static bool RunUpgradePath1_11To1_15(USSequencer sequence)
        {
            sequence.Version = 5;

            USRuntimeUtility.CreateAndAttachObserver(sequence);

            return(true);
        }
Esempio n. 2
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);
                    }
                }
            }
        }