コード例 #1
0
            public static void InitAllPrefabInstancePools()
            {
                for (int i = 0; i < SceneManager.sceneCount; i++)
                {
                    Scene scene = SceneManager.GetSceneAt(i);

                    PrefabInstancePool[] prefabPools = SceneUtils.FindAllComponentInferfacesInScene <PrefabInstancePool>(scene);

                    for (int j = 0; j < prefabPools.Length; j++)
                    {
                        prefabPools[j].Init();
                    }
                }
            }
コード例 #2
0
            private bool DrawSnapshotDropdown()
            {
                AnimatedCamera camera = (AnimatedCamera)target;

                IAnimatedCameraStateSource[] snapshots = SceneUtils.FindAllComponentInferfacesInScene <IAnimatedCameraStateSource>(camera.gameObject.scene);

                int index        = 0;
                int currentIndex = -1;

                string[] snapshotNames = new string[snapshots.Length + 2];
                snapshotNames[index++] = "(None)";

                foreach (IAnimatedCameraStateSource snapshot in snapshots)
                {
                    snapshotNames[index] = snapshot.GetName();

                    if (snapshot == _currentSnapshot)
                    {
                        currentIndex = index;
                    }

                    index++;
                }

                snapshotNames[index++] = "(New Snapshot)";

                int newIndex = EditorGUILayout.Popup("Edit Snapshot", currentIndex == -1 ? 0 : currentIndex, snapshotNames);

                if (currentIndex != newIndex)
                {
                    if (newIndex == 0)
                    {
                        SetCurrentSnapshot(null);
                    }
                    else if (newIndex == snapshotNames.Length - 1)
                    {
                        //Add new snapshot!
                        GameObject newObj = new GameObject("Snapshot" + newIndex);
                        newObj.transform.parent   = camera.transform.parent;
                        newObj.transform.position = camera.transform.position;
                        newObj.transform.rotation = camera.transform.rotation;

                        IAnimatedCameraStateSource newSnapShot = newObj.AddComponent(camera.GetAnimatedCameraStateSourceType()) as IAnimatedCameraStateSource;
                        if (newSnapShot != null)
                        {
                            UpdateSnapshotFromCamera(newSnapShot);
                            SetCurrentSnapshot(newSnapShot);
                        }

                        return(true);
                    }
                    else
                    {
                        SetCurrentSnapshot(snapshots[newIndex - 1]);
                    }
                }

                DrawCameraProperties();

                return(false);
            }