zoukankan      html  css  js  c++  java
  • copy节点相对prefab的路径 (unity小工具)

        [MenuItem("GameObject/copy节点相对prefab的路径", false, 36)]
        public static void CopyPathByPrefab()
        {
            UnityEngine.Object obj = Selection.activeObject;
            if (obj == null)
            {
                Debug.LogError("You must select Obj first!");
                return;
            }
            string result = AssetDatabase.GetAssetPath(obj);
            if (string.IsNullOrEmpty(result))//如果不是资源则在场景中查找
            {
                Transform selectChild = Selection.activeTransform;
                if (selectChild != null)
                {
                    result = selectChild.name;
                    while (selectChild.parent != null)
                    {
                        selectChild = selectChild.parent;
                        if(selectChild.parent !=null)
                        {
                            result = string.Format("{0}/{1}", selectChild.name, result);
                        }
                    }
                }
            }
            ClipBoard.Copy(result);
            Debug.Log(string.Format("The gameobject:{0}'s path has been copied to the clipboard!", obj.name));
    
        }
    改变自己
  • 相关阅读:
    软件工程——股票利润
    软件工程——爬楼梯
    总结
    团队4
    团队答辩
    团队3
    软工2
    团队合作(1)
    软件工程第二次作业
    软件工程第一次作业(2)
  • 原文地址:https://www.cnblogs.com/sun-shadow/p/15001806.html
Copyright © 2011-2022 走看看