예제 #1
0
        public override void OnEnable()
        {
            base.OnEnable();

            removingProperty = null;
            if (CurveEditor == null)
            {
                CurveEditor = CreateInstance <AnimationCurveEditor>();
            }

            if (propertyBoxes == null)
            {
                propertyBoxes = new List <PropertyBox>();
            }

            Undo.undoRedoPerformed        -= CreatePropertyBoxes;
            Undo.undoRedoPerformed        += CreatePropertyBoxes;
            Undo.postprocessModifications -= PostProcess;
            Undo.postprocessModifications += PostProcess;

            if (ISelectableContainers == null)
            {
                ISelectableContainers = new List <ISelectableContainer>();
                ISelectableContainers.Add(CurveEditor);
            }
        }
예제 #2
0
        private void RemoveProperty(PropertyBox propertyBox)
        {
            Debug.Log("Removing Property " + propertyBox);
            USUndoManager.RegisterCompleteObjectUndo(PropertyTimeline, "Remove Curve");
            USUndoManager.RegisterCompleteObjectUndo(this, "Remove Curve");
            USUndoManager.PropertyChange(CurveEditor, "Add Curve");

            propertyBoxes.Remove(propertyBox);

            var preFix       = propertyBox.PropertyName;
            var propertyInfo = PropertyTimeline.GetProperty(preFix, propertyBox.Component);

            propertyInfo.curves.ForEach(curve => CurveEditor.Curves.Remove(curve));

            propertyInfo.RestoreBaseState();
            PropertyTimeline.RemoveProperty(propertyInfo);
            USUndoManager.DestroyImmediate(propertyInfo);
        }
예제 #3
0
        private void AddProperty(PropertyBox propertyBox)
        {
            Debug.Log("Adding Property " + propertyBox);

            var usPropertyInfo = CreateInstance <USPropertyInfo>();

            USUndoManager.RegisterCreatedObjectUndo(usPropertyInfo, "Add Curve");
            USUndoManager.RegisterCompleteObjectUndo(PropertyTimeline, "Add Curve");
            USUndoManager.RegisterCompleteObjectUndo(this, "Add Curve");
            USUndoManager.RegisterCompleteObjectUndo(CurveEditor, "Add Curve");

            object propertyValue = null;

            usPropertyInfo.Component = propertyBox.PropertyFieldInfo.Component;

            if (propertyBox.PropertyFieldInfo.Property != null)
            {
                usPropertyInfo.propertyInfo = propertyBox.PropertyFieldInfo.Property;
                propertyValue = propertyBox.PropertyFieldInfo.Property.GetValue(propertyBox.PropertyFieldInfo.Component, null);
            }
            else if (propertyBox.PropertyFieldInfo.Field != null)
            {
                usPropertyInfo.fieldInfo = propertyBox.PropertyFieldInfo.Field;
                propertyValue            = propertyBox.PropertyFieldInfo.Field.GetValue(propertyBox.PropertyFieldInfo.Component);
            }

            usPropertyInfo.InternalName = propertyBox.PropertyFieldInfo.MappedType;
            usPropertyInfo.CreatePropertyInfo(USPropertyInfo.GetMappedType(propertyValue.GetType()));
            usPropertyInfo.AddKeyframe(propertyValue, 0.0f, CurveAutoTangentModes.None);
            usPropertyInfo.AddKeyframe(propertyValue, PropertyTimeline.Sequence.Duration, CurveAutoTangentModes.None);
            PropertyTimeline.AddProperty(usPropertyInfo);

            usPropertyInfo.StoreBaseState();

            var newCurves = CurveEditor.Curves;

            newCurves.AddRange(usPropertyInfo.curves);
            CurveEditor.Curves = newCurves;

            propertyBox.ShouldShowFavouriteButton = false;
            propertyBox.ShouldShowAddRemove       = false;
            propertyBoxes.Add(propertyBox);
        }
 public PropertyHierarchyItem(PropertyBox propertyBox)
 {
     this.propertyBox = propertyBox;
 }
 public FavouriteHierarchyItem(PropertyBox propertyBox)
 {
     this.propertyBox = propertyBox;
 }
 public SuggestionHierarchyItem(PropertyBox propertyBox)
 {
     this.propertyBox = propertyBox;
 }
예제 #7
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;
            }
        }
 public PropertyBoxHierarchyItem(PropertyBox property)
 {
     this.property = property;
 }