Beispiel #1
0
            private void UpdateSnapshotFromCamera(IAnimatedCameraStateSource snapshot)
            {
                AnimatedCamera camera = (AnimatedCamera)target;

                if (snapshot != null)
                {
                    snapshot.SetState(camera.GetState());
                }
            }
Beispiel #2
0
            protected virtual void SetCurrentSnapshot(IAnimatedCameraStateSource snapshot)
            {
                //Select new snapshot
                _currentSnapshot = snapshot;

                if (_currentSnapshot != null)
                {
                    //Set camera position to snapshot
                    UpdateCameraFromSnapshot();
                }
                else
                {
                    ResetCameraState();
                }
            }
Beispiel #3
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);
            }