Beispiel #1
0
        public override void OnSelectionChange()
        {
            isNoticeIgnore = false;
            if (!FR2_Cache.isReady)
            {
                return;
            }

            if (lockSelection)
            {
                return;
            }

            if (focusedWindow == null)
            {
                return;
            }

            if (SceneUsesDrawer == null)
            {
                InitIfNeeded();
            }

            ids = FR2_Unity.Selection_AssetGUIDs;

            //ignore selection on asset when selected any object in scene
            if (Selection.gameObjects.Length > 0 && !FR2_Unity.IsInAsset(Selection.gameObjects[0]))
            {
                ids = new string[0];
            }

            if (IsFocusingSceneInScene)
            {
                RefSceneInScene.ResetSceneInScene(Selection.gameObjects);
            }

            if (IsFocusingUses)
            {
                SceneUsesDrawer.ResetSceneUseSceneObjects(Selection.gameObjects);
            }

            if (IsFocusingFindInScene)
            {
                RefInScene.Reset(ids, this as IWindow);
            }

            level = 0;

            EditorApplication.delayCall += Repaint;
        }
Beispiel #2
0
        // ------------------------- Scene use scene objects
        public static Dictionary <string, FR2_Ref> FindSceneUseSceneObjects(GameObject[] targets)
        {
            var results = new Dictionary <string, FR2_Ref>();

            GameObject[] objs = Selection.gameObjects;
            for (var i = 0; i < objs.Length; i++)
            {
                if (FR2_Unity.IsInAsset(objs[i]))
                {
                    continue;
                }

                string key = objs[i].GetInstanceID().ToString();
                if (!results.ContainsKey(key))
                {
                    results.Add(key, new FR2_SceneRef(0, objs[i]));
                }

                Component[] coms = objs[i].GetComponents <Component>();
                Dictionary <Component, HashSet <FR2_SceneCache.HashValue> > SceneCache = FR2_SceneCache.Api.cache;
                for (var j = 0; j < coms.Length; j++)
                {
                    HashSet <FR2_SceneCache.HashValue> hash = null;
                    if (SceneCache.TryGetValue(coms[j], out hash))
                    {
                        foreach (FR2_SceneCache.HashValue item in hash)
                        {
                            if (item.isSceneObject)
                            {
                                Object obj  = item.target;
                                string key1 = obj.GetInstanceID().ToString();
                                if (!results.ContainsKey(key1))
                                {
                                    results.Add(key1, new FR2_SceneRef(1, obj));
                                }
                            }
                        }
                    }
                }
            }

            return(results);
        }
Beispiel #3
0
        public static Dictionary <string, FR2_Ref> FindUsageScene(GameObject[] objs, bool depth)
        {
            var dict = new Dictionary <string, FR2_Ref>();

            // var list = new List<FR2_Ref>();

            for (var i = 0; i < objs.Length; i++)
            {
                if (FR2_Unity.IsInAsset(objs[i]))
                {
                    continue;                     //only get in scene
                }

                //add selection
                if (!dict.ContainsKey(objs[i].GetInstanceID().ToString()))
                {
                    dict.Add(objs[i].GetInstanceID().ToString(), new FR2_SceneRef(0, objs[i]));
                }

                foreach (Object item in FR2_Unity.GetAllRefObjects(objs[i]))
                {
                    AppendUsageScene(dict, item);
                }

                if (depth)
                {
                    foreach (GameObject child in FR2_Unity.getAllChild(objs[i]))
                    {
                        foreach (Object item2 in FR2_Unity.GetAllRefObjects(child))
                        {
                            AppendUsageScene(dict, item2);
                        }
                    }
                }
            }

            return(dict);
        }
Beispiel #4
0
        public override void OnSelectionChange()
        {
            Repaint();

            isNoticeIgnore = false;
            if (!FR2_Cache.isReady)
            {
                return;
            }

            if (lockSelection)
            {
                return;
            }

            if (focusedWindow == null)
            {
                return;
            }

            if (SceneUsesDrawer == null)
            {
                InitIfNeeded();
            }

            if (UsesDrawer == null)
            {
                InitIfNeeded();
            }

            ids = FR2_Unity.Selection_AssetGUIDs;

            //ignore selection on asset when selected any object in scene
            if (Selection.gameObjects.Length > 0 && !FR2_Unity.IsInAsset(Selection.gameObjects[0]))
            {
                ids = new string[0];
            }

            level = 0;
            if (IsFocusingSceneToAsset)
            {
                SceneToAssetDrawer.Reset(Selection.gameObjects, true, true);
            }

            if (IsFocusingUses)
            {
                UsesDrawer.Reset(ids, true);
            }

            if (IsFocusingUsedBy)
            {
                UsedByDrawer.Reset(ids, false);
            }

            if (IsFocusingSceneInScene)
            {
                RefSceneInScene.ResetSceneInScene(Selection.gameObjects);
            }

            if (IsFocusingUses)
            {
                SceneUsesDrawer.ResetSceneUseSceneObjects(Selection.gameObjects);
            }

            if (IsFocusingFindInScene)
            {
                RefInScene.Reset(ids, this as IWindow);
            }

            if (IsFocusingGUIDs)
            {
                objs = new Object[ids.Length];
                for (var i = 0; i < ids.Length; i++)
                {
                    objs[i] = FR2_Unity.LoadAssetAtPath <Object>
                              (
                        AssetDatabase.GUIDToAssetPath(ids[i])
                              );
                }
            }


            if (FR2_SceneCache.Api.Dirty && !Application.isPlaying)
            {
                FR2_SceneCache.Api.refreshCache(this);
            }

            EditorApplication.delayCall -= Repaint;
            EditorApplication.delayCall += Repaint;
        }
Beispiel #5
0
        // ------------------------- Scene in scene
        public static Dictionary <string, FR2_Ref> FindSceneInScene(GameObject[] targets)
        {
            var results = new Dictionary <string, FR2_Ref>();

            GameObject[] objs = Selection.gameObjects;
            for (var i = 0; i < objs.Length; i++)
            {
                if (FR2_Unity.IsInAsset(objs[i]))
                {
                    continue;
                }

                string key = objs[i].GetInstanceID().ToString();
                if (!results.ContainsKey(key))
                {
                    results.Add(key, new FR2_SceneRef(0, objs[i]));
                }


                foreach (KeyValuePair <Component, HashSet <FR2_SceneCache.HashValue> > item in FR2_SceneCache.Api.cache)
                {
                    foreach (FR2_SceneCache.HashValue item1 in item.Value)
                    {
                        // if(item.Key.gameObject.name == "ScenesManager")
                        // Debug.Log(item1.objectReferenceValue);
                        GameObject ob = null;
                        if (item1.target is GameObject)
                        {
                            ob = item1.target as GameObject;
                        }
                        else
                        {
                            var com = item1.target as Component;
                            if (com == null)
                            {
                                continue;
                            }

                            ob = com.gameObject;
                        }

                        if (ob == null)
                        {
                            continue;
                        }

                        if (ob != objs[i])
                        {
                            continue;
                        }

                        key = item.Key.GetInstanceID().ToString();
                        if (!results.ContainsKey(key))
                        {
                            results.Add(key, new FR2_SceneRef(1, item.Key));
                        }

                        (results[key] as FR2_SceneRef).usingType.Add(item1.target.GetType().FullName);
                    }
                }
            }

            return(results);
        }