Ejemplo n.º 1
0
        public void SetValueOfType(Type newType, object value)
        {
            Assert.IsNotNull(newType);
            Type = newType;

            if (Type == typeof(int))
            {
                intValue = (int)value;
            }
            else if (Type == typeof(long))
            {
                longValue = (long)value;
            }
            else if (Type == typeof(bool))
            {
                boolValue = (bool)value;
            }
            else if (Type == typeof(float))
            {
                floatValue = (float)value;
            }
            else if (Type == typeof(double))
            {
                doubleValue = (double)value;
            }
            else if (Type == typeof(string))
            {
                stringValue = (string)value;
            }
            else if (Type == typeof(Color))
            {
                colorValue = (Color)value;
            }
            else if (Type.IsSubtypeOrEqualTo(typeof(UnityEngine.Object)))
            {
                objectValue = (UnityEngine.Object)value;
            }
            else if (Type == typeof(LayerMask))
            {
                layerMaskValue = (LayerMask)value;
            }
            else if (Type.IsSubtypeOrEqualTo(typeof(Enum)))
            {
                enumValue = new SerializableEnum((Enum)value, Type);
            }
            else if (Type == typeof(Vector2))
            {
                vector2Value = (Vector2)value;
            }
            else if (Type == typeof(Vector3))
            {
                vector3Value = (Vector3)value;
            }
            else if (Type == typeof(Vector4))
            {
                vector4Value = (Vector4)value;
            }
            else if (Type == typeof(Rect))
            {
                rectValue = (Rect)value;
            }
            else if (Type == typeof(char))
            {
                charValue = (char)value;
            }
            else if (Type == typeof(AnimationCurve))
            {
                curveValue = (AnimationCurve)value;
            }
            else if (Type == typeof(Bounds))
            {
                boundsValue = (Bounds)value;
            }
        }
Ejemplo n.º 2
0
        public void SetValueOfType(Type newType, object value)
        {
            Assert.IsNotNull(newType);
            Type = newType;

            if(Type == typeof(int))
                intValue = (int) value;
            else if(Type == typeof(long))
                longValue = (long) value;
            else if(Type == typeof(bool))
                boolValue = (bool) value;
            else if(Type == typeof(float))
                floatValue = (float) value;
            else if(Type == typeof(double))
                doubleValue = (double) value;
            else if(Type == typeof(string))
                stringValue = (string) value;
            else if(Type == typeof(Color))
                colorValue = (Color) value;
            else if(Type.IsSubtypeOrEqualTo(typeof(UnityEngine.Object)))
                objectValue = (UnityEngine.Object) value;
            else if(Type == typeof(LayerMask))
                layerMaskValue = (LayerMask) value;
            else if(Type.IsSubtypeOrEqualTo(typeof(Enum)))
                enumValue = new SerializableEnum((Enum) value, Type);
            else if(Type == typeof(Vector2))
                vector2Value = (Vector2) value;
            else if(Type == typeof(Vector3))
                vector3Value = (Vector3) value;
            else if(Type == typeof(Vector4))
                vector4Value = (Vector4) value;
            else if(Type == typeof(Rect))
                rectValue = (Rect) value;
            else if(Type == typeof(char))
                charValue = (char) value;
            else if(Type == typeof(AnimationCurve))
                curveValue = (AnimationCurve) value;
            else if(Type == typeof(Bounds))
                boundsValue = (Bounds) value;
        }