コード例 #1
0
        private void SequenceUpdate()
        {
            if (CurrentSequence)
            {
                float currentTime = Time.realtimeSinceStartup;
                float deltaTime   = currentTime - PreviousTime;
                if (Mathf.Abs(deltaTime) > JSequencer.SequenceUpdateRate)
                {
                    if (CurrentSequence.IsPlaying && !Application.isPlaying)
                    {
                        //CurrentSequence.UpdateSequencer(deltaTime * Time.timeScale);
                        Repaint();
                    }
                    PreviousTime = currentTime;
                }
            }
            JSequencer nextSequence = null;

            if (Selection.activeGameObject != null && (CurrentSequence == null || Selection.activeGameObject != CurrentSequence.gameObject))
            {
                nextSequence = Selection.activeGameObject.GetComponent <JSequencer>();
                if (nextSequence != null)
                {
                    bool isPrefab = PrefabUtility.GetPrefabParent(nextSequence.gameObject) == null && PrefabUtility.GetPrefabObject(nextSequence.gameObject) != null;
                    if (isPrefab)
                    {
                        nextSequence = null;
                    }
                }
            }
            else
            {
                return;
            }

            if (nextSequence == null)
            {
                return;
            }

            if (!Application.isPlaying && CurrentSequence != nextSequence)
            {
                if (CurrentSequence)
                {
                    CurrentSequence.Stop();
                }

                if (nextSequence)
                {
                    nextSequence.Stop();
                }

                StopProcessingAnimationMode();
            }

            SequenceSwitch(nextSequence);

            Repaint();
        }
コード例 #2
0
 private void Stop()
 {
     if (!CurrentSequence)
     {
         return;
     }
     CurrentSequence.Stop();
     StopProcessingAnimationMode();
 }
コード例 #3
0
        private void StopProcessingAnimationMode()
        {
            if (CurrentSequence)
            {
                CurrentSequence.Stop();
            }

            if (Application.isPlaying)
            {
                return;
            }

            ContentRenderer.RestoreBaseState();
        }
コード例 #4
0
        private void OnDestroy()
        {
            thisWindow = null;
            EditorApplication.hierarchyWindowChanged -= OnHierarchyChanged;
            SceneView.onSceneGUIDelegate             -= OnScene;
            Undo.undoRedoPerformed -= UndoRedoCallback;
            EditorApplication.playmodeStateChanged -= PlayModeStateChanged;
            EditorApplication.update -= SequenceUpdate;

            StopProcessingAnimationMode();

            if (CurrentSequence)
            {
                CurrentSequence.Stop();
            }
        }
コード例 #5
0
        private void StopProcessingAnimationMode()
        {
            if (CurrentSequence)
            {
                CurrentSequence.Stop();
            }

            if (!AnimationHelper.IsInAnimationMode)
            {
                return;
            }

            if (Application.isPlaying)
            {
                return;
            }

            USUndoManager.RegisterCompleteObjectUndo(this, "Play");
            IsInAnimationMode = false;

            ContentRenderer.RestoreBaseState();
        }
コード例 #6
0
        private void Stop()
        {
            if (!CurrentSequence)
            {
                return;
            }

            USUndoManager.PropertyChange(CurrentSequence, "Stop");

            CurrentSequence.Stop();
            StopProcessingAnimationMode();

            if (isArmed)
            {
                if (GetOrSpawnRecorder())
                {
                    GetOrSpawnRecorder().StopRecording();
                }

                DestroyImmediate(GetOrSpawnRecorder().gameObject);
            }

            isArmed = false;
        }
