Ejemplo n.º 1
0
        public static bool ToVector3(this OSCMessage message, out Vector3 value, bool force = false)
        {
            var values = message.GetValues(OSCValueType.Float);

            if (values.Length >= 3)
            {
                var firstValue  = values[0];
                var secondValue = values[1];
                var thirdValue  = values[2];

                value = new Vector3(firstValue.FloatValue, secondValue.FloatValue, thirdValue.FloatValue);

                return(true);
            }

            if (force)
            {
                Vector2 vector2;
                if (message.ToVector2(out vector2))
                {
                    value = vector2;
                    return(true);
                }

                Vector4 vector4;
                if (message.ToVector4(out vector4))
                {
                    value = vector4;
                    return(true);
                }
            }

            value = Vector3.zero;
            return(false);
        }
Ejemplo n.º 2
0
        public static bool ToColor(this OSCMessage message, out Color value, bool force = false)
        {
            var values = message.GetValues(OSCValueType.Color);

            if (values.Length > 0)
            {
                var firstValue = values[0];

                value = firstValue.ColorValue;
                return(true);
            }

            if (force)
            {
                Vector3 vector3;
                if (message.ToVector3(out vector3))
                {
                    value = new Color(vector3.x, vector3.y, vector3.z);
                    return(true);
                }

                Vector4 vector4;
                if (message.ToVector4(out vector4))
                {
                    value = new Color(vector4.x, vector4.y, vector4.z, vector4.w);
                    return(true);
                }
            }

            value = Color.white;
            return(false);
        }
Ejemplo n.º 3
0
        public static bool ToRect(this OSCMessage message, out Rect value)
        {
            Vector4 vector4;

            if (message.ToVector4(out vector4))
            {
                value = new Rect(vector4.x, vector4.y, vector4.z, vector4.w);
                return(true);
            }

            value = new Rect();
            return(false);
        }
Ejemplo n.º 4
0
        public static bool ToQuaternion(this OSCMessage message, out Quaternion value)
        {
            Vector4 vector4;

            if (message.ToVector4(out vector4))
            {
                value = new Quaternion(vector4.x, vector4.y, vector4.z, vector4.w);
                return(true);
            }

            value = new Quaternion();
            return(false);
        }