unity editor下选中GameObject粘贴复制pos信息
生活随笔
收集整理的這篇文章主要介紹了
unity editor下选中GameObject粘贴复制pos信息
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
參考:https://blog.uwa4d.com/archives/USparkle_Continuous-optimization.html
?實現(xiàn):運行時 選中GameObject后copy坐標信息可粘貼出來
實現(xiàn)代碼:
using System.Collections; using System.Collections.Generic; using UnityEngine;public class TestCopyPosHelper : MonoBehaviour {private void OnEnable(){UnityEditor.Selection.selectionChanged += OnSelectChanged;}// Use this for initializationvoid Start (){}// Update is called once per framevoid Update (){}private void OnDisable(){UnityEditor.Selection.selectionChanged -= OnSelectChanged;}private void OnSelectChanged(){GameObject tempSelectObject = UnityEditor.Selection.activeGameObject;if(tempSelectObject!=null){string ret = tempSelectObject.transform.localPosition.x.ToString("0.0") + "," +tempSelectObject.transform.localPosition.y.ToString("0.0") + "," +tempSelectObject.transform.localPosition.z.ToString("0.0");Debug.LogError(ret);GUIUtility.systemCopyBuffer = ret;}} }
轉(zhuǎn)載于:https://www.cnblogs.com/sun-shadow/p/9080158.html
總結(jié)
以上是生活随笔為你收集整理的unity editor下选中GameObject粘贴复制pos信息的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 0523 CSS知识点
- 下一篇: (扫盲)RPC远程过程调用