コード例 #7
0
        private void SequenceUpdate()
        {
            if (PropertyBoxPopup.OpenCooldown >= 0.0f)
            {
                var currentTime = Time.realtimeSinceStartup;
                var deltaTime   = currentTime - PreviousTime;
                PropertyBoxPopup.OpenCooldown = PropertyBoxPopup.OpenCooldown - deltaTime;
            }
            PropertyBoxPopup.OpenCooldown = Mathf.Clamp(PropertyBoxPopup.OpenCooldown, 0.0f, 1.0f);

            if (CurrentSequence)
            {
                var currentTime = Time.realtimeSinceStartup;
                var deltaTime   = currentTime - PreviousTime;

                if (Mathf.Abs(deltaTime) > USSequencer.SequenceUpdateRate)
                {
                    if (CurrentSequence.IsPlaying && !Application.isPlaying)
                    {
                        CurrentSequence.UpdateSequencer(deltaTime * Time.timeScale);
                        Repaint();
                    }
                    PreviousTime = currentTime;
                }
            }

            USSequencer nextSequence = null;

            if (Selection.activeGameObject != null && (CurrentSequence == null || Selection.activeGameObject != CurrentSequence.gameObject))
            {
                nextSequence = Selection.activeGameObject.GetComponent <USSequencer>();
                if (nextSequence != null)
                {
                    var isPrefab = PrefabUtility.GetPrefabParent(nextSequence.gameObject) == null && PrefabUtility.GetPrefabObject(nextSequence.gameObject) != null;
                    if (isPrefab)
                    {
                        nextSequence = null;
                    }
                }
            }
            else
            {
                return;
            }

            if (nextSequence == null)
            {
                return;
            }

            if (!Application.isPlaying && CurrentSequence != nextSequence)
            {
                ShowOnlyAnimated = false;

                if (CurrentSequence)
                {
                    CurrentSequence.Stop();
                }

                if (nextSequence)
                {
                    nextSequence.Stop();
                }

                StopProcessingAnimationMode();
            }

            SequenceSwitch(nextSequence);

            Repaint();
        }
