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));
    
        }
    改变自己
  • 相关阅读:
    加一
    斐波那契数
    整数的各位积和之差
    移除元素
    删除排序数组中的重复项
    有效的括号
    爬楼梯
    最长公共前缀
    罗马数字转整数
    回文数
  • 原文地址:https://www.cnblogs.com/sun-shadow/p/15001806.html
Copyright © 2011-2022 走看看