예제 #1
0
        public UIFile(UIFloder _parent, string _fileName, bool displayLayer)
        {
            fileName    = _fileName;
            displayName = fileName;
            parent      = _parent;
            //查找当前 Hierhary 中 同名Gameobject
            var objects            = FindObjectsOfType <GameObject>();
            List <GameObject> objs = new List <GameObject>();

            foreach (var o in objects)
            {
                if (o.name != fileName)
                {
                    continue;
                }
                var parent     = PrefabUtility.GetPrefabParent(o);
                var parentPath = AssetDatabase.GetAssetPath(parent);
                //追溯 GameObjet 的路径,进行比较
                parentPath = parentPath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
                selected   = parentPath.Contains(GetPath());
                if (selected)
                {
                    instance = o;
                    break;
                }
            }

            if (!displayLayer)
            {
                return;
            }
            var path   = GetPath();
            var prefab = Resources.Load <GameObject>(path);

            if (prefab == null)
            {
                return;
            }
            var canvas = prefab.GetComponent <Canvas>();

            if (canvas == null)
            {
                return;
            }
            displayName += "(" + canvas.sortingLayerName + " " + canvas.sortingOrder + ")";
        }
예제 #2
0
 public void SetFloder(List <string> array, bool displayLayer = false)
 {
     if (array[0].EndsWith(".prefab"))
     {
         UIFile f = new UIFile(this, array[0].Substring(0, array[0].Length - 7), displayLayer);
         files.Add(f);
     }
     else
     {
         UIFloder floder = null;
         if (!floders.TryGetValue(array[0], out floder))
         {
             floder            = new UIFloder();
             floder.floderName = array[0];
             floder.parent     = this;
             floder.depth      = depth + 1;
             floders.Add(array[0], floder);
         }
         array.RemoveAt(0);
         floder.SetFloder(array, displayLayer);
     }
 }
예제 #3
0
    public void Init(bool displayLayer = false)
    {
        var files = Directory.GetFiles("Assets", "*.prefab", SearchOption.AllDirectories);

        dic = new Dictionary <string, UIFloder>();

        foreach (var f in files)
        {
            bool skip = true;
            for (int a = 0; a < PathFilter.Length; a++)
            {
                var p = PathFilter[a];
                if (f.Contains(p))
                {
                    skip = false;
                }
            }
            if (skip)
            {
                continue;
            }

            var sps     = f.Split(Path.DirectorySeparatorChar);
            var key     = sps[1];
            var i       = f.IndexOf("UI") + 3;
            var value   = f.Substring(i);
            var floders = value.Split(Path.DirectorySeparatorChar);
            var list    = new List <string>();
            list.AddRange(floders);
            if (!dic.ContainsKey(key))
            {
                UIFloder floder = new UIFloder();
                floder.floderName = key;
                dic.Add(key, floder);
            }
            dic[key].SetFloder(list, displayLayer);
        }
    }