public static bool ToVector2(this OSCMessage message, out Vector2 value, bool force = false) { var values = message.GetValues(OSCValueType.Float); if (values.Length >= 2) { var firstValue = values[0]; var secondValue = values[1]; value = new Vector2(firstValue.FloatValue, secondValue.FloatValue); return(true); } if (force) { Vector3 vector3; if (message.ToVector3(out vector3)) { value = vector3; return(true); } Vector4 vector4; if (message.ToVector4(out vector4)) { value = vector4; return(true); } } value = Vector2.zero; return(false); }
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); }
protected void EulerAnglesReceived(OSCMessage message) { Vector3 value; if (message.ToVector3(out value) && headTransform != null) { Matrix4x4 inMatrix = Matrix4x4.Rotate(ConvertEulerAnglesToUnitySpace(value)); headTransform.transform.localRotation = (inMatrix * headMatrix).rotation; } }
protected void PositionReceived(OSCMessage message) { Vector3 value; if (message.ToVector3(out value) && headTransform != null) { value.x *= -1; headTransform.localPosition = value; } }