public bool IsPropertyUsingCurrentValue() { var preFix = PropertyFieldInfo.Name; var propertyInfo = PropertyTimeline.GetProperty(preFix, PropertyFieldInfo.Component); return(propertyInfo.curves.Any(curve => curve.UseCurrentValue)); }
private void RemoveProperty() { USUndoManager.RegisterCompleteObjectUndo(PropertyTimeline, "Remove Curve"); USUndoManager.RegisterCompleteObjectUndo(this, "Remove Curve"); foreach (var child in Children) { USUndoManager.RegisterCompleteObjectUndo(child, "Remove Curve"); } var preFix = PropertyFieldInfo.Name; var propertyInfo = PropertyTimeline.GetProperty(preFix, PropertyFieldInfo.Component); foreach (var child in Children) { ((USPropertyMemberHierarchyItem)child).Curve = null; } propertyInfo.RestoreBaseState(); PropertyTimeline.RemoveProperty(propertyInfo); USUndoManager.DestroyImmediate(propertyInfo); IsSelected = false; foreach (var child in Children) { ((USPropertyMemberHierarchyItem)child).IsSelected = false; } }
public void ToggleUseCurrentValue() { var preFix = PropertyFieldInfo.Name; var propertyInfo = PropertyTimeline.GetProperty(preFix, PropertyFieldInfo.Component); foreach (var curve in propertyInfo.curves) { curve.UseCurrentValue = !curve.UseCurrentValue; } }
public override void Initialize(USTimelineBase timeline) { var numberOfChildren = Children.Count; if (PropertyFieldInfo.Property != null) { numberOfChildren = USPropertyMemberUtility.GetNumberOfMembers(PropertyFieldInfo.Property.PropertyType); } else if (PropertyFieldInfo.Field != null) { numberOfChildren = USPropertyMemberUtility.GetNumberOfMembers(PropertyFieldInfo.Field.FieldType); } if (numberOfChildren != Children.Count) { Children.Clear(); for (var index = 0; index < numberOfChildren; index++) { var postFix = ""; if (PropertyFieldInfo.Property != null) { postFix = USPropertyMemberUtility.GetAdditionalMemberName(PropertyFieldInfo.Property.PropertyType, index); } else if (PropertyFieldInfo.Field != null) { postFix = USPropertyMemberUtility.GetAdditionalMemberName(PropertyFieldInfo.Field.FieldType, index); } var preFix = PropertyFieldInfo.Name; var propertyMemberItem = CreateInstance <USPropertyMemberHierarchyItem>(); propertyMemberItem.PostFix = postFix; propertyMemberItem.Prefix = preFix; propertyMemberItem.CurveIndex = index; propertyMemberItem.Initialize(PropertyTimeline); var propertyInfo = PropertyTimeline.GetProperty(preFix, PropertyFieldInfo.Component); if (propertyInfo != null) { propertyMemberItem.Curve = propertyInfo.curves[index]; propertyInfo.InternalName = MappedType; } Children.Add(propertyMemberItem as IUSHierarchyItem); } } }
private void AddProperty() { var usPropertyInfo = CreateInstance <USPropertyInfo>(); USUndoManager.RegisterCreatedObjectUndo(usPropertyInfo, "Add Curve"); USUndoManager.PropertyChange(PropertyTimeline, "Add Curve"); USUndoManager.PropertyChange(this, "Add Curve"); foreach (var child in Children) { USUndoManager.PropertyChange(child, "Add Curve"); } object propertyValue = null; usPropertyInfo.Component = PropertyFieldInfo.Component; if (PropertyFieldInfo.Property != null) { usPropertyInfo.propertyInfo = PropertyFieldInfo.Property; propertyValue = PropertyFieldInfo.Property.GetValue(PropertyFieldInfo.Component, null); } else if (PropertyFieldInfo.Field != null) { usPropertyInfo.fieldInfo = PropertyFieldInfo.Field; propertyValue = PropertyFieldInfo.Field.GetValue(PropertyFieldInfo.Component); } usPropertyInfo.InternalName = 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); for (var curveIndex = 0; curveIndex < usPropertyInfo.curves.Count; curveIndex++) { ((USPropertyMemberHierarchyItem)Children[curveIndex]).Curve = usPropertyInfo.curves[curveIndex]; } usPropertyInfo.StoreBaseState(); IsSelected = true; foreach (var child in Children) { ((USPropertyMemberHierarchyItem)child).IsSelected = true; } }
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); }
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 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; } }