コード例 #8
0
        private void DisplayTopBar()
        {
            var space = 16.0f;

            GUILayout.Box("", EditorStyles.toolbar, GUILayout.ExpandWidth(true), GUILayout.Height(18.0f));

            if (Event.current.type == EventType.Repaint)
            {
                TopBar = GUILayoutUtility.GetLastRect();
            }

            using (new Shared.GUIBeginArea(TopBar))
            {
                using (new Shared.GUIBeginHorizontal())
                {
                    if (GUILayout.Button("Create New Sequence", EditorStyles.toolbarButton))
                    {
                        var newSequence = new GameObject("Sequence");
                        USUndoManager.RegisterCreatedObjectUndo(newSequence, "Create new sequence");

                        var sequence = newSequence.AddComponent <USSequencer>();
                        sequence.Version = USUpgradePaths.CurrentVersionNumber;
                        USUndoManager.RegisterCreatedObjectUndo(sequence, "Create new sequence");

                        USUndoManager.RegisterCompleteObjectUndo(newSequence, "Create new sequence");
                        USRuntimeUtility.CreateAndAttachObserver(sequence);

                        if (CurrentSequence == null)
                        {
                            Selection.activeGameObject = newSequence;
                            Selection.activeTransform  = newSequence.transform;
                            SequenceSwitch(sequence);
                        }

                        Repaint();
                    }

                    var currentSequence = CurrentSequence != null ? CurrentSequence.name : "";
                    var label           = "Select a Sequence";
                    if (CurrentSequence != null)
                    {
                        label = String.Format("Editting : {0}", currentSequence);
                    }
                    if (GUILayout.Button(label, EditorStyles.toolbarButton, GUILayout.Width(150.0f)))
                    {
                        var menu             = new GenericMenu();
                        var sequences        = FindObjectsOfType(typeof(USSequencer)) as USSequencer[];
                        var orderedSequences = sequences.OrderBy(sequence => sequence.name);
                        foreach (var sequence in orderedSequences)
                        {
                            menu.AddItem(new GUIContent(sequence.name),
                                         currentSequence == sequence.name ? true : false,
                                         (obj) => Selection.activeGameObject = (GameObject)obj,
                                         sequence.gameObject);
                        }
                        menu.ShowAsContext();
                    }

                    GUILayout.Space(space);
                    GUILayout.Box("", USEditorUtility.SeperatorStyle, GUILayout.Height(18.0f));
                    GUILayout.Space(space);

                    if (CurrentSequence != null)
                    {
                        using (new Shared.GUIChangeColor((AnimationHelper.IsInAnimationMode || IsArmed) ? Color.red : GUI.color))
                        {
                            if (GUILayout.Button(new GUIContent(!CurrentSequence.IsPlaying ? USEditorUtility.PlayButton : USEditorUtility.PauseButton, "Toggle Play Mode (P)"), USEditorUtility.ToolbarButtonSmall))
                            {
                                PlayOrPause();
                            }

                            if (GUILayout.Button(USEditorUtility.StopButton, USEditorUtility.ToolbarButtonSmall))
                            {
                                Stop();
                            }
                        }
                        using (new Shared.GUIEnable(EditorApplication.isPlaying))
                        {
                            var buttonContent = new GUIContent(USEditorUtility.RecordButton, !EditorApplication.isPlaying ? "You must be in Play Mode to enable this button" : "Start g");
                            if (GUILayout.Button(buttonContent, USEditorUtility.ToolbarButtonSmall))
                            {
                                Record();
                            }
                        }

                        GUILayout.Space(space);

                        USUndoManager.BeginChangeCheck();
                        GUILayout.Button(new GUIContent(USEditorUtility.PrevKeyframeButton, "Prev Keyframe (Alt + ,)"), USEditorUtility.ToolbarButtonSmall);
                        if (USUndoManager.EndChangeCheck())
                        {
                            USUndoManager.PropertyChange(this, "Previous Keyframe");
                            GoToPrevKeyframe();
                        }

                        USUndoManager.BeginChangeCheck();
                        GUILayout.Button(new GUIContent(USEditorUtility.NextKeyframeButton, "Next Keyframe (Alt + .)"), USEditorUtility.ToolbarButtonSmall);
                        if (USUndoManager.EndChangeCheck())
                        {
                            USUndoManager.PropertyChange(this, "Next Keyframe");
                            GoToNextKeyframe();
                        }

                        GUILayout.Space(space);
                        GUILayout.Box("", USEditorUtility.SeperatorStyle, GUILayout.Height(18.0f));
                        GUILayout.Space(space);

                        EditorGUILayout.LabelField(new GUIContent("Keyframe Snap", "The amount keyframes will snap to when dragged in the uSequencer window. (Left Shift to activate)"), GUILayout.MaxWidth(100.0f));
                        USUndoManager.BeginChangeCheck();
                        var snapAmount = EditorGUILayout.FloatField(new GUIContent("", "The amount keyframes will snap to when dragged in the uSequencer window. (Left Shift to activate)"), ContentRenderer.SnapAmount, GUILayout.MaxWidth(40.0f));
                        if (USUndoManager.EndChangeCheck())
                        {
                            USUndoManager.PropertyChange(this, "Snap Amount");
                            ContentRenderer.SnapAmount = snapAmount;
                        }

                        GUILayout.Space(space);
                        GUILayout.Box("", USEditorUtility.SeperatorStyle, GUILayout.Height(18.0f));
                        GUILayout.Space(space);
                    }

                    GUILayout.FlexibleSpace();

                    if (CurrentSequence && GUILayout.Button("Duplicate Sequence", EditorStyles.toolbarButton))
                    {
                        USEditorUtility.DuplicateSequence(CurrentSequence);
                    }

                    if (CurrentSequence && GUILayout.Button(PrefabUtility.GetPrefabObject(CurrentSequence.gameObject) ? "Update Prefab" : "Create Prefab", EditorStyles.toolbarButton))
                    {
                        CurrentSequence.Stop();
                        StopProcessingAnimationMode();
                        USEditorUtility.CreatePrefabFrom(CurrentSequence, false);
                    }
                }
            }
        }