Exemplo n.º 1
0
        protected virtual void Start()
        {
            // Register receive callback.
            Receiver.Bind(_address, MessageReceived);

            // Create message
            var message = OSCMessage.Create(_address);

            // Create array
            var array = OSCValue.Array();

            array.AddValue(OSCValue.Int(1)); // You can use AddValue(OSCValue) method only with OSCValue what stored Array type.
            array.AddValue(OSCValue.Float(2.5f));
            array.AddValue(OSCValue.Color(Color.red));

            // You can store another array inside array.
            // Warning! OSCValue with "Array" type cannot store itself. It can do infinite loop.
            var secondArray = OSCValue.Array();

            secondArray.AddValue(OSCValue.String("This array..."));
            secondArray.AddValue(OSCValue.String("...inside another array!"));
            array.AddValue(secondArray);

            // Add array in message
            message.AddValue(array);

            // Send message
            Transmitter.Send(message);
        }
Exemplo n.º 2
0
 void Update()
 {
     if (Time.frameCount % 2 == 0)      // TODO fixed fps tick
     {
         manager.SendOSCMessage(OSCMessage.Create(Config.OSC_ADDRESS_TICK, Time.time));
     }
 }
Exemplo n.º 3
0
    void SendOSC(Vector3 pos, Vector3 rot, Rect rect)
    {
        OSCManager manager = OSCManager.instance;
        OSCMessage msg     = OSCMessage.Create("/calibration", pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, rect.x, rect.y, rect.width, rect.height);

        manager.SendPacket(msg, ipAddress, 7000);
    }
Exemplo n.º 4
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.name == "tableCollider")      // TODO ...
     {
         return;
     }
     if (collision.relativeVelocity.sqrMagnitude > 2)
     {
         // send "/collision"
         manager.SendOSCMessage(OSCMessage.Create(Config.OSC_ADDRESS_COLLISION, collision.relativeVelocity.sqrMagnitude));
     }
 }
Exemplo n.º 5
0
        void Update()
        {
            if (manager == null)
            {
                return;
            }

            // send "/ball"
            int     frame  = Time.frameCount % 99;
            Vector2 screen = manager.WorldToScreen(_transform.position);

            manager.SendOSCMessage(OSCMessage.Create(Config.OSC_ADDRESS_BALL, frame, (double)screen.x, (double)screen.y));
        }
Exemplo n.º 6
0
 OSCMessage createMessage()
 {
     return(OSCMessage.Create("/test", Time.frameCount, Random.Range(0, 10), Random.value, "hoge"));
 }