Esempio n. 1
0
            public static GameObject GetScenePrefabInstance(Scene scene, int id)
            {
                UnityPlayModeSaverSceneUtils prefabIndexer = GetPrefabIndexer(scene);

                if (prefabIndexer != null)
                {
                    return(prefabIndexer.GetScenePrefabInstance(id));
                }

                return(null);
            }
Esempio n. 2
0
            public static bool IsScenePrefabInstance(Object obj, Scene scene, out GameObject prefab, out int id)
            {
                UnityPlayModeSaverSceneUtils prefabIndexer = GetPrefabIndexer(scene);

                if (prefabIndexer != null)
                {
                    return(prefabIndexer.IsScenePrefabInstance(obj, out prefab, out id));
                }

                prefab = null;
                id     = -1;
                return(false);
            }
Esempio n. 3
0
            private static UnityPlayModeSaverSceneUtils GetPrefabIndexer(Scene scene)
            {
                foreach (GameObject rootObject in scene.GetRootGameObjects())
                {
                    UnityPlayModeSaverSceneUtils prefabIndexer = rootObject.GetComponentInChildren <UnityPlayModeSaverSceneUtils>();

                    if (prefabIndexer != null)
                    {
                        return(prefabIndexer);
                    }
                }

                return(null);
            }
Esempio n. 4
0
            public static void CacheScenePrefabInstances(Scene scene)
            {
                UnityPlayModeSaverSceneUtils prefabIndexer = GetPrefabIndexer(scene);

                if (prefabIndexer == null)
                {
                    GameObject gameObject = new GameObject("Prefab Indexer", typeof(UnityPlayModeSaverSceneUtils))
                    {
                        hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector | HideFlags.NotEditable
                    };
                    SceneManager.MoveGameObjectToScene(gameObject, scene);
                    prefabIndexer = gameObject.GetComponent <UnityPlayModeSaverSceneUtils>();
                }

                prefabIndexer.BuildScenePrefabMap();
            }