예제 #1
0
        private void UpdateValue(string value, bool raiseValueChangedEvent)
        {
            if (m_item != null && !m_item.ComponentIsNull)
            {
                Type type = m_item.Value.GetType();

                object result;
                if (Reflection.TryConvert(value, type, out result))
                {
                    m_item.SetValue(result, raiseValueChangedEvent);
                }
            }
        }
예제 #2
0
        public void SetValue(object value, bool raiseValueChangedEvent)
        {
            object oldValue = Value;

            if (Parent != null)
            {
                object v = Parent.Value;
                SetMemberValue(v, PropertyName, value);
                Parent.SetValue(v, raiseValueChangedEvent);
            }
            else
            {
                SetMemberValue(Component, PropertyName, value);
            }

            if (ValueChanged != null && raiseValueChangedEvent)
            {
                object newValue = Value;
                if (oldValue != null || newValue != null)
                {
                    if (oldValue == null || newValue == null)
                    {
                        ValueChanged(this, oldValue, newValue);
                    }
                    else
                    {
                        if (!oldValue.Equals(newValue))
                        {
                            ValueChanged(this, oldValue, newValue);
                        }
                    }
                }
            }
        }
예제 #3
0
        public bool TryToCreateChildren()
        {
            if (ComponentTypeName == k_SpecialEmptySpace || ComponentTypeName == k_SpecialAddButton)
            {
                return(false);
            }

            Type type = Value.GetType();

            if (Reflection.IsPrimitive(type))
            {
                return(false);
            }

            if (!Reflection.IsValueType(type))
            {
                return(false);
            }

            List <RuntimeAnimationProperty> children = new List <RuntimeAnimationProperty>();

            FieldInfo[] fields = type.GetSerializableFields();
            for (int i = 0; i < fields.Length; ++i)
            {
                FieldInfo field = fields[i];
                if (!Reflection.IsPrimitive(field.FieldType))
                {
                    continue;
                }

                RuntimeAnimationProperty child = new RuntimeAnimationProperty
                {
                    PropertyName          = field.Name,
                    AnimationPropertyName = field.Name,
                    PropertyDisplayName   = field.Name,
                    ComponentTypeName     = ComponentTypeName,
                    Parent    = this,
                    Component = Component,
                    Curve     = new AnimationCurve(),
                };
                child.SetValue(GetMemberValue(Value, field.Name), false);
                children.Add(child);
            }

            PropertyInfo[] properties = type.GetSerializableProperties();
            for (int i = 0; i < properties.Length; ++i)
            {
                PropertyInfo property = properties[i];
                if (!Reflection.IsPrimitive(property.PropertyType))
                {
                    continue;
                }

                RuntimeAnimationProperty child = new RuntimeAnimationProperty
                {
                    PropertyName          = property.Name,
                    AnimationPropertyName = property.Name,
                    PropertyDisplayName   = property.Name,
                    ComponentTypeName     = ComponentTypeName,
                    Parent    = this,
                    Component = Component,
                    Curve     = new AnimationCurve(),
                };
                child.SetValue(GetMemberValue(Value, property.Name), false);
                children.Add(child);
            }

            Children = children;
            return(true);
        }