Esempio n. 1
0
        private void OnEnable()
        {
            showAnimationModeTime = EditorApplication.timeSinceStartup;
            thisWindow            = this;
            hideFlags             = HideFlags.HideAndDontSave;

            if (ContentRenderer == null)
            {
                ContentRenderer = CreateInstance <USContent>();
            }
            ContentRenderer.SequenceWindow = this;

            // Run our upgrade paths, do this for each sequence in the hierarchy.
            var sequences = FindObjectsOfType(typeof(USSequencer)) as USSequencer[];

            foreach (var sequence in sequences)
            {
                USUpgradePaths.RunUpgradePaths(sequence);
            }

            EditorApplication.hierarchyWindowChanged -= OnHierarchyChanged;
            EditorApplication.hierarchyWindowChanged += OnHierarchyChanged;
            SceneView.onSceneGUIDelegate             -= OnScene;
            SceneView.onSceneGUIDelegate             += OnScene;
            Undo.undoRedoPerformed -= UndoRedoCallback;
            Undo.undoRedoPerformed += UndoRedoCallback;
            EditorApplication.playmodeStateChanged -= PlayModeStateChanged;
            EditorApplication.playmodeStateChanged += PlayModeStateChanged;
            EditorApplication.update -= SequenceUpdate;
            EditorApplication.update += SequenceUpdate;
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.HelpBox("Sequence Settings", MessageType.None);

            EditorGUILayout.PropertyField(updateOnFixedUpdate, new GUIContent("Fixed Update?"));
            EditorGUILayout.PropertyField(autoPlay, new GUIContent("Auto Play?"));

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.HelpBox("Utility", MessageType.None);

            var sequences = new List <USSequencer>();

            foreach (var target in targets)
            {
                var sequence = target as USSequencer;
                if (sequence == null)
                {
                    continue;
                }

                sequences.Add(sequence);
            }

            if (sequences.Count == 1 && GUILayout.Button("Open and Edit Sequence"))
            {
                USWindow.OpenuSequencerWindow();
                Selection.activeObject = sequences[0];
            }

            if (sequences.Count <= 1)
            {
                EditorGUILayout.Space();
                EditorGUILayout.Space();
            }

            if (GUILayout.Button(sequences.Count > 1 ? "Duplicate Sequences" : "Duplicate Sequence"))
            {
                foreach (var sequence in sequences)
                {
                    USEditorUtility.DuplicateSequence(sequence);
                }
            }

            if (sequences.Count == 1 && GUILayout.Button(PrefabUtility.GetPrefabObject(sequences[0].gameObject) ? "Update Prefab" : "Create Prefab"))
            {
                USEditorUtility.CreatePrefabFrom(sequences[0], false);
            }

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 3
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();
            }
        }
Esempio n. 4
0
        public override void DoGUI(int depth)
        {
            BaseTimeline.ShouldRenderGizmos = IsExpanded && USPreferenceWindow.RenderHierarchyGizmos;

            using (new Shared.GUIBeginHorizontal())
            {
                using (new Shared.GUIBeginVertical(GUILayout.MaxWidth(FloatingWidth)))
                {
                    FloatingOnGUI(depth);

                    if (IsExpanded)
                    {
                        var propertyArea = FloatingBackgroundRect;
                        propertyArea.y     += ItemHeightStep;
                        propertyArea.x      = GetXOffsetForDepth(depth + 1);
                        propertyArea.width -= propertyArea.x;

                        using (new Shared.GUIBeginArea(propertyArea))
                        {
                            foreach (var propertyBox in propertyBoxes)
                            {
                                using (new Shared.GUIBeginHorizontal())
                                {
                                    propertyBox.OnGUI();

                                    using (new Shared.GUIChangeColor(Color.red))
                                    {
                                        if (GUILayout.Button("-", GUILayout.Width(20.0f)))
                                        {
                                            removingProperty = propertyBox;
                                        }
                                    }

                                    // This can happen during undo redo.
                                    if (propertyBox.PropertyFieldInfo == null)
                                    {
                                        continue;
                                    }

                                    var preFix       = propertyBox.PropertyFieldInfo.Name;
                                    var propertyInfo = PropertyTimeline.GetProperty(preFix, propertyBox.PropertyFieldInfo.Component);
                                    using (new Shared.GUIChangeColor(propertyInfo.UseCurrentValue ? Color.red : GUI.color))
                                    {
                                        if (GUILayout.Button("C"))
                                        {
                                            propertyInfo.UseCurrentValue = !propertyInfo.UseCurrentValue;
                                        }
                                    }
                                }
                            }

                            if (GUILayout.Button("Animate"))
                            {
                                if (Event.current.type == EventType.Repaint)
                                {
                                    animateButton = GUILayoutUtility.GetLastRect();
                                }

                                var components = PropertyTimeline.AffectedObject.GetComponents <Component>().ToList();

                                var allPropertyBoxes = new List <PropertyBox>();
                                foreach (var component in components)
                                {
                                    var properties = component.GetType().GetProperties().Where(property => !PropertyFieldInfoUtility.ShouldIgnoreProperty(property, component));
                                    var fields     = component.GetType().GetFields().Where(field => !PropertyFieldInfoUtility.shouldIgnoreField(field, component));

                                    foreach (var property in properties)
                                    {
                                        allPropertyBoxes.Add(new PropertyBox(new PropertyFieldInfo(component, property), true));
                                    }

                                    foreach (var field in fields)
                                    {
                                        allPropertyBoxes.Add(new PropertyBox(new PropertyFieldInfo(component, field), true));
                                    }
                                }

                                foreach (var propertyBox in propertyBoxes)
                                {
                                    var overlappingProperties = allPropertyBoxes.Where(innerPropertyBox => innerPropertyBox.Component == propertyBox.Component && innerPropertyBox.PropertyName == propertyBox.PropertyName);
                                    foreach (var overlappingProperty in overlappingProperties)
                                    {
                                        overlappingProperty.AddingProperty = true;
                                    }
                                }

                                USWindow.ShowPopupForProperties(animateButton, allPropertyBoxes, CommitModifications);
                            }
                        }
                    }
                }

                if (Event.current.type == EventType.Repaint)
                {
                    var newMaxHeight = GUILayoutUtility.GetLastRect().height;

                    if (MaxHeight != newMaxHeight)
                    {
                        EditorWindow.Repaint();
                        MaxHeight = newMaxHeight;
                    }
                }

                ContentOnGUI();
            }

            if (removingProperty != null)
            {
                RemoveProperty(removingProperty);
            }

            removingProperty = null;

            if (Event.current.commandName == "UndoRedoPerformed")
            {
                return;
            }

            if (CurveEditor.AreCurvesDirty)
            {
                PropertyTimeline.Process(PropertyTimeline.Sequence.RunningTime, PropertyTimeline.Sequence.PlaybackRate);
                CurveEditor.AreCurvesDirty = false;
            }
        }