Ejemplo n.º 1
0
        internal static string GetEditorTemplate(PropertyTypeInfo typeInfo, bool isForeignKey)
        {
            if (isForeignKey)
            {
                return typeInfo.IsCollection ?
                    Templates.Editor.DualList :
                    Templates.Editor.DropDownList;
            }
            if (typeInfo.SourceDataType != null)
            {
                switch (typeInfo.SourceDataType)
                {
                    case SystemDataType.DateTime:
                        return Templates.Editor.DateTime;
                    case SystemDataType.Date:
                        return Templates.Editor.Date;
                    case SystemDataType.Time:
                        return Templates.Editor.Time;
                    case SystemDataType.Url:
                    case SystemDataType.Upload:
                        return Templates.Editor.File;
                    case SystemDataType.ImageUrl:
                        return Templates.Editor.File;
                    case SystemDataType.Currency:
                        return Templates.Editor.Numeric;
                    case SystemDataType.Password:
                        return Templates.Editor.Password;
                    case SystemDataType.Html:
                        return Templates.Editor.Html;
                    case SystemDataType.MultilineText:
                        return Templates.Editor.TextArea;
                    case SystemDataType.PhoneNumber:
                    case SystemDataType.Text:
                    case SystemDataType.EmailAddress:
                    case SystemDataType.CreditCard:
                    case SystemDataType.PostalCode:
                        return Templates.Editor.TextBox;
                }
            }

            switch (typeInfo.DataType)
            {
                case DataType.Enum:
                    return Templates.Editor.DropDownList;
                case DataType.DateTime:
                    return Templates.Editor.DateTime;
                case DataType.Bool:
                    return Templates.Editor.Checkbox;
                case DataType.File:
                    return Templates.Editor.File;
                case DataType.Image:
                    return Templates.Editor.File;
                case DataType.Numeric:
                    return Templates.Editor.Numeric;
                default:
                    return Templates.Editor.TextBox;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name = "property"></param>
        protected override void SerializeSimpleProperty(PropertyTypeInfo<SimpleProperty> property)
        {
            if (property.Property.Value == null) return;

            writeStartProperty(Elements.SimpleObject, property.Name, property.ValueType);

            _writer.WriteAttribute(Attributes.Value, property.Property.Value);

            writeEndProperty();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// </summary>
        /// <param name = "property"></param>
        protected override void SerializeComplexProperty(PropertyTypeInfo<ComplexProperty> property)
        {
            WriteStartProperty(Elements.ComplexObject, property.Name, property.ValueType);

            // additional attribute with referenceId
            if (property.Property.Reference.Count > 1) {
                _writer.WriteAttribute(Attributes.ReferenceId, property.Property.Reference.Id);
            }

            // Properties
            WriteProperties(property.Property.Properties, property.Property.Type);

            WriteEndProperty();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// </summary>
        /// <param name = "property"></param>
        protected void SerializeCore(PropertyTypeInfo<Property> property)
        {
            if (property == null) throw new ArgumentNullException("property");

            var nullProperty = property.Property as NullProperty;
            if (nullProperty != null)
            {
                SerializeNullProperty(new PropertyTypeInfo<NullProperty>(nullProperty, property.ExpectedPropertyType,
                                                                         property.ValueType));
                return;
            }

            // check if the value type is equal to the property type.
            // if so, there is no need to explicit define the value type
            if (property.ExpectedPropertyType != null && property.ExpectedPropertyType == property.ValueType)
            {
                // Type is not required, because the property has the same value type as the expected property type
                property.ValueType = null;
            }

            var simpleProperty = property.Property as SimpleProperty;
            if (simpleProperty != null)
            {
                SerializeSimpleProperty(new PropertyTypeInfo<SimpleProperty>(simpleProperty,
                                                                             property.ExpectedPropertyType,
                                                                             property.ValueType));
                return;
            }

            var referenceTarget = property.Property as ReferenceTargetProperty;
            if (referenceTarget != null)
            {
                if (serializeReference(referenceTarget))
                    // Reference to object was serialized
                    return;

                // Full Serializing of the object
                if (serializeReferenceTarget(new PropertyTypeInfo<ReferenceTargetProperty>(referenceTarget,
                                                                                       property.ExpectedPropertyType,
                                                                                       property.ValueType)))
                {                    
                    return;
                }
            }

            throw new InvalidOperationException(string.Format("Unknown Property: {0}", property.Property.GetType()));            
        }
        public static int GetCurveCount(PropertyTypeInfo info)
        {

            if (info == PropertyTypeInfo.Int || info == PropertyTypeInfo.Long || info == PropertyTypeInfo.Float ||
                info == PropertyTypeInfo.Double)
            {
                return 1;
            }
            else if (info == PropertyTypeInfo.Vector2)
            {
                return 2;
            }
            else if (info == PropertyTypeInfo.Vector3)
            {
                return 3;
            }
            else if (info == PropertyTypeInfo.Vector4 || info == PropertyTypeInfo.Quaternion || info == PropertyTypeInfo.Color)
            {
                return 4;
            }
            return 0;
        }
        /// <summary>
        /// </summary>
        /// <param name = "property"></param>
        protected override void SerializeDictionaryProperty(PropertyTypeInfo<DictionaryProperty> property)
        {
            if (!writePropertyHeaderWithReferenceId(Elements.DictionaryWithId, property.Property.Reference, property.Name, property.ValueType))
            {
                // Property value is not referenced multiple times
                writePropertyHeader(Elements.Dictionary, property.Name, property.ValueType);
            } 

            // type of keys
            _writer.WriteType(property.Property.KeyType);

            // type of values
            _writer.WriteType(property.Property.ValueType);

            // Properties
            writeProperties(property.Property.Properties, property.Property.Type);

            // Items
            writeDictionaryItems(property.Property.Items, property.Property.KeyType, property.Property.ValueType);
        }
        /// <summary>
        /// </summary>
        /// <param name = "property"></param>
        protected override void SerializeMultiDimensionalArrayProperty(
            PropertyTypeInfo<MultiDimensionalArrayProperty> property)
        {
            if (!writePropertyHeaderWithReferenceId(Elements.MultiArrayWithId, property.Property.Reference, property.Name, property.ValueType))
            {
                // Property value is not referenced multiple times
                writePropertyHeader(Elements.MultiArray, property.Name, property.ValueType);
            } 

            // ElementType
            _writer.WriteType(property.Property.ElementType);

            // DimensionInfos
            writeDimensionInfos(property.Property.DimensionInfos);

            // Einträge
            writeMultiDimensionalArrayItems(property.Property.Items, property.Property.ElementType);
        }
 private PropertyInfo[] getValidProperties(Component component, PropertyTypeInfo propertyTypeInfo)
 {
     List<PropertyInfo> properties = new List<PropertyInfo>();
     foreach (PropertyInfo propertyInfo in component.GetType().GetProperties())
     {
         if (UnityPropertyTypeInfo.GetMappedType(propertyInfo.PropertyType) == propertyTypeInfo && propertyInfo.CanWrite)
         {
             properties.Add(propertyInfo);
         }
     }
     return properties.ToArray();
 }
Ejemplo n.º 9
0
        internal static string GetDisplayTemplate(PropertyTypeInfo typeInfo, bool isForeignKey)
        {
            if (isForeignKey)
            {
                return(Templates.Display.Text);
            }

            if (typeInfo.SourceDataType != null)
            {
                switch (typeInfo.SourceDataType)
                {
                case SystemDataType.DateTime:
                    return(Templates.Display.DateTime);

                case SystemDataType.Date:
                    return(Templates.Display.Date);

                case SystemDataType.Time:
                    return(Templates.Display.DateTime);

                case SystemDataType.Url:
                case SystemDataType.Upload:
                    return(Templates.Display.Url);

                case SystemDataType.ImageUrl:
                    return(Templates.Display.Image);

                case SystemDataType.Currency:
                    return(Templates.Display.Numeric);

                case SystemDataType.Password:
                    return(Templates.Display.Password);

                case SystemDataType.Html:
                    return(Templates.Display.Html);

                case SystemDataType.MultilineText:
                    return(Templates.Display.Text);

                case SystemDataType.PhoneNumber:
                case SystemDataType.Text:
                case SystemDataType.EmailAddress:
                case SystemDataType.CreditCard:
                case SystemDataType.PostalCode:
                    return(Templates.Display.Text);
                }
            }

            switch (typeInfo.DataType)
            {
            case DataType.Enum:
                return(Templates.Display.Text);

            case DataType.DateTime:
                return(Templates.Display.DateTime);

            case DataType.Bool:
                return(Templates.Display.Bool);

            case DataType.File:
                return(typeInfo.IsFileStoredInDb ?
                       Templates.Display.DbImage :
                       Templates.Display.File);

            case DataType.Image:
                return(typeInfo.IsFileStoredInDb ?
                       Templates.Display.DbImage :
                       Templates.Display.Image);

            case DataType.Numeric:
                return(Templates.Display.Numeric);

            default:
                return(Templates.Display.Text);
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected abstract void SerializeDictionaryProperty(PropertyTypeInfo<DictionaryProperty> property);
Ejemplo n.º 11
0
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected abstract void SerializeNullProperty(PropertyTypeInfo<NullProperty> property);
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected override void SerializeNullProperty(PropertyTypeInfo<NullProperty> property)
 {
     // nulls must be serialized also
     writeStartProperty(Elements.Null, property.Name, property.ValueType);
     writeEndProperty();
 }
        protected override bool initializeClipCurves(MemberClipCurveData data, Component component)
        {
            object           value     = GetCurrentValue(component, data.PropertyName, data.IsProperty);
            PropertyTypeInfo typeInfo  = data.PropertyType;
            float            startTime = Firetime;
            float            endTime   = Firetime + Duration;

            if (typeInfo == PropertyTypeInfo.Int || typeInfo == PropertyTypeInfo.Long || typeInfo == PropertyTypeInfo.Float || typeInfo == PropertyTypeInfo.Double)
            {
                float x;
                float.TryParse(value.ToString(), out x);

                if (float.IsInfinity(x) || float.IsNaN(x))
                {
                    return(false);
                }

                data.Curve1 = AnimationCurve.Linear(startTime, x, endTime, x);
            }
            else if (typeInfo == PropertyTypeInfo.Vector2)
            {
                Vector2 vec2 = (Vector2)value;

                if (float.IsInfinity(vec2.x) || float.IsNaN(vec2.x) ||
                    float.IsInfinity(vec2.y) || float.IsNaN(vec2.y))
                {
                    return(false);
                }

                data.Curve1 = AnimationCurve.Linear(startTime, vec2.x, endTime, vec2.x);
                data.Curve2 = AnimationCurve.Linear(startTime, vec2.y, endTime, vec2.y);
            }
            else if (typeInfo == PropertyTypeInfo.Vector3)
            {
                Vector3 vec3 = (Vector3)value;

                if (float.IsInfinity(vec3.x) || float.IsNaN(vec3.x) ||
                    float.IsInfinity(vec3.y) || float.IsNaN(vec3.y) ||
                    float.IsInfinity(vec3.z) || float.IsNaN(vec3.z))
                {
                    return(false);
                }

                data.Curve1 = AnimationCurve.Linear(startTime, vec3.x, endTime, vec3.x);
                data.Curve2 = AnimationCurve.Linear(startTime, vec3.y, endTime, vec3.y);
                data.Curve3 = AnimationCurve.Linear(startTime, vec3.z, endTime, vec3.z);
            }
            else if (typeInfo == PropertyTypeInfo.Vector4)
            {
                Vector4 vec4 = (Vector4)value;

                if (float.IsInfinity(vec4.x) || float.IsNaN(vec4.x) ||
                    float.IsInfinity(vec4.y) || float.IsNaN(vec4.y) ||
                    float.IsInfinity(vec4.z) || float.IsNaN(vec4.z) ||
                    float.IsInfinity(vec4.w) || float.IsNaN(vec4.w))
                {
                    return(false);
                }

                data.Curve1 = AnimationCurve.Linear(startTime, vec4.x, endTime, vec4.x);
                data.Curve2 = AnimationCurve.Linear(startTime, vec4.y, endTime, vec4.y);
                data.Curve3 = AnimationCurve.Linear(startTime, vec4.z, endTime, vec4.z);
                data.Curve4 = AnimationCurve.Linear(startTime, vec4.w, endTime, vec4.w);
            }
            else if (typeInfo == PropertyTypeInfo.Quaternion)
            {
                Quaternion quaternion = (Quaternion)value;

                if (float.IsInfinity(quaternion.x) || float.IsNaN(quaternion.x) ||
                    float.IsInfinity(quaternion.y) || float.IsNaN(quaternion.y) ||
                    float.IsInfinity(quaternion.z) || float.IsNaN(quaternion.z) ||
                    float.IsInfinity(quaternion.w) || float.IsNaN(quaternion.w))
                {
                    return(false);
                }

                data.Curve1 = AnimationCurve.Linear(startTime, quaternion.x, endTime, quaternion.x);
                data.Curve2 = AnimationCurve.Linear(startTime, quaternion.y, endTime, quaternion.y);
                data.Curve3 = AnimationCurve.Linear(startTime, quaternion.z, endTime, quaternion.z);
                data.Curve4 = AnimationCurve.Linear(startTime, quaternion.w, endTime, quaternion.w);
            }
            else if (typeInfo == PropertyTypeInfo.Color)
            {
                Color color = (Color)value;

                if (float.IsInfinity(color.r) || float.IsNaN(color.r) ||
                    float.IsInfinity(color.g) || float.IsNaN(color.g) ||
                    float.IsInfinity(color.b) || float.IsNaN(color.b) ||
                    float.IsInfinity(color.a) || float.IsNaN(color.a))
                {
                    return(false);
                }

                data.Curve1 = AnimationCurve.Linear(startTime, color.r, endTime, color.r);
                data.Curve2 = AnimationCurve.Linear(startTime, color.g, endTime, color.g);
                data.Curve3 = AnimationCurve.Linear(startTime, color.b, endTime, color.b);
                data.Curve4 = AnimationCurve.Linear(startTime, color.a, endTime, color.a);
            }

            return(true);
        }
Ejemplo n.º 14
0
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected override void SerializeNullProperty(PropertyTypeInfo <NullProperty> property)
 {
     // nulls must be serialized also
     writeStartProperty(Elements.Null, property.Name, property.ValueType);
     writeEndProperty();
 }
        public static string GetCurveName(PropertyTypeInfo info, int i)
        {
            string retVal = "x";
            if (i == 1)
            {
                retVal = "y";
            }
            else if (i == 2)
            {
                retVal = "z";
            }
            else if (i == 3)
            {
                retVal = "w";
            }


            if (info == PropertyTypeInfo.Int || info == PropertyTypeInfo.Long || info == PropertyTypeInfo.Float ||
                info == PropertyTypeInfo.Double)
            {
                retVal = "value";
            }
            else if (info == PropertyTypeInfo.Color)
            {
                if (i == 0)
                {
                    retVal = "r";
                }
                else if (i == 1)
                {
                    retVal = "g";
                }
                else if (i == 2)
                {
                    retVal = "b";
                }
                else if (i == 3)
                {
                    retVal = "a";
                }
            }

            return retVal;
        }
Ejemplo n.º 16
0
        public static object GetCurrentValue(Component component, string propertyName, bool isProperty, PropertyTypeInfo propertyTypeInfo = PropertyTypeInfo.None)
        {
            if (component == null || propertyName == string.Empty)
            {
                return(null);
            }
            Type type = component.GetType();

            if (isProperty)
            {
                PropertyInfo propertyInfo = ReflectionHelper.GetProperty(type, propertyName);
                return(propertyInfo.GetValue(component, null));
            }
            FieldInfo fieldInfo = ReflectionHelper.GetField(type, propertyName);

            if (fieldInfo == null && propertyTypeInfo == PropertyTypeInfo.FloatParameter)
            {
            }
            return(fieldInfo.GetValue(component));
        }
Ejemplo n.º 17
0
        public override void initializeClipCurves(MemberClipCurveData data, Component component, PropertyTypeInfo propertyTypeInfo = PropertyTypeInfo.None)
        {
            object           value     = GetCurrentValue(component, data.PropertyName, data.IsProperty, data.PropertyType);
            PropertyTypeInfo typeInfo  = data.PropertyType;
            float            startTime = Firetime;
            float            endTime   = Firetime + Duration;

            if (typeInfo == PropertyTypeInfo.Int || typeInfo == PropertyTypeInfo.Long || typeInfo == PropertyTypeInfo.Float || typeInfo == PropertyTypeInfo.Double)
            {
                float x = (float)value;
                data.Curve1 = AnimationCurve.Linear(startTime, x, endTime, x);
            }
            else if (typeInfo == PropertyTypeInfo.Vector2)
            {
                Vector2 vec2 = (Vector2)value;
                data.Curve1 = AnimationCurve.Linear(startTime, vec2.x, endTime, vec2.x);
                data.Curve2 = AnimationCurve.Linear(startTime, vec2.y, endTime, vec2.y);
            }
            else if (typeInfo == PropertyTypeInfo.Vector3)
            {
                Vector3 vec3 = (Vector3)value;
                data.Curve1 = AnimationCurve.Linear(startTime, vec3.x, endTime, vec3.x);
                data.Curve2 = AnimationCurve.Linear(startTime, vec3.y, endTime, vec3.y);
                data.Curve3 = AnimationCurve.Linear(startTime, vec3.z, endTime, vec3.z);
            }
            else if (typeInfo == PropertyTypeInfo.Vector4)
            {
                Vector4 vec4 = (Vector4)value;
                data.Curve1 = AnimationCurve.Linear(startTime, vec4.x, endTime, vec4.x);
                data.Curve2 = AnimationCurve.Linear(startTime, vec4.y, endTime, vec4.y);
                data.Curve3 = AnimationCurve.Linear(startTime, vec4.z, endTime, vec4.z);
                data.Curve4 = AnimationCurve.Linear(startTime, vec4.w, endTime, vec4.w);
            }
            else if (typeInfo == PropertyTypeInfo.Quaternion)
            {
                Quaternion quaternion = (Quaternion)value;
                data.Curve1 = AnimationCurve.Linear(startTime, quaternion.x, endTime, quaternion.x);
                data.Curve2 = AnimationCurve.Linear(startTime, quaternion.y, endTime, quaternion.y);
                data.Curve3 = AnimationCurve.Linear(startTime, quaternion.z, endTime, quaternion.z);
                data.Curve4 = AnimationCurve.Linear(startTime, quaternion.w, endTime, quaternion.w);
            }
            else if (typeInfo == PropertyTypeInfo.Color)
            {
                Color color = (Color)value;
                data.Curve1 = AnimationCurve.Linear(startTime, color.r, endTime, color.r);
                data.Curve2 = AnimationCurve.Linear(startTime, color.g, endTime, color.g);
                data.Curve3 = AnimationCurve.Linear(startTime, color.b, endTime, color.b);
                data.Curve4 = AnimationCurve.Linear(startTime, color.a, endTime, color.a);
            }
        }
Ejemplo n.º 18
0
        internal static string GetEditorTemplate(PropertyTypeInfo typeInfo, bool isForeignKey)
        {
            if (isForeignKey)
            {
                return(typeInfo.IsCollection ?
                       Templates.Editor.DualList :
                       Templates.Editor.DropDownList);
            }
            if (typeInfo.SourceDataType != null)
            {
                switch (typeInfo.SourceDataType)
                {
                case SystemDataType.DateTime:
                    return(Templates.Editor.DateTime);

                case SystemDataType.Date:
                    return(Templates.Editor.Date);

                case SystemDataType.Time:
                    return(Templates.Editor.Time);

                case SystemDataType.Url:
                case SystemDataType.Upload:
                    return(Templates.Editor.File);

                case SystemDataType.ImageUrl:
                    return(Templates.Editor.File);

                case SystemDataType.Currency:
                    return(Templates.Editor.Numeric);

                case SystemDataType.Password:
                    return(Templates.Editor.Password);

                case SystemDataType.Html:
                    return(Templates.Editor.Html);

                case SystemDataType.MultilineText:
                    return(Templates.Editor.TextArea);

                case SystemDataType.PhoneNumber:
                case SystemDataType.Text:
                case SystemDataType.EmailAddress:
                case SystemDataType.CreditCard:
                case SystemDataType.PostalCode:
                    return(Templates.Editor.TextBox);
                }
            }

            switch (typeInfo.DataType)
            {
            case DataType.Enum:
                return(Templates.Editor.DropDownList);

            case DataType.DateTime:
                return(Templates.Editor.DateTime);

            case DataType.Bool:
                return(Templates.Editor.Checkbox);

            case DataType.File:
                return(Templates.Editor.File);

            case DataType.Image:
                return(Templates.Editor.File);

            case DataType.Numeric:
                return(Templates.Editor.Numeric);

            default:
                return(Templates.Editor.TextBox);
            }
        }
        /// <summary>
        /// </summary>
        /// <param name = "property"></param>
        protected override void SerializeComplexProperty(PropertyTypeInfo<ComplexProperty> property)
        {
            if (!writePropertyHeaderWithReferenceId(Elements.ComplexObjectWithId, property.Property.Reference, property.Name, property.ValueType))
            {
                // Property value is not referenced multiple times
                writePropertyHeader(Elements.ComplexObject, property.Name, property.ValueType);                
            }            

            // Properties
            writeProperties(property.Property.Properties, property.Property.Type);
        }
Ejemplo n.º 20
0
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected abstract void SerializeSimpleProperty(PropertyTypeInfo <SimpleProperty> property);
Ejemplo n.º 21
0
        /// <summary>
        /// </summary>
        /// <param name = "property"></param>
        protected override void SerializeDictionaryProperty(PropertyTypeInfo<DictionaryProperty> property)
        {
            WriteStartProperty(Elements.Dictionary, property.Name, property.ValueType);

            // additional attribute with referenceId
            if (property.Property.Reference.Count > 1) {
                _writer.WriteAttribute(Attributes.ReferenceId, property.Property.Reference.Id);
            }

            // Properties
            WriteProperties(property.Property.Properties, property.Property.Type);

            // Items
            WriteDictionaryItems(property.Property.Items, property.Property.KeyType, property.Property.ValueType);

            WriteEndProperty();
        }
Ejemplo n.º 22
0
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected abstract void SerializeMultiDimensionalArrayProperty(
     PropertyTypeInfo <MultiDimensionalArrayProperty> property);
        /// <summary>
        /// </summary>
        /// <param name = "property"></param>
        protected override void SerializeCollectionProperty(PropertyTypeInfo<CollectionProperty> property)
        {
            writeStartProperty(Elements.Collection, property.Name, property.ValueType);

            // additional attribute with referenceId
            if (property.Property.Reference.Count > 1)
            {
                _writer.WriteAttribute(Attributes.ReferenceId, property.Property.Reference.Id);
            }

            // Properties
            writeProperties(property.Property.Properties, property.Property.Type);

            //Items
            writeItems(property.Property.Items, property.Property.ElementType);

            writeEndProperty();
        }
Ejemplo n.º 24
0
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected abstract void SerializeSingleDimensionalArrayProperty(
     PropertyTypeInfo <SingleDimensionalArrayProperty> property);
Ejemplo n.º 25
0
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected abstract void SerializeMultiDimensionalArrayProperty(
     PropertyTypeInfo<MultiDimensionalArrayProperty> property);
Ejemplo n.º 26
0
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected abstract void SerializeDictionaryProperty(PropertyTypeInfo <DictionaryProperty> property);
Ejemplo n.º 27
0
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected abstract void SerializeComplexProperty(PropertyTypeInfo<ComplexProperty> property);
Ejemplo n.º 28
0
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected abstract void SerializeCollectionProperty(PropertyTypeInfo <CollectionProperty> property);
Ejemplo n.º 29
0
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected abstract void SerializeNullProperty(PropertyTypeInfo <NullProperty> property);
Ejemplo n.º 30
0
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected abstract void SerializeComplexProperty(PropertyTypeInfo <ComplexProperty> property);
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected override void SerializeSimpleProperty(PropertyTypeInfo<SimpleProperty> property)
 {
     writePropertyHeader(Elements.SimpleObject, property.Name, property.ValueType);
     _writer.WriteValue(property.Property.Value);
 }
Ejemplo n.º 32
0
    /// <summary>
    /// Update and Draw the inspector
    /// </summary>
    public override void OnInspectorGUI()
    {
        clipCurve.Update();

        SerializedProperty curveData = clipCurve.FindProperty("curveData");

        if (curveData.arraySize > 0)
        {
            CinemaMultiActorCurveClip curveclip = target as CinemaMultiActorCurveClip;

            SerializedProperty member = curveData.GetArrayElementAtIndex(0);
            propertyType = member.FindPropertyRelative("PropertyType");

            PropertyTypeInfo current     = (PropertyTypeInfo)propertyType.enumValueIndex;
            PropertyTypeInfo newProperty = (PropertyTypeInfo)EditorGUILayout.EnumPopup(new GUIContent("Property Type"), current);

            if (current != newProperty)
            {
                propertyType.enumValueIndex = (int)newProperty;

                SerializedProperty curve1 = member.FindPropertyRelative("Curve1");
                SerializedProperty curve2 = member.FindPropertyRelative("Curve2");
                SerializedProperty curve3 = member.FindPropertyRelative("Curve3");
                SerializedProperty curve4 = member.FindPropertyRelative("Curve4");

                //SerializedProperty firetime = clipCurve.FindProperty("Firetime");
                //SerializedProperty duration = clipCurve.FindProperty("Duration");

                curve1.animationCurveValue = AnimationCurve.Linear(curveclip.Firetime, 0, curveclip.Duration, 0);
                curve2.animationCurveValue = AnimationCurve.Linear(curveclip.Firetime, 0, curveclip.Duration, 0);
                curve3.animationCurveValue = AnimationCurve.Linear(curveclip.Firetime, 0, curveclip.Duration, 0);
                curve4.animationCurveValue = AnimationCurve.Linear(curveclip.Firetime, 0, curveclip.Duration, 0);
            }

            componentsProperty.arraySize = actorCount;
            propertiesProperty.arraySize = actorCount;

            for (int i = 0; i < actorCount; i++)
            {
                Transform actor = curveclip.Actors[i];
                EditorGUILayout.LabelField(actor.name);
                EditorGUI.indentLevel++;
                List <GUIContent> componentSelectionList = new List <GUIContent>();
                List <GUIContent> propertySelectionList  = new List <GUIContent>();

                // Display component selection
                Component[] components = getValidComponents(actor.gameObject);
                foreach (Component component in components)
                {
                    componentSelectionList.Add(new GUIContent(component.GetType().Name));
                }
                componentSelection[i] = EditorGUILayout.Popup(new GUIContent("Component"), componentSelection[i], componentSelectionList.ToArray());

                componentsProperty.GetArrayElementAtIndex(i).objectReferenceValue = components[componentSelection[i]];

                // Display property selection
                PropertyInfo[] properties = getValidProperties(components[componentSelection[i]], (PropertyTypeInfo)propertyType.enumValueIndex);
                foreach (PropertyInfo propertyInfo in properties)
                {
                    propertySelectionList.Add(new GUIContent(propertyInfo.Name));
                }
                Color temp = GUI.color;
                if (propertySelectionList.Count < 1)
                {
                    propertySelectionList.Add(new GUIContent("None"));
                    GUI.color = Color.red;
                }
                propertySelection[i] = EditorGUILayout.Popup(new GUIContent("Property"), propertySelection[i], propertySelectionList.ToArray());

                if (propertySelection[i] > propertySelectionList.Count - 1)
                {
                    propertySelection[i] = 0;
                }
                string selectedProperty = propertySelectionList[propertySelection[i]].text;
                propertiesProperty.GetArrayElementAtIndex(i).stringValue = selectedProperty;
                GUI.color = temp;

                EditorGUI.indentLevel--;
            }
        }

        clipCurve.ApplyModifiedProperties();
    }
        /// <summary>
        /// </summary>
        /// <param name = "property"></param>
        protected override void SerializeSingleDimensionalArrayProperty(
            PropertyTypeInfo<SingleDimensionalArrayProperty> property)
        {
            if (!writePropertyHeaderWithReferenceId(Elements.SingleArrayWithId, property.Property.Reference, property.Name, property.ValueType))
            {
                // Property value is not referenced multiple times
                writePropertyHeader(Elements.SingleArray, property.Name, property.ValueType);
            } 

            // ElementType
            _writer.WriteType(property.Property.ElementType);

            // Lower Bound
            _writer.WriteNumber(property.Property.LowerBound);

            // items
            writeItems(property.Property.Items, property.Property.ElementType);
        }
Ejemplo n.º 34
0
        public static int GetCurveCount(int p)
        {
            PropertyTypeInfo info = (PropertyTypeInfo)p;

            return(GetCurveCount(info));
        }
        /// <summary>
        /// </summary>
        /// <param name = "property"></param>
        protected override void SerializeCollectionProperty(PropertyTypeInfo<CollectionProperty> property)
        {
            if (!writePropertyHeaderWithReferenceId(Elements.CollectionWithId, property.Property.Reference, property.Name, property.ValueType))
            {
                // Property value is not referenced multiple times
                writePropertyHeader(Elements.Collection, property.Name, property.ValueType);
            }  

            // ElementType
            _writer.WriteType(property.Property.ElementType);

            // Properties
            writeProperties(property.Property.Properties, property.Property.Type);

            //Items
            writeItems(property.Property.Items, property.Property.ElementType);
        }
Ejemplo n.º 36
0
    private void checkToAddNewKeyframes(CinemaActorClipCurve clipCurve, DirectorControlState state)
    {
        if (state.IsInPreviewMode && IsEditing &&
            clipCurve.Cutscene.State == Cutscene.CutsceneState.Paused && GUIUtility.hotControl == 0 &&
            (clipCurve.Firetime <= state.ScrubberPosition &&
             state.ScrubberPosition <= clipCurve.Firetime + clipCurve.Duration) && clipCurve.Actor != null)
        {
            Undo.RecordObject(clipCurve, "Auto Key Created");
            bool hasDifferenceBeenFound = false;
            for (int i = 0; i < clipCurve.CurveData.Count; i++)
            {
                MemberClipCurveData data = clipCurve.CurveData[i];
                if (data.Type == string.Empty || data.PropertyName == string.Empty)
                {
                    continue;
                }

                Component component = clipCurve.Actor.GetComponent(data.Type);
                object    value     = clipCurve.GetCurrentValue(component, data.PropertyName, data.IsProperty);

                PropertyTypeInfo typeInfo = data.PropertyType;

                if (typeInfo == PropertyTypeInfo.Int || typeInfo == PropertyTypeInfo.Long)
                {
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(Convert.ToInt32(value), curve1Value, data.Curve1, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Float || typeInfo == PropertyTypeInfo.Double)
                {
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(Convert.ToSingle(value), curve1Value, data.Curve1, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Vector2)
                {
                    Vector2 vec2        = (Vector2)value;
                    float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec2.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec2.y, curve2Value, data.Curve2, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Vector3)
                {
                    Vector3 vec3        = (Vector3)value;
                    float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float   curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.y, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.z, curve3Value, data.Curve3, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Vector4)
                {
                    Vector4 vec4        = (Vector4)value;
                    float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float   curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float   curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.y, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.z, curve3Value, data.Curve3, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.w, curve4Value, data.Curve4, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Quaternion)
                {
                    Quaternion quaternion  = (Quaternion)value;
                    float      curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float      curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float      curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float      curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    for (int j = 0; j < data.Curve1.length; j++)
                    {
                        Keyframe k = data.Curve1[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.x, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve1, j, newKeyframe);
                        }
                    }

                    for (int j = 0; j < data.Curve2.length; j++)
                    {
                        Keyframe k = data.Curve2[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.y, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve2, j, newKeyframe);
                        }
                    }

                    for (int j = 0; j < data.Curve3.length; j++)
                    {
                        Keyframe k = data.Curve3[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.z, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve3, j, newKeyframe);
                        }
                    }

                    for (int j = 0; j < data.Curve4.length; j++)
                    {
                        Keyframe k = data.Curve4[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.w, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve4, j, newKeyframe);
                        }
                    }

                    Quaternion curveValue = new Quaternion(curve1Value, curve2Value, curve3Value, curve4Value);
                    float      angle      = Vector3.Angle(quaternion.eulerAngles, curveValue.eulerAngles);
                    hasDifferenceBeenFound = hasDifferenceBeenFound || angle > QUATERNION_THRESHOLD;
                    if (angle > QUATERNION_THRESHOLD && hasUserInteracted)
                    {
                        data.Curve1.AddKey(state.ScrubberPosition, quaternion.x);
                        data.Curve2.AddKey(state.ScrubberPosition, quaternion.y);
                        data.Curve3.AddKey(state.ScrubberPosition, quaternion.z);
                        data.Curve4.AddKey(state.ScrubberPosition, quaternion.w);
                        hasUserInteracted = true;
                    }
                }
                else if (typeInfo == PropertyTypeInfo.Color)
                {
                    Color color       = (Color)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.r, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.g, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.b, curve3Value, data.Curve3, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.a, curve4Value, data.Curve4, state.ScrubberPosition);
                }
            }
            if (hasDifferenceBeenFound)
            {
                hasUserInteracted = true;
                EditorUtility.SetDirty(clipCurve);
            }
        }
    }
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected override void SerializeNullProperty(PropertyTypeInfo<NullProperty> property)
 {
     writePropertyHeader(Elements.Null, property.Name, property.ValueType);
 }
 /// <summary>
 /// </summary>
 /// <param name="property"></param>
 protected override void SerializeNullProperty(PropertyTypeInfo <NullProperty> property)
 {
     WritePropertyHeader(Elements.Null, property.Name, property.ValueType);
 }
        /// <summary>
        /// </summary>
        /// <param name = "property"></param>
        protected override void SerializeMultiDimensionalArrayProperty(
            PropertyTypeInfo<MultiDimensionalArrayProperty> property)
        {
            writeStartProperty(Elements.MultiArray, property.Name, property.ValueType);

            // additional attribute with referenceId
            if (property.Property.Reference.Count > 1)
            {
                _writer.WriteAttribute(Attributes.ReferenceId, property.Property.Reference.Id);
            }

            // DimensionInfos
            writeDimensionInfos(property.Property.DimensionInfos);

            // Einträge
            writeMultiDimensionalArrayItems(property.Property.Items, property.Property.ElementType);

            writeEndProperty();
        }
 /// <summary>
 /// </summary>
 /// <param name="property"></param>
 protected override void SerializeSimpleProperty(PropertyTypeInfo <SimpleProperty> property)
 {
     WritePropertyHeader(Elements.SimpleObject, property.Name, property.ValueType);
     _writer.WriteValue(property.Property.Value);
 }
        /// <summary>
        /// </summary>
        /// <param name = "property"></param>
        protected override void SerializeSingleDimensionalArrayProperty(
            PropertyTypeInfo<SingleDimensionalArrayProperty> property)
        {
            writeStartProperty(Elements.SingleArray, property.Name, property.ValueType);

            // additional attribute with referenceId
            if (property.Property.Reference.Count > 1)
            {
                _writer.WriteAttribute(Attributes.ReferenceId, property.Property.Reference.Id);
            }

            // LowerBound
            if (property.Property.LowerBound != 0)
            {
                _writer.WriteAttribute(Attributes.LowerBound, property.Property.LowerBound);
            }

            // items
            writeItems(property.Property.Items, property.Property.ElementType);

            writeEndProperty();
        }
Ejemplo n.º 42
0
 public virtual void initializeClipCurves(MemberClipCurveData data, Component component, PropertyTypeInfo propertyTypeInfo = PropertyTypeInfo.None)
 {
 }
Ejemplo n.º 43
0
        private bool serializeReferenceTarget(PropertyTypeInfo<ReferenceTargetProperty> property)
        {
            var multiDimensionalArrayProperty = property.Property as MultiDimensionalArrayProperty;
            if (multiDimensionalArrayProperty != null)
            {
                multiDimensionalArrayProperty.Reference.IsProcessed = true;
                SerializeMultiDimensionalArrayProperty(
                    new PropertyTypeInfo<MultiDimensionalArrayProperty>(multiDimensionalArrayProperty,
                                                                        property.ExpectedPropertyType,
                                                                        property.ValueType));
                return true;
            }

            var singleDimensionalArrayProperty = property.Property as SingleDimensionalArrayProperty;
            if (singleDimensionalArrayProperty != null)
            {
                singleDimensionalArrayProperty.Reference.IsProcessed = true;
                SerializeSingleDimensionalArrayProperty(
                    new PropertyTypeInfo<SingleDimensionalArrayProperty>(singleDimensionalArrayProperty,
                                                                         property.ExpectedPropertyType,
                                                                         property.ValueType));
                return true;
            }

            var dictionaryProperty = property.Property as DictionaryProperty;
            if (dictionaryProperty != null)
            {
                dictionaryProperty.Reference.IsProcessed = true;
                SerializeDictionaryProperty(new PropertyTypeInfo<DictionaryProperty>(dictionaryProperty,
                                                                                     property.ExpectedPropertyType,
                                                                                     property.ValueType));
                return true;
            }

            var collectionProperty = property.Property as CollectionProperty;
            if (collectionProperty != null)
            {
                collectionProperty.Reference.IsProcessed = true;
                SerializeCollectionProperty(new PropertyTypeInfo<CollectionProperty>(collectionProperty,
                                                                                     property.ExpectedPropertyType,
                                                                                     property.ValueType));
                return true;
            }

            var complexProperty = property.Property as ComplexProperty;
            if (complexProperty != null)
            {
                complexProperty.Reference.IsProcessed = true;
                SerializeComplexProperty(new PropertyTypeInfo<ComplexProperty>(complexProperty,
                                                                               property.ExpectedPropertyType,
                                                                               property.ValueType));
                return true;
            }

            return false;
        }
Ejemplo n.º 44
0
        internal static string GetDisplayTemplate(PropertyTypeInfo typeInfo, bool isForeignKey)
        {
            if (isForeignKey)
            {
                return Templates.Display.Text;
            }

            if (typeInfo.SourceDataType != null)
            {
                switch (typeInfo.SourceDataType)
                {
                    case SystemDataType.DateTime:
                        return Templates.Display.DateTime;
                    case SystemDataType.Date:
                        return Templates.Display.Date;
                    case SystemDataType.Time:
                        return Templates.Display.DateTime;
                    case SystemDataType.Url:
                    case SystemDataType.Upload:
                        return Templates.Display.Url;
                    case SystemDataType.ImageUrl:
                        return Templates.Display.Image;
                    case SystemDataType.Currency:
                        return Templates.Display.Numeric;
                    case SystemDataType.Password:
                        return Templates.Display.Password;
                    case SystemDataType.Html:
                        return Templates.Display.Html;
                    case SystemDataType.MultilineText:
                        return Templates.Display.Text;
                    case SystemDataType.PhoneNumber:
                    case SystemDataType.Text:
                    case SystemDataType.EmailAddress:
                    case SystemDataType.CreditCard:
                    case SystemDataType.PostalCode:
                        return Templates.Display.Text;
                }
            }

            switch (typeInfo.DataType)
            {
                case DataType.Enum:
                    return Templates.Display.Text;
                case DataType.DateTime:
                    return Templates.Display.DateTime;
                case DataType.Bool:
                    return Templates.Display.Bool;
                case DataType.File:
                    return typeInfo.IsFileStoredInDb ?
                        Templates.Display.DbImage :
                        Templates.Display.File;
                case DataType.Image:
                    return typeInfo.IsFileStoredInDb ?
                        Templates.Display.DbImage :
                        Templates.Display.Image;
                case DataType.Numeric:
                    return Templates.Display.Numeric;
                default:
                    return Templates.Display.Text;
            }
        }
Ejemplo n.º 45
0
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected abstract void SerializeSimpleProperty(PropertyTypeInfo<SimpleProperty> property);
Ejemplo n.º 46
0
        protected override void SerializeSingleDimensionalArrayProperty(PropertyTypeInfo<SingleDimensionalArrayProperty> property)
        {
            writeStartProperty(Elements.SingleArray, property.Name, property.ValueType);

            // ElementType
            writeElementType(property.Property.ElementType);

            // LowerBound
            if (property.Property.LowerBound != 0)
            {
                _writer.WriteAttributeString(Attributes.LowerBound, property.Property.LowerBound.ToString());
            }

            // items
            writeItems(property.Property.Items, property.Property.ElementType);

            writeEndProperty();
        }
Ejemplo n.º 47
0
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected abstract void SerializeSingleDimensionalArrayProperty(
     PropertyTypeInfo<SingleDimensionalArrayProperty> property);
    private void checkToAddNewKeyframes(CinemaActorClipCurve clipCurve, DirectorControlState state)
    {
        if (state.IsInPreviewMode && IsEditing && GUIUtility.hotControl == 0 && (clipCurve.Firetime <= state.ScrubberPosition && state.ScrubberPosition <= clipCurve.Firetime + clipCurve.Duration))
        {
            bool hasDifferenceBeenFound = false;
            foreach (MemberClipCurveData data in clipCurve.CurveData)
            {
                if (data.Type == string.Empty || data.PropertyName == string.Empty)
                {
                    continue;
                }

                Component component = clipCurve.Actor.GetComponent(data.Type);
                object    value     = clipCurve.GetCurrentValue(component, data.PropertyName, data.IsProperty);


                PropertyTypeInfo typeInfo = data.PropertyType;
                if (typeInfo == PropertyTypeInfo.Int || typeInfo == PropertyTypeInfo.Long || typeInfo == PropertyTypeInfo.Float ||
                    typeInfo == PropertyTypeInfo.Double)
                {
                    float x           = (float)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(x, curve1Value, data.Curve1, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Vector2)
                {
                    Vector2 vec2        = (Vector2)value;
                    float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec2.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec2.y, curve2Value, data.Curve2, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Vector3)
                {
                    Vector3 vec3        = (Vector3)value;
                    float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float   curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.y, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.z, curve3Value, data.Curve3, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Vector4)
                {
                    Vector4 vec4        = (Vector4)value;
                    float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float   curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float   curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.y, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.z, curve3Value, data.Curve3, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.w, curve4Value, data.Curve4, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Quaternion)
                {
                    Quaternion quaternion  = (Quaternion)value;
                    float      curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float      curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float      curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float      curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    for (int j = 0; j < data.Curve1.length; j++)
                    {
                        Keyframe k = data.Curve1[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            data.Curve1.MoveKey(j, new Keyframe(k.time, quaternion.x, k.inTangent, k.outTangent));
                        }
                    }

                    for (int j = 0; j < data.Curve2.length; j++)
                    {
                        Keyframe k = data.Curve2[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            data.Curve2.MoveKey(j, new Keyframe(k.time, quaternion.y, k.inTangent, k.outTangent));
                        }
                    }

                    for (int j = 0; j < data.Curve3.length; j++)
                    {
                        Keyframe k = data.Curve3[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            data.Curve3.MoveKey(j, new Keyframe(k.time, quaternion.z, k.inTangent, k.outTangent));
                        }
                    }

                    for (int j = 0; j < data.Curve4.length; j++)
                    {
                        Keyframe k = data.Curve4[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            data.Curve4.MoveKey(j, new Keyframe(k.time, quaternion.w, k.inTangent, k.outTangent));
                        }
                    }

                    Quaternion curveValue = new Quaternion(curve1Value, curve2Value, curve3Value, curve4Value);
                    float      angle      = Vector3.Angle(quaternion.eulerAngles, curveValue.eulerAngles);
                    hasDifferenceBeenFound = hasDifferenceBeenFound || angle > QUATERNION_THRESHOLD;
                    if (angle > QUATERNION_THRESHOLD && hasUserInteracted)
                    {
                        data.Curve1.AddKey(state.ScrubberPosition, quaternion.x);
                        data.Curve2.AddKey(state.ScrubberPosition, quaternion.y);
                        data.Curve3.AddKey(state.ScrubberPosition, quaternion.z);
                        data.Curve4.AddKey(state.ScrubberPosition, quaternion.w);
                        hasUserInteracted = true;
                    }
                }
                else if (typeInfo == PropertyTypeInfo.Color)
                {
                    Color color       = (Color)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.r, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.g, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.b, curve3Value, data.Curve3, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.a, curve4Value, data.Curve4, state.ScrubberPosition);
                }
            }
            if (hasDifferenceBeenFound)
            {
                hasUserInteracted = true;
            }
        }
    }
Ejemplo n.º 49
0
 /// <summary>
 /// </summary>
 /// <param name = "property"></param>
 protected abstract void SerializeCollectionProperty(PropertyTypeInfo<CollectionProperty> property);
Ejemplo n.º 50
0
        private bool serializeReferenceTarget(PropertyTypeInfo <ReferenceTargetProperty> property)
        {
            var multiDimensionalArrayProperty = property.Property as MultiDimensionalArrayProperty;

            if (multiDimensionalArrayProperty != null)
            {
                multiDimensionalArrayProperty.Reference.IsProcessed = true;
                SerializeMultiDimensionalArrayProperty(
                    new PropertyTypeInfo <MultiDimensionalArrayProperty>(multiDimensionalArrayProperty,
                                                                         property.ExpectedPropertyType,
                                                                         property.ValueType));
                return(true);
            }

            var singleDimensionalArrayProperty = property.Property as SingleDimensionalArrayProperty;

            if (singleDimensionalArrayProperty != null)
            {
                singleDimensionalArrayProperty.Reference.IsProcessed = true;
                SerializeSingleDimensionalArrayProperty(
                    new PropertyTypeInfo <SingleDimensionalArrayProperty>(singleDimensionalArrayProperty,
                                                                          property.ExpectedPropertyType,
                                                                          property.ValueType));
                return(true);
            }

            var dictionaryProperty = property.Property as DictionaryProperty;

            if (dictionaryProperty != null)
            {
                dictionaryProperty.Reference.IsProcessed = true;
                SerializeDictionaryProperty(new PropertyTypeInfo <DictionaryProperty>(dictionaryProperty,
                                                                                      property.ExpectedPropertyType,
                                                                                      property.ValueType));
                return(true);
            }

            var collectionProperty = property.Property as CollectionProperty;

            if (collectionProperty != null)
            {
                collectionProperty.Reference.IsProcessed = true;
                SerializeCollectionProperty(new PropertyTypeInfo <CollectionProperty>(collectionProperty,
                                                                                      property.ExpectedPropertyType,
                                                                                      property.ValueType));
                return(true);
            }

            var complexProperty = property.Property as ComplexProperty;

            if (complexProperty != null)
            {
                complexProperty.Reference.IsProcessed = true;
                SerializeComplexProperty(new PropertyTypeInfo <ComplexProperty>(complexProperty,
                                                                                property.ExpectedPropertyType,
                                                                                property.ValueType));
                return(true);
            }

            return(false);
        }
Ejemplo n.º 51
0
        protected override void SerializeSimpleProperty(PropertyTypeInfo<SimpleProperty> property)
        {
            if (property.Property.Value == null) return;
            writeStartProperty(Elements.SimpleObject, property.Name, property.ValueType);

            var converter = getSimpleValueConverter();
            var value = converter.ConvertToString(property.Property.Value);

            _writer.WriteAttributeString(Attributes.Value, value);

            writeEndProperty();
        }
Ejemplo n.º 52
0
    private void checkToAddNewKeyframes(CinemaActorClipCurve clipCurve, DirectorControlState state)
    {
        if (state.IsInPreviewMode && IsEditing &&
            clipCurve.Cutscene.State == Cutscene.CutsceneState.Paused && GUIUtility.hotControl == 0 &&
            (clipCurve.Firetime <= state.ScrubberPosition &&
             state.ScrubberPosition <= clipCurve.Firetime + clipCurve.Duration) && clipCurve.Actor != null)
        {
            Undo.RecordObject(clipCurve, "Auto Key Created");
            bool hasDifferenceBeenFound = false;
            for (int i = 0; i < clipCurve.CurveData.Count; i++)
            {
                MemberClipCurveData data = clipCurve.CurveData[i];
                if (data.Type == string.Empty || data.PropertyName == string.Empty)
                {
                    continue;
                }

                Component component = clipCurve.Actor.GetComponent(data.Type);
                object    value     = null;

                //Specific hard-coded fix for the Rotation Curve Issue.
                currentlyEditingRotation = data.PropertyName == "localEulerAngles";
#if UNITY_2017_2_OR_NEWER
                if (component != null)
                {
                    Type type = component.GetType();
                    if (data.IsProperty)
                    {
                        // Deal with a special case, use the new TransformUtils to get the rotation value from the editor field.
                        if (type == typeof(Transform) && data.PropertyName == "localEulerAngles")
                        {
                            value = UnityEditor.TransformUtils.GetInspectorRotation(component.transform); // TransformUtils added in 2017.2
                        }
                        else
                        {
                            value = clipCurve.GetCurrentValue(component, data.PropertyName, data.IsProperty);
                        }
                    }
                }
#else
                value = clipCurve.GetCurrentValue(component, data.PropertyName, data.IsProperty);
#endif

                PropertyTypeInfo typeInfo = data.PropertyType;

                if (typeInfo == PropertyTypeInfo.Int || typeInfo == PropertyTypeInfo.Long)
                {
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(Convert.ToInt32(value), curve1Value, data.Curve1, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Float || typeInfo == PropertyTypeInfo.Double)
                {
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(Convert.ToSingle(value), curve1Value, data.Curve1, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Vector2)
                {
                    Vector2 vec2        = (Vector2)value;
                    float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec2.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec2.y, curve2Value, data.Curve2, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Vector3)
                {
                    //Special check for rotations
                    if (!currentlyEditingRotation || (currentlyEditingRotation && clipCurve.Actor.transform.hasChanged))
                    {
                        Vector3 vec3        = (Vector3)value;
                        float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                        float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                        float   curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);

                        hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.x, curve1Value, data.Curve1, state.ScrubberPosition);
                        hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.y, curve2Value, data.Curve2, state.ScrubberPosition);
                        hasDifferenceBeenFound |= addKeyOnUserInteraction(vec3.z, curve3Value, data.Curve3, state.ScrubberPosition);
                    }
                }
                else if (typeInfo == PropertyTypeInfo.Vector4)
                {
                    Vector4 vec4        = (Vector4)value;
                    float   curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float   curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float   curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float   curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.x, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.y, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.z, curve3Value, data.Curve3, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(vec4.w, curve4Value, data.Curve4, state.ScrubberPosition);
                }
                else if (typeInfo == PropertyTypeInfo.Quaternion)
                {
                    Quaternion quaternion  = (Quaternion)value;
                    float      curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float      curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float      curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float      curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    for (int j = 0; j < data.Curve1.length; j++)
                    {
                        Keyframe k = data.Curve1[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.x, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve1, j, newKeyframe);
                        }
                    }

                    for (int j = 0; j < data.Curve2.length; j++)
                    {
                        Keyframe k = data.Curve2[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.y, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve2, j, newKeyframe);
                        }
                    }

                    for (int j = 0; j < data.Curve3.length; j++)
                    {
                        Keyframe k = data.Curve3[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.z, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve3, j, newKeyframe);
                        }
                    }

                    for (int j = 0; j < data.Curve4.length; j++)
                    {
                        Keyframe k = data.Curve4[j];
                        if (k.time == state.ScrubberPosition)
                        {
                            Keyframe newKeyframe = new Keyframe(k.time, quaternion.w, k.inTangent, k.outTangent);
                            newKeyframe.tangentMode = k.tangentMode;
                            AnimationCurveHelper.MoveKey(data.Curve4, j, newKeyframe);
                        }
                    }

                    Quaternion curveValue = new Quaternion(curve1Value, curve2Value, curve3Value, curve4Value);
                    float      angle      = Vector3.Angle(quaternion.eulerAngles, curveValue.eulerAngles);
                    hasDifferenceBeenFound = hasDifferenceBeenFound || angle > QUATERNION_THRESHOLD;
                    if (angle > QUATERNION_THRESHOLD && hasUserInteracted)
                    {
                        data.Curve1.AddKey(state.ScrubberPosition, quaternion.x);
                        data.Curve2.AddKey(state.ScrubberPosition, quaternion.y);
                        data.Curve3.AddKey(state.ScrubberPosition, quaternion.z);
                        data.Curve4.AddKey(state.ScrubberPosition, quaternion.w);
                        hasUserInteracted = true;
                    }
                }
                else if (typeInfo == PropertyTypeInfo.Color)
                {
                    Color color       = (Color)value;
                    float curve1Value = data.Curve1.Evaluate(state.ScrubberPosition);
                    float curve2Value = data.Curve2.Evaluate(state.ScrubberPosition);
                    float curve3Value = data.Curve3.Evaluate(state.ScrubberPosition);
                    float curve4Value = data.Curve4.Evaluate(state.ScrubberPosition);

                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.r, curve1Value, data.Curve1, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.g, curve2Value, data.Curve2, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.b, curve3Value, data.Curve3, state.ScrubberPosition);
                    hasDifferenceBeenFound |= addKeyOnUserInteraction(color.a, curve4Value, data.Curve4, state.ScrubberPosition);
                }
            }
            if (hasDifferenceBeenFound)
            {
                hasUserInteracted = true;
                EditorUtility.SetDirty(clipCurve);
            }
        }
    }