public static Vector2 ToVector2(JsonObject obj)
        {
            float x = obj.GetFloat("x");
            float y = obj.GetFloat("y");

            return(new Vector2(x, y));
        }
        public static Vector3 ToVector3(JsonObject obj)
        {
            float x = obj.GetFloat("x");
            float y = obj.GetFloat("y");
            float z = obj.GetFloat("z");

            return(new Vector3(x, y, z));
        }
        public static Quaternion ToQuaternion(JsonObject obj)
        {
            float x = obj.GetFloat("x");
            float y = obj.GetFloat("y");
            float z = obj.GetFloat("z");
            float w = obj.GetFloat("w");

            return(new Quaternion(x, y, z, w));
        }
        public static Vector4 ToVector4(JsonObject obj)
        {
            float x = obj.GetFloat("x");
            float y = obj.GetFloat("y");
            float z = obj.GetFloat("z");
            float w = obj.GetFloat("w");

            return(new Vector4(x, y, z, w));
        }
        public static Rect ToRect(JsonObject obj)
        {
            Rect r = new Rect();

            r.x      = obj.GetFloat("x");
            r.y      = obj.GetFloat("y");
            r.height = obj.GetFloat("height");
            r.width  = obj.GetFloat("width");
            return(r);
        }
        public static Color ToColor(JsonObject obj)
        {
            Color c = new Color();

            c.r = obj.GetFloat("r");
            c.g = obj.GetFloat("g");
            c.b = obj.GetFloat("b");
            c.a = obj.GetFloat("a");
            return(c);
        }
Beispiel #7
0
 /// <summary>
 /// Возвращает float значение из JsonObject, либо дефолтное, если такого ключа нет
 /// </summary>
 public static float GetFloat(this JsonObject obj, string key, float defaultValue)
 {
     return(obj.ContainsKey(key) ? obj.GetFloat(key) : defaultValue);
 }