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