public static object OnConvertFromXmlNode(object obj, XmlNode node)
                {
                    if (node == null)
                    {
                        return(obj);
                    }

                    AnimationCurve curve = new AnimationCurve();

                    XmlNode keyframesXmlNode = XmlUtils.FindChildWithAttributeValue(node, XmlConverter.kXmlFieldIdAttributeTag, "keyFrames");

                    if (keyframesXmlNode != null)
                    {
                        List <Keyframe> keyFrames = new List <Keyframe>();
                        foreach (XmlNode child in keyframesXmlNode.ChildNodes)
                        {
                            Keyframe keyFrame = new Keyframe();
                            keyFrame.inTangent   = XmlConverter.FieldObjectFromXmlNode <float>(child, "inTangent");
                            keyFrame.outTangent  = XmlConverter.FieldObjectFromXmlNode <float>(child, "outTangent");
                            keyFrame.tangentMode = XmlConverter.FieldObjectFromXmlNode <int>(child, "tangentMode");
                            keyFrame.time        = XmlConverter.FieldObjectFromXmlNode <float>(child, "time");
                            keyFrame.value       = XmlConverter.FieldObjectFromXmlNode <float>(child, "value");
                            keyFrames.Add(keyFrame);
                        }
                        curve.keys = keyFrames.ToArray();
                    }

                    return(curve);
                }
                public static object OnConvertFromXmlNode(object obj, XmlNode node)
                {
                    if (node == null)
                    {
                        return(obj);
                    }

                    IntRange intRange = (IntRange)obj;

                    intRange._min = XmlConverter.FieldObjectFromXmlNode <int>(node, "min");
                    intRange._max = XmlConverter.FieldObjectFromXmlNode <int>(node, "max");

                    return(intRange);
                }
Exemple #3
0
                public static object OnConvertFromXmlNode(object obj, XmlNode node)
                {
                    if (node == null)
                    {
                        return(obj);
                    }

                    Vector2 vector = (Vector2)obj;

                    vector.x = XmlConverter.FieldObjectFromXmlNode <float>(node, "x");
                    vector.y = XmlConverter.FieldObjectFromXmlNode <float>(node, "y");

                    return(vector);
                }
Exemple #4
0
                public static object OnConvertFromXmlNode(object obj, XmlNode node)
                {
                    if (node == null)
                    {
                        return(obj);
                    }

                    FloatRange floatRange = (FloatRange)obj;

                    floatRange._min = XmlConverter.FieldObjectFromXmlNode <float>(node, "min");
                    floatRange._max = XmlConverter.FieldObjectFromXmlNode <float>(node, "max");

                    return(floatRange);
                }
                public static object OnConvertFromXmlNode(object obj, XmlNode node)
                {
                    if (node == null)
                    {
                        return(obj);
                    }

                    Vector3 euler;

                    euler.x = XmlConverter.FieldObjectFromXmlNode <float>(node, "x");
                    euler.y = XmlConverter.FieldObjectFromXmlNode <float>(node, "y");
                    euler.z = XmlConverter.FieldObjectFromXmlNode <float>(node, "z");

                    return(Quaternion.Euler(euler));
                }
                public static object OnConvertFromXmlNode(object obj, XmlNode node)
                {
                    if (node == null)
                    {
                        return(obj);
                    }

                    string valueName = XmlConverter.FieldObjectFromXmlNode <string>(node, "valueName");

                    //First try to get value from string, If not possible, use the int value of the enum
                    int valueInt;

                    if (!ConvertFlagsFromString(obj, valueName, out valueInt))
                    {
                        valueInt = XmlConverter.FieldObjectFromXmlNode <int>(node, "valueIndex");
                    }

                    return(Enum.ToObject(obj.GetType(), valueInt));
                }
                public static object OnConvertFromXmlNode(object obj, XmlNode node)
                {
                    if (node == null)
                    {
                        return(obj);
                    }

                    Gradient gradient = new Gradient();

                    XmlNode colorKeysXmlNode = XmlUtils.FindChildWithAttributeValue(node, XmlConverter.kXmlFieldIdAttributeTag, "colorKeys");

                    if (colorKeysXmlNode != null)
                    {
                        List <GradientColorKey> colorKeys = new List <GradientColorKey>();
                        foreach (XmlNode child in colorKeysXmlNode.ChildNodes)
                        {
                            GradientColorKey colorKey = new GradientColorKey();
                            colorKey.color = XmlConverter.FieldObjectFromXmlNode <Color>(child, "color");
                            colorKey.time  = XmlConverter.FieldObjectFromXmlNode <float>(child, "time");
                            colorKeys.Add(colorKey);
                        }
                        gradient.colorKeys = colorKeys.ToArray();
                    }

                    XmlNode alphaKeysXmlNode = XmlUtils.FindChildWithAttributeValue(node, XmlConverter.kXmlFieldIdAttributeTag, "alphaKeys");

                    if (alphaKeysXmlNode != null)
                    {
                        List <GradientAlphaKey> alphaKeys = new List <GradientAlphaKey>();
                        foreach (XmlNode child in alphaKeysXmlNode.ChildNodes)
                        {
                            GradientAlphaKey alphaKey = new GradientAlphaKey();
                            alphaKey.alpha = XmlConverter.FieldObjectFromXmlNode <float>(child, "alpha");
                            alphaKey.time  = XmlConverter.FieldObjectFromXmlNode <float>(child, "time");
                            alphaKeys.Add(alphaKey);
                        }
                        gradient.alphaKeys = alphaKeys.ToArray();
                    }

                    return(gradient);
                }
                public static object OnConvertFromXmlNode(object obj, XmlNode node)
                {
                    if (node == null)
                    {
                        return(obj);
                    }

                    string valueName  = XmlConverter.FieldObjectFromXmlNode <string>(node, "valueName");
                    int    valueIndex = XmlConverter.FieldObjectFromXmlNode <int>(node, "valueIndex");

                    //First try to get value from string
                    if (!string.IsNullOrEmpty(valueName) && Enum.IsDefined(obj.GetType(), valueName))
                    {
                        return(Enum.Parse(obj.GetType(), valueName));
                    }
                    //If not possible, use the int value of the enum
                    else
                    {
                        return(Enum.ToObject(obj.GetType(), valueIndex));
                    }
                }