Example #1
0
        public FR2_RefDrawer Reset(string[] assetGUIDs, bool isUsage)
        {
            //Debug.Log("Reset :: " + assetGUIDs.Length + "\n" + string.Join("\n", assetGUIDs));

            if (isUsage)
            {
                refs = FR2_Ref.FindUsage(assetGUIDs);
            }
            else
            {
                refs = FR2_Ref.FindUsedBy(assetGUIDs);
            }

            //RefreshFolders();

            // Remove folders && items in assetGUIDs
            //var map = new Dictionary<string, int>();
            //for (var i = 0;i < assetGUIDs.Length; i++)
            //{
            //	map.Add(assetGUIDs[i], i);
            //}

            //for (var i = refs.Count-1; i>=0; i--)
            //{
            //	var a = refs[i].asset;
            //	if (!a.IsFolder) continue; // && !map.ContainsKey(refs[i].asset.guid)
            //	refs.RemoveAt(i); //Remove folders and items in Selection
            //}

            dirty = true;
            if (list != null)
            {
                list.Clear();
            }

            return(this);
        }
Example #2
0
        public FR2_RefDrawer Reset(GameObject[] objs, bool findDept, bool findPrefabInAsset)
        {
            refs = FR2_Ref.FindUsageScene(objs, findDept);

            var guidss = new List <string>();
            Dictionary <GameObject, HashSet <string> > dependent = FR2_SceneCache.Api.prefabDependencies;

            foreach (GameObject gameObject in objs)
            {
                HashSet <string> hash;
                if (!dependent.TryGetValue(gameObject, out hash))
                {
                    continue;
                }

                foreach (string guid in hash)
                {
                    guidss.Add(guid);
                }
            }

            Dictionary <string, FR2_Ref> usageRefs1 = FR2_Ref.FindUsage(guidss.ToArray());

            foreach (KeyValuePair <string, FR2_Ref> kvp in usageRefs1)
            {
                if (refs.ContainsKey(kvp.Key))
                {
                    continue;
                }

                if (guidss.Contains(kvp.Key))
                {
                    kvp.Value.depth = 1;
                }

                refs.Add(kvp.Key, kvp.Value);
            }


            if (findPrefabInAsset)
            {
                var guids = new List <string>();
                for (var i = 0; i < objs.Length; i++)
                {
                    string guid = FR2_Unity.GetPrefabParent(objs[i]);
                    if (string.IsNullOrEmpty(guid))
                    {
                        continue;
                    }

                    guids.Add(guid);
                }

                Dictionary <string, FR2_Ref> usageRefs = FR2_Ref.FindUsage(guids.ToArray());
                foreach (KeyValuePair <string, FR2_Ref> kvp in usageRefs)
                {
                    if (refs.ContainsKey(kvp.Key))
                    {
                        continue;
                    }

                    if (guids.Contains(kvp.Key))
                    {
                        kvp.Value.depth = 1;
                    }

                    refs.Add(kvp.Key, kvp.Value);
                }
            }

            dirty = true;
            if (list != null)
            {
                list.Clear();
            }

            return(this);
        }
Example #3
0
        public void RefreshView()
        {
            var scenes = new HashSet <string>();

            // string[] scenes = new string[sceneCount];
            foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes)
            {
                if (scene == null)
                {
                    continue;
                }

                if (scene.enabled == false)
                {
                    continue;
                }

                string sce = AssetDatabase.AssetPathToGUID(scene.path);

                if (scenes.Contains(sce))
                {
                    continue;
                }

                scenes.Add(sce);
            }

            refs = FR2_Ref.FindUsage(scenes.ToArray());

            foreach (string VARIABLE in scenes)
            {
                FR2_Ref asset = null;
                if (!refs.TryGetValue(VARIABLE, out asset))
                {
                    continue;
                }


                asset.depth = 1;
            }

            List <FR2_Asset> list = FR2_Cache.Api.AssetList;
            int count             = list.Count;

            for (var i = 0; i < count; i++)
            {
                FR2_Asset item = list[i];
                if (item.inEditor)
                {
                    continue;
                }

                if (item.inPlugins)
                {
                    if (item.type == FR2_AssetType.SCENE)
                    {
                        continue;
                    }
                }

                if (item.inResources || item.inStreamingAsset || item.inPlugins)
                {
                    if (refs.ContainsKey(item.guid))
                    {
                        continue;
                    }

                    refs.Add(item.guid, new FR2_Ref(0, 1, item, null));
                }
            }

            drawer.SetRefs(refs);
            dirty = false;
        }