void Awake()
    {
        //Here we show the different possibilities to create a OSCEventTarget from code:

        //When we only specify a port we listen to all OSCMessages on that port (We assume that there is a OSCConnection with that listening port in our scene)
        oscTarget1 = new UniOSCEventTargetCBImplementation(OSCPort);
        oscTarget1.OSCMessageReceived += OnOSCMessageReceived1;
        //oscTarget1.oscPort = OSCPort;

        //This implies that we use the explicitConnection mode. (With responding to all OSCmessages)
        oscTarget2 = new UniOSCEventTargetCBImplementation(OSCConnection);
        oscTarget2.OSCMessageReceived += OnOSCMessageReceived2;

        //We listen to a special OSCAddress regardless of the port.
        oscTarget3 = new UniOSCEventTargetCBImplementation(OSCAddress);
        oscTarget3.OSCMessageReceived += OnOSCMessageReceived3;

        //The standard : respond to a given OSCAddress on a given port
        oscTarget4 = new UniOSCEventTargetCBImplementation(OSCAddress, OSCPort);
        oscTarget4.OSCMessageReceived += OnOSCMessageReceived4;

        //This version has the advantage that we are not bound to a special port. If the connection changes the port we still respond to the OSCMessage
        //oscTarget5 = new UniOSCEventTargetCBImplementation(OSCAddress, OSCConnection);
        //oscTarget5.OSCMessageReceived+=OnOSCMessageReceived5;


        oscDispatcher1 = new UniOSCEventDispatcherCBImplementation(OSCAddressOUT, OSCIPAddressOUT, OSCPortOUT);

        //oscDispatcher1.AppendData("TEST1");
        oscDispatcher1.AppendData(isDragging);                  // data at index [0] int isDragging
        oscDispatcher1.AppendData(controllerXPosition);         // data at index [1] float x
        oscDispatcher1.AppendData(controllerYPosition);         // data at index [2] float y
        oscDispatcher1.AppendData(isPinching);                  // data at index [3] int isPinching
        oscDispatcher1.AppendData(controllerScale);             // data at index [4] float z scale
        oscDispatcher1.AppendData(isTwisting);                  // data at index [5] int isTwisting
        oscDispatcher1.AppendData(controllerZRotation);         // data at index [6] float z rotation (euler)
        oscDispatcher1.AppendData(isDoubleTapped);              // data at index [7] int IsDoubleTapped

        //oscDispatcher2 = new UniOSCEventDispatcherCBImplementation(OSCAddressOUT,OSCConnectionOUT);


        //OSCConnection.transmissionTypeIn = OSCsharp.Net.TransmissionType.Multicast;
        //OSCConnection.oscInIPAddress = "224.0.0.1";//Set a valid Multicast address.
    }
    void OnEnable()
    {
        //Debug.Log("UniOSCCodeBasedDemo.OnEnable");

        //Just to create a OSCEventTarget isn't enough. We nedd to enable it:

        oscTarget1.Enable();

        oscTarget2.Enable();

        oscTarget3.Enable();

        oscTarget4.Enable();

        //oscTarget5.Enable();



        if (controllerToTrack == null)
        {
            controllerToTrack = this.gameObject;
        }

        //here your custom code

        //If you append data  data later you should always call this first otherwise we get more and more data appended if you toggle the enabled state of your component.
        //ClearData();


        //We append our data that we want to send with a message
        //The best place to do this step is on Enable().This approach is more flexible through the internal way UniOSC works.
        //later in the your "MySendOSCMessageTriggerMethod" you change this data with :
        //Message mode: ((OscMessage)_OSCeArg.Packet).UpdateDataAt(index,yourValue);
        //Bundle mode Mode: ((OscBundle)_OSCeArg.Packet).Messages[i]).UpdateDataAt(index,yourValue);
        //We only can append data types that are supported by the OSC specification:
        //(Int32,Int64,Single,Double,String,Byte[],OscTimeTag,Char,Color,Boolean)

        //Message mode

        controllerXPosition = controllerToTrack.transform.position.x;                   // drag
        controllerYPosition = controllerToTrack.transform.position.y;                   // drag
        controllerScale     = controllerToTrack.transform.localScale.x;                 // pinch
        controllerZRotation = controllerToTrack.transform.eulerAngles.z;                // twist
        isDragging          = 0;
        isDoubleTapped      = 0;
        isTwisting          = 0;
        isPinching          = 0;


        oscDispatcher1.AppendData(isDragging);                  // data at index [0] int isDragging
        oscDispatcher1.AppendData(controllerXPosition);         // data at index [1] float x
        oscDispatcher1.AppendData(controllerYPosition);         // data at index [2] float y
        oscDispatcher1.AppendData(isPinching);                  // data at index [3] int isPinching
        oscDispatcher1.AppendData(controllerScale);             // data at index [4] float z scale
        oscDispatcher1.AppendData(isTwisting);                  // data at index [5] int isTwisting
        oscDispatcher1.AppendData(controllerZRotation);         // data at index [6] float z rotation (euler)
        oscDispatcher1.AppendData(isDoubleTapped);              // data at index [7] int IsDoubleTapped


        //oscDispatcher1.Enable();

        //oscDispatcher2.Enable();
        ////just a test to show that you can clear and add data (is overwritten with 0 and 1 at Update())
        //oscDispatcher2.ClearData();
        //oscDispatcher2.AppendData("TEST2");
        //oscDispatcher2.AppendData("TEST2.1");

        // We want sent continously data so start our timer to set a flag at a given interval
        // The interval is in milliseconds.
        StartSendIntervalTimer();
    }