ParseVector2() public static method

public static ParseVector2 ( string val ) : Vector2
val string
return Vector2
Ejemplo n.º 1
0
    object ParseValue(SteeringBehaviorAsset.PropertyType t, string val)
    {
        switch (t)
        {
        case SteeringBehaviorAsset.PropertyType.BOOL:
            return(System.Boolean.Parse(val));

        case SteeringBehaviorAsset.PropertyType.INT:
            return(System.Int32.Parse(val));

        case SteeringBehaviorAsset.PropertyType.FLOAT:
            return(System.Single.Parse(val));

        case SteeringBehaviorAsset.PropertyType.STRING:
            return(val);

        case SteeringBehaviorAsset.PropertyType.VECTOR2:
            return(SteeringBehaviorAsset.ParseVector2(val));

        case SteeringBehaviorAsset.PropertyType.VECTOR3:
            return(SteeringBehaviorAsset.ParseVector3(val));

        case SteeringBehaviorAsset.PropertyType.VECTOR4:
            return(SteeringBehaviorAsset.ParseVector4(val));
        }
        return(null);
    }
Ejemplo n.º 2
0
    private string DefaultField(string val,
                                SteeringBehaviorAsset.PropertyType t)
    {
        if (val == null)
        {
            return(null);
        }
        object result = null;

        switch (t)
        {
        case SteeringBehaviorAsset.PropertyType.BOOL:
            bool vb = System.Boolean.Parse(val);
            result = EditorGUILayout.Toggle("Enabled", vb);
            break;

        case SteeringBehaviorAsset.PropertyType.INT:
            int vi = System.Int32.Parse(val);
            result = EditorGUILayout.IntField("Default Value", vi);
            break;

        case SteeringBehaviorAsset.PropertyType.FLOAT:
            float vf = System.Single.Parse(val);
            result = EditorGUILayout.FloatField("Default Value", vf);
            break;

        case SteeringBehaviorAsset.PropertyType.STRING:
            result = EditorGUILayout.TextField("Default Value", val);
            break;

        case SteeringBehaviorAsset.PropertyType.VECTOR2:
            Vector2 v2 = SteeringBehaviorAsset.ParseVector2(val);
            result = EditorGUILayout.Vector2Field("Default Value", v2);
            break;

        case SteeringBehaviorAsset.PropertyType.VECTOR3:
            Vector3 v3 = SteeringBehaviorAsset.ParseVector3(val);
            result = EditorGUILayout.Vector3Field("Default Value", v3);
            break;

        case SteeringBehaviorAsset.PropertyType.VECTOR4:
            Vector4 v4 = SteeringBehaviorAsset.ParseVector4(val);
            result = EditorGUILayout.Vector4Field("Default Value", v4);
            break;
        }
        return(result == null ? null : result.ToString());
    }