Ejemplo n.º 1
0
        /// <summary>
        /// Получение Vector3 из json
        /// </summary>
        /// <param name="node">Узел JSON</param>
        /// <returns> Vector3 </returns>
        public static Vector3 ReadVector3(JSON.ANode node)
        {
            float x = -1, y = -1, z = -1;

            if (TryReadFloat(node, ref x, "x") && TryReadFloat(node, ref y, "y") && TryReadFloat(node, ref z, "z"))
            {
                return(new Vector3(x, y, z));
            }
            Debug.LogError("Dev.JSON.ReadVector3: Bad Vector3: " + node.ToJSON());
            return(Vector3.zero);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Получение Quaternion из json
        /// </summary>
        /// <param name="node">Узел JSON</param>
        /// <returns> Quaternion </returns>
        public static Quaternion ReadQuaternion(JSON.ANode node)
        {
            float x = -1, y = -1, z = -1, w = -1;

            if (TryReadFloat(node, ref x, "x") && TryReadFloat(node, ref y, "y") && TryReadFloat(node, ref z, "z"))
            {
                return(TryReadFloat(node, ref w, "w") ? new Quaternion(x, y, z, w) : Quaternion.Euler(x, y, z));
            }
            Debug.LogError("Dev.JSON.ReadQuaternion: Bad Quaternion: " + node.ToJSON());
            return(Quaternion.identity);
        }