public void InitOscEvent(OscOut osc, string name, string address, double seekTime)
    {
        oscOut = osc;
        if (timelineSeekOscEvent == null)
        {
            timelineSeekOscEvent = new TimelineSeekOscEvent();
        }
        timelineSeekOscEvent.address   = address;
        timelineSeekOscEvent.name      = name;
        timelineSeekOscEvent.startTime = seekTime;
        if (timelineSeekOscEvent.oscMessage == null)
        {
            timelineSeekOscEvent.oscMessage = new OscMessage();
        }
        ;
        timelineSeekOscEvent.oscMessage.address = address;
        timelineSeekOscEvent.oscMessage.Add(seekTime);
        timelineSeekOscEvent.oscMessage.Set(0, seekTime);
        inputEventName.text = name;
        inPutAddress.text   = address;
        inputSeekTime.text  = seekTime.ToString();

        button.onClick.AddListener(() =>
        {
            oscOut.Send(timelineSeekOscEvent.oscMessage);
        });
    }
예제 #2
0
        void Start()
        {
            // Set up OscIn and OscOut for testing locally
            _oscOut = gameObject.AddComponent <OscOut>();
            _oscIn  = gameObject.AddComponent <OscIn>();
            _oscOut.Open(7000);
            _oscIn.Open(7000);

            // Forward received messages with addresses to methods.
            _oscIn.Map(address1, OnReceived1);
            _oscIn.Map(address2, OnReceived2);

            // Create a bundle and two messages.
            _bundle   = new OscBundle();
            _message1 = new OscMessage(address1);
            _message2 = new OscMessage(address2);

            // Add the two messages to the bundle.
            _bundle.Add(_message1);
            _bundle.Add(_message2);

            // Messages contained in incoming bundles are automatically unpacked,
            // and so incoming bundle objects are never exposed.
            // If you need to access time tags from incoming bundles you can set a
            // flag that will add the a time tag from contained messages when unpacking.
            //_oscIn.addTimeTagsToBundledMessages = true;
        }
예제 #3
0
    void Start()
    {
        // find scripts
        sampleInfo_JSONParsed       = GameObject.Find("loadJSON_fromMax").GetComponent <LoadJSON_FromMax>().sampleInfo_JSONParsed;
        globalEvolution_script      = GameObject.Find("globalEvolution").GetComponent <GlobalEvolution>();
        oscOutScript                = GameObject.Find("osc").GetComponent <OscOut>();
        cameraExplorerParent_script = GameObject.Find("camera_explorer_parent").GetComponent <CameraExplorerParent_Movement>();
        voidsAllInfo_script         = GameObject.Find("voidsAllInfo").GetComponent <VoidsAllInfo>();

        // init new() shit
        mixer = new Mixer();
        void_static_onOffCn                = new OnOff_Cn();
        void_static_onOffTracker           = new OnOffTracker();
        void_upsideDownReveal_onOffCn      = new OnOff_Cn();
        void_upsideDownReveal_onOffTracker = new OnOffTrackerWeighted();

        // evolution and mixer
        globalEvolutionState = GlobalEvolution.GlobalEvolutionState.begin;
        EvolutionParams();
        MixerValues_Init();

        // get the methods goin'
        New_Qbit_Qtype1_Transposition();
        New_Qbit_Brownian_State();

        // init Prevs

        // json data
        void_upsideDownReveal_prerecorded_brownianBufferDur = sampleInfo_JSONParsed["upsideDownReveal/1/duration"];

        // start over for Methods()
        start = false;
    }
        void Start()
        {
            // Create objects for sending and receiving
            oscOut = gameObject.AddComponent<OscOut>();
            oscIn = gameObject.AddComponent<OscIn>();

            // Prepare for multicasting messages to devices with applications that have joined the
            // multicast group with address 224.0.1.0 and are listening on port 7000.
            oscOut.Open( 7000, multicastAddress );

            // Technically multicasting addresses must be between 224.0.0.0 to 239.255.255.255,
            // but 224.0.0.0 to 224.0.0.255 is reserved for routing info so you should really
            // only use 224.0.1.0 to 239.255.255.255.

            // Prepare for receiving messages that are send to multicast group with address 224.0.1.0
            // on port 7000. We will also be receiving unicasted and broadcasted messages.
            oscIn.Open( 7000, multicastAddress );

            // If you only want messages from the multicast group that have been send from other
            // applications, then set the multicastLoopback property on OscOut to false.
            //oscOut.multicastLoopback = false;

            // Forward recived messages with address to method
            oscIn.Map( oscAddress, OnMessageReceived );

            // Show UI
            uiWrapper.SetActive( true );
        }
예제 #5
0
 // Use this for initialization
 void Start()
 {
     generalMagnager = MRPM_GeneralManager._instance;
     oscIn           = GetComponent <OscIn>();
     oscOut          = GetComponent <OscOut>();
     authStream      = oscIn.onAnyMessage.AsObservable();
 }
예제 #6
0
        void Start()
        {
            // Set up OscIn and OscOut for local testing.
            _oscOut = gameObject.AddComponent <OscOut>();
            _oscIn  = gameObject.AddComponent <OscIn>();
            _oscOut.Open(7000);
            _oscIn.Open(7000);

            // OPTIMISATION #1
            // Ensure that outgoing messages will be bundled automatically.
            // You can also bundle messages yourself; check the Bundles example.
            _oscOut.bundleMessagesOnEndOfFrame = true;

            // OPTIMISATION #2
            // Instantiate outgoing messages once and cache them locally.
            // If you are sending a single argument that is neither a string
            // nor a blob, then you can use the optimised method
            // Send( address, value ) instead.
            _outgoingMessage = new OscMessage(address);

            // OPTIMISATION #3
            // When receving strings and blobs then handle the message yourself.
            // Otherwise new strings and byte arrays will be generated continously.
            _oscIn.Map(address, OnMessageReceived);
        }
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Displays connected: " + Display.displays.Length);

        if (Display.displays.Length > 1)
        {
            Display.displays[1].Activate();
        }
        if (Display.displays.Length > 2)
        {
            Display.displays[2].Activate();
        }

        _oscIn  = gameObject.AddComponent <OscIn>();
        _oscOut = gameObject.AddComponent <OscOut>();

        _oscIn.Open(8000);
        _oscOut.Open(8000, "255.255.255.255");

        command.Select();
        command.ActivateInputField();

        _oscIn.MapInt("/amsie", AMSIceEarthCounterSetter);
        _oscIn.MapInt("/amsim", AMSIceMarsCounterSetter);
        _oscIn.MapInt("/amst", AMSTeethCounterSetter);
        _oscIn.MapInt("/amsr", AMSRingCounterSetter);
        _oscIn.MapInt("/amscn", AMSNoCarbonCounterSetter);
        _oscIn.MapInt("/amslun", AMSNoPbUCounterSetter);
        _oscIn.MapInt("/bdc", BDCCounterSetter);
        _oscIn.MapBool("/dosreport", ReportActivator);
        _oscIn.MapInt("/crate", OpenCrates);
    }
예제 #8
0
        void Start()
        {
            // Create objects for sending and receiving.
            oscOut = gameObject.AddComponent <OscOut>();
            oscIn  = gameObject.AddComponent <OscIn>();

            // Prepare for multicasting messages to devices with applications that have joined the
            // multicast group with address 224.0.1.0 and are listening on port 7000.
            oscOut.Open(7000, multicastAddress);

            // NOTE: Technically, multicasting addresses must be between 224.0.0.0 to 239.255.255.255,
            // but addresses 224.0.0.0 to 224.0.0.255 are reserved for routing info so you should really
            // only use 224.0.1.0 to 239.255.255.255.

            // Prepare for receiving messages that are send to multicast group with address 224.0.1.0
            // on port 7000. We will also be receiving unicasted and broadcasted messages.
            oscIn.Open(7000, multicastAddress);

            // If you only want messages from the multicast group that have been send from other
            // applications, then set the multicastLoopback property on OscOut to false.
            //oscOut.multicastLoopback = false;

            // Forward recived messages with address to method.
            oscIn.Map(oscAddress, OnMessageReceived);

            // Show UI
            uiWrapper.SetActive(true);
        }
예제 #9
0
 // Start is called before the first frame update
 void Start()
 {
     port     = "8000";
     ipadress = "127.0.0.1";
     oscOut   = gameObject.GetComponent <OscOut>();
     csc      = GameObject.FindWithTag("StatusCheck").GetComponent <ConnectionStatusCheck>();
 }
예제 #10
0
 // Use this for initialization
 void Start()
 {
     _generalManager          = MRPM_GeneralManager._instance;
     startButton              = GetComponent <Button>();
     startButton.interactable = false;
     oscOut = GetComponent <OscOut>();
 }
예제 #11
0
 void Start()
 {
     if (!oscOut)
     {
         oscOut = gameObject.AddComponent <OscOut>();
     }
     oscOut.Open(SonicPort, SonicHost);
 }
예제 #12
0
    // NOTE: this osc assets package makes it so In must be in Enable()
    //       and Out must be in Update(); this also won't work in OnApplicationQuit() unfortunately

    void Update()
    {
        if (start == true)
        {
            oscOutScript = GameObject.Find("osc").GetComponent <OscOut>();
            oscOutScript.Send("/unityStart", 1);
            start = false;
        }
    }
예제 #13
0
    private void Awake()
    {
        armBase = robotTransform.Find("base_link");
        arm     = robotTransform.Find("shoulder_pan_joint");

        oscOut = robotTransform.GetComponent <OscOut> ();


        oscCircle = this.transform.Find("OscStatus").GetComponent <Image> ();
    }
예제 #14
0
        public void OpenMultiChoicePorts()
        {
            YPRPorts = 1;

            if (!_oscOutCOMPASSMulti)
            {
                _oscOutCOMPASSMulti = gameObject.AddComponent <OscOut>();
            }
            _oscOutCOMPASSMulti.Open(1000, "127.0.0.1");
        }
예제 #15
0
        void Start()
        {
            // Set up OscIn and OscOut for local testing.
            _oscOut = gameObject.AddComponent <OscOut>();
            _oscIn  = gameObject.AddComponent <OscIn>();
            _oscOut.Open(7000);
            _oscIn.Open(7000);

            // Forward received messages with address to method.
            _oscIn.MapTimeTag(address, OnReceived);
        }
예제 #16
0
        public void OpenPort()
        {
            // Open OSC port for REAPER
            if (!_oscOutReaper)
            {
                _oscOutReaper = gameObject.AddComponent <OscOut>();
            }
            //_oscOutReaper.Open(9000, "127.0.0.1");
            _oscOutReaper.Open(9000, "192.168.1.46");

            Debug.Log("Ports opened");
        }
예제 #17
0
    void Start()
    {
        GameObject osc = GameObject.Find("osc");

        oscOut = osc.GetComponent <OscOut>();
        oscIn  = osc.GetComponent <OscIn>();

        oscOut.Open(7000);
        oscIn.Open(8000);

        // Debug.Log( "!!! Make sure Max udpsend is set to IPAddress " + OscIn.ipAddress );
        Debug.Log("!!! If orbits aren't working, in Max, try banging 'init_sound_libraries' and then restart the Scene");
    }
예제 #18
0
    void Start()
    {
        oscOutScript       = GameObject.Find("osc").GetComponent <OscOut>();
        lightComponent     = GetComponent <Light>();
        rigidbodyComponent = GetComponent <Rigidbody>();

        makeDiscsModel_script          = GameObject.Find("makeDiscsModel").GetComponent <MakeDiscsModel>();
        globalEvolution_script         = GameObject.Find("globalEvolution").GetComponent <GlobalEvolution>();
        lightDiscs_numBusyFlare_script = GameObject.Find("lightDiscs_numBusyFlare").GetComponent <LightDiscs_NumBusyFlare>();

        mixer = new Mixer();
        MixerValues_Init();
    }
예제 #19
0
        void Start()
        {
            // Set up OscIn and OscOut objects for a local test.
            _oscOut = gameObject.AddComponent <OscOut>();
            _oscIn  = gameObject.AddComponent <OscIn>();
            _oscOut.Open(7000);
            _oscIn.Open(7000);

            // Request messages with 'address' to be send to 'OnMessageReceived'.
            _oscIn.Map(address, OnMessageReceived);

            // Always cache messages when possible.
            _message = new OscMessage(address);
        }
예제 #20
0
        // public Action<string> onCommandReceived = (string s) =>
        // {};
        // public Action<string> onMessageReceived = (string s) =>
        // {};

        #endregion

        #region Unity Frameworks

        void Awake()
        {
            if (instance == null)
            {
                instance = this;
            }
            else if (instance != this)
            {
                Destroy(gameObject);
            }

            oscReceive = GetComponent <OscIn>();
            oscSend    = GetComponent <OscOut>();
        }
예제 #21
0
 // Start is called before the first frame update
 void Start()
 {
     if (!oscOut)
     {
         oscOut = gameObject.AddComponent <OscOut>();
     }
     oscOut.Open(8000, "127.0.0.1");
     oscOut.Send("OSC connection established");
     xAngle       = gameObject.GetComponent <CalculateAngle>().azimuth;
     yAngle       = gameObject.GetComponent <CalculateAngle>().elevation;
     MyDistance   = gameObject.GetComponent <GetDistance>().Distance_;
     DistanceL    = gameObject.GetComponent <GetAngle>().DistanceL;
     DistanceR    = gameObject.GetComponent <GetAngle>().DistanceR;
     switchSounds = gameObject.GetComponent <SwitchSound>().buttonPressed;
 }
예제 #22
0
    private void initOSC()
    {
        isReceiving = false;

        oscIn  = gameObject.GetComponent <OscIn>();
        oscOut = gameObject.GetComponent <OscOut>();

        oscIn.Open(9000);
        oscOut.Open(9000, "192.168.1.85");

        // cached to avoid constantly creating the message on update
        poseMessage = new OscMessage("/setAndGoTarget", 0f, 0f, 0f, 0f, 0f, 0f, 0f);              // moves the robot to the position
        //poseMessage = new OscMessage ("/realTimeTargetPose", 0f, 0f, 0f, 0f, 0f, 0f, 0f); // requires a goToTarget/ mesage to move the robot
        velocityMessage = new OscMessage("/setVelocity", velocity, acceleration);
    }
예제 #23
0
        protected override void OnStop()
        {
            foreach (var plugin in Plugins)
            {
                plugin.HostShutdown();
            }

            MidiIn?.Close();
            MidiIn?.Dispose();

            OscOut?.Close();
            OscOut?.Dispose();

            OscIn?.Close();
            OscIn?.Dispose();
        }
예제 #24
0
        public void OpenMushraPorts()
        {
            YPRPorts = 2;

            if (!_oscOutCOMPASSMushra1)
            {
                _oscOutCOMPASSMushra1 = gameObject.AddComponent <OscOut>();
            }
            _oscOutCOMPASSMushra1.Open(1000, "127.0.0.1");

            if (!_oscOutCOMPASSMushra2)
            {
                _oscOutCOMPASSMushra2 = gameObject.AddComponent <OscOut>();
            }
            _oscOutCOMPASSMushra2.Open(1100, "127.0.0.1");
        }
예제 #25
0
    void Start()
    {
        skybox = RenderSettings.skybox;

        oscOut_script          = GameObject.Find("osc").GetComponent <OscOut>();
        globalEvolution_script = GameObject.Find("globalEvolution").GetComponent <GlobalEvolution>();

        mixer = new Mixer();
        MixerValues_Init();
        skybox.SetFloat("_Exposure", 0);
        fade = true;

        New_SofterFade();
        New_StayPut();
        ReportOscStart();
    }
    // Start is called before the first frame update
    void Start()
    {
        _oscIn  = gameObject.AddComponent <OscIn>();
        _oscOut = gameObject.AddComponent <OscOut>();

        _oscIn.Open(8000);
        _oscOut.Open(8000, "255.255.255.255");


        _oscIn.MapInt("/resetsem", ResetMachine);

        imageHolder.SetActive(false);
        dataNumber.gameObject.SetActive(false);
        scanning.SetActive(false);
        noSampleScanned.SetActive(false);
        introduction.SetActive(true);



        //MicroscopeBackgroundSource.Play();

        ScanButton.DeviceSerialNumber = 523574;
        ScanButton.Channel            = 0;
        ScanButton.IsLocal            = true;
        ScanButton.Attach            += digitalInput_Attach;
        ScanButton.StateChange       += digitalInput_StateChange;

        RFIDMicroscope.DeviceSerialNumber = 453586;
        RFIDMicroscope.Channel            = 0;
        RFIDMicroscope.IsLocal            = true;
        RFIDMicroscope.Attach            += rfid_Attach;
        RFIDMicroscope.Tag     += rfid_Tag;
        RFIDMicroscope.TagLost += rfid_TagLost;


        try
        {
            ScanButton.Open(5000);
            RFIDMicroscope.Open(5000);
        }
        catch (PhidgetException e)
        {
            Debug.Log("Failed: " + e.Message);
        }

        // StartCoroutine(TurnRFIDAntennaOff());
    }
        void Start()
        {
            // Ensure that we have a OscOut component.
            if( !oscOut ) oscOut = gameObject.AddComponent<OscOut>();

            // Prepare for sending messages to applications on this device on port 7000.
            //oscOut.Open( port );

            // Or, to a target IP Address (Unicast).
            //oscOut.Open( 7000, "192.168.1.101" );

            // Or to all devices on the local network (Broadcast).
            oscOut.Open( port, "255.255.255.255" );

            // Or to a multicast group (Multicast).
            //oscOut.Open( 7000, "224.1.1.101" );
        }
예제 #28
0
        void OnEnable()
        {
            oscOut = target as OscOut;
            if (messageBuffer == null)
            {
                messageBuffer = new Queue <OscMessage>(messageBufferCapacity);
            }

            // Get serialized properties.
            _openOnAwake                = serializedObject.FindProperty("_openOnAwake");
            _ipAddress                  = serializedObject.FindProperty("_ipAddress");
            _port                       = serializedObject.FindProperty("_port");
            _multicastLoopback          = serializedObject.FindProperty("_multicastLoopback");
            _bundleMessagesOnEndOfFrame = serializedObject.FindProperty("_bundleMessagesOnEndOfFrame");
            _settingsFoldout            = serializedObject.FindProperty("_settingsFoldout");
            _messagesFoldout            = serializedObject.FindProperty("_messagesFoldout");

            // Store socket info for change check workaround.
            tempIPAddress = _ipAddress.stringValue;
            tempPort      = _port.intValue;

            // Ensure that OscOut scripts will be executed early, so that if Open On Awake is enabled the socket will open before other scripts are called.
            MonoScript script = MonoScript.FromMonoBehaviour(target as MonoBehaviour);

            if (MonoImporter.GetExecutionOrder(script) != executionOrderNum)
            {
                MonoImporter.SetExecutionOrder(script, executionOrderNum);
            }

            // When object is selected in Edit Mode then we start listening.
            if (oscOut.enabled && !Application.isPlaying && !oscOut.isOpen)
            {
                oscOut.Open(oscOut.port, oscOut.ipAddress);
                statusInEditMode = oscOut.mode == OscSendMode.UnicastToSelf ? OscRemoteStatus.Connected : OscRemoteStatus.Unknown;
            }

            // Subscribe to OSC messages
            oscOut.onAnyMessage.AddListener(OnOSCMessage);

            // If in Edit Mode, then start a coroutine that will update the connection status. Unity can't start coroutines in Runtime.
            if (!Application.isPlaying && oscOut.mode == OscSendMode.Unicast)
            {
                pingEnumerator = OscHelper.StartCoroutineInEditMode(PingCoroutine(), ref lastPingTime);
            }
        }
예제 #29
0
        void Start()
        {
            // Create objects for sending and receiving.
            oscOut = gameObject.AddComponent <OscOut>();
            oscIn  = gameObject.AddComponent <OscIn>();

            // Prepare for sending messages on port 7000.
            oscOut.Open(7000);

            // Prepare for receiving messages on port 7000.
            oscIn.Open(7000);

            // Forward received messages with address to method.
            oscIn.Map(address, OnMessageReceived);

            // Show UI.
            uiWrapper.SetActive(true);
        }
예제 #30
0
        void Start()
        {
            // Create objects for sending and receiving.
            oscOut = gameObject.AddComponent<OscOut>();
            oscIn = gameObject.AddComponent<OscIn>();

            // Prepare for sending messages on port 7000.
            oscOut.Open( 7000 );

            // Prepare for receiving messages on port 7000.
            oscIn.Open( 7000 );

            // Forward recived messages with address to method.
            oscIn.Map( address, OnMessageReceived );

            // Show UI.
            uiWrapper.SetActive( true );
        }
예제 #31
0
    void Start()
    {
        voidMeshScript  = GetComponent <VoidMesh>();
        particleSystem1 = GetComponent <ParticleSystem>();
        shapeModule     = particleSystem1.shape;
        mainModule      = particleSystem1.main;
        emissionModule  = particleSystem1.emission;
        rendererModule  = GetComponent <ParticleSystemRenderer>();

        self_id = voidMeshScript.self_id;

        globalEvolution_script = GameObject.Find("globalEvolution").GetComponent <GlobalEvolution>();
        voidsAllInfo_script    = GameObject.Find("voidsAllInfo").GetComponent <VoidsAllInfo>();

        oscOutScript = GameObject.Find("osc").GetComponent <OscOut>();

        mixer = new Mixer();
        MixerValues_Init();
    }
예제 #32
0
        void Start()
        {
            // Create objects for sending and receiving
            oscOut = gameObject.AddComponent<OscOut>();
            oscIn = gameObject.AddComponent<OscIn>();

            // Prepare for sending messages to applications on this device on port 7000.
            oscOut.Open( 7000 );

            // Prepare for receiving messages on port 7000.
            oscIn.Open( 7000 );

            // Forward recived messages with addresses to methods.
            oscIn.Map( address1, OnMessage1Received );
            oscIn.Map( address2, OnMessage2Received );

            // Show UI.
            uiWrapper.SetActive( true );
        }
예제 #33
0
        void OnEnable()
        {
            _oscOut = target as OscOut;

            // Get serialized properties.
            _openOnAwake                        = serializedObject.FindProperty("_openOnAwake");
            _remoteIpAddress                    = serializedObject.FindProperty("_remoteIpAddress");
            _port                               = serializedObject.FindProperty("_port");
            _multicastLoopback                  = serializedObject.FindProperty("_multicastLoopback");
            _bundleMessagesOnEndOfFrame         = serializedObject.FindProperty("_bundleMessagesOnEndOfFrame");
            _splitBundlesAvoidingBufferOverflow = serializedObject.FindProperty("_splitBundlesAvoidingBufferOverflow");
            _udpBufferSize                      = serializedObject.FindProperty("_udpBufferSize");
            _settingsFoldout                    = serializedObject.FindProperty("_settingsFoldout");
            _messagesFoldout                    = serializedObject.FindProperty("_messagesFoldout");

            // Store socket info for change check workaround.
            _tempIPAddress = _remoteIpAddress.stringValue;
            _tempPort      = _port.intValue;

            // Ensure that OscOut scripts will be executed early, so that if Open On Awake is enabled the socket will open before other scripts are called.
            MonoScript script = MonoScript.FromMonoBehaviour(target as MonoBehaviour);

            if (MonoImporter.GetExecutionOrder(script) != executionOrderNum)
            {
                MonoImporter.SetExecutionOrder(script, executionOrderNum);
            }

            // When object is selected in Edit Mode then we start listening.
            if (_oscOut.enabled && !Application.isPlaying && !_oscOut.isOpen)
            {
                _oscOut.Open(_oscOut.port, _oscOut.remoteIpAddress);
                _statusInEditMode = _oscOut.mode == OscSendMode.UnicastToSelf ? OscRemoteStatus.Connected : OscRemoteStatus.Unknown;
            }

            // Subscribe to OSC messages
            OscEditorUI.AddInspectorMessageListener(_oscOut, OnOSCMessage, ref _inspectorMessageEventObject);

            // If in Edit Mode, then start a coroutine that will update the connection status. Unity can't start coroutines in Runtime.
            if (!Application.isPlaying && _oscOut.mode == OscSendMode.Unicast)
            {
                _pingEnumerator = OscHelper.StartCoroutineInEditMode(PingCoroutine(), ref _lastPingTime);
            }
        }
예제 #34
0
        void Start()
        {
            // Create objects for sending and receiving
            oscOut = gameObject.AddComponent <OscOut>();
            oscIn  = gameObject.AddComponent <OscIn>();

            // Prepare for sending messages to applications on this device on port 7000.
            oscOut.Open(7000);

            // Prepare for receiving messages on port 7000.
            oscIn.Open(7000);

            // Forward recived messages with addresses to methods.
            oscIn.Map(address1, OnMessage1Received);
            oscIn.Map(address2, OnMessage2Received);

            // Show UI.
            uiWrapper.SetActive(true);
        }
        void Start()
        {
            // Create objects for sending and receiving
            oscOut = gameObject.AddComponent<OscOut>();
            oscIn = gameObject.AddComponent<OscIn>();

            // Prepare for broadcasting messages to devices on the local network to be received by applications listening on port 7000.
            oscOut.Open( 7000, "255.255.255.255" );

            // For the hardcode haters, you can get the broadcast address like this System.Net.IPAddress.Broadcast.ToString().

            // Prepare for receiving unicasted and broadcasted messages from this and other devices on port 7000.
            oscIn.Open( 7000 );

            // Forward recived messages with address to method
            oscIn.Map( address, OnMessageReceived );

            // Show UI
            uiWrapper.SetActive( true );
        }
예제 #36
0
        void Start()
        {
            // Create objects for sending and receiving
            oscOut = gameObject.AddComponent<OscOut>();
            oscIn = gameObject.AddComponent<OscIn>();

            // Prepare for unicasting messages to this (same) device to be received by applications listening on port 7000.
            oscOut.Open( 7000 );

            // Alternatively, prepare for unicasting messages to device with IP address to be received by applications listening on port 7000.
            //oscOut.Open( 7000, "192.168.1.101" );

            // Prepare for receiving unicasted and broadcasted messages from this and other devices on port 7000
            oscIn.Open( 7000 );

            // Forward recived messages with address to method
            oscIn.Map( address, OnMessageReceived );

            // Show UI
            uiWrapper.SetActive( true );
        }
        void OnEnable()
        {
            oscOut = target as OscOut;
            if( messageBuffer == null ) messageBuffer = new Queue<OscMessage>( messageBufferCapacity );

            // Get serialized properties
            _openOnAwake = serializedObject.FindProperty("_openOnAwake");
            _ipAddress = serializedObject.FindProperty("_ipAddress");
            _port = serializedObject.FindProperty("_port");
            _multicastLoopback = serializedObject.FindProperty("_multicastLoopback");
            _bundleMessagesOnEndOfFrame = serializedObject.FindProperty("_bundleMessagesOnEndOfFrame");
            _settingsFoldout = serializedObject.FindProperty("_settingsFoldout");
            _messagesFoldout = serializedObject.FindProperty("_messagesFoldout");

            // Store socket info for change check workaround
            tempIPAddress = _ipAddress.stringValue;
            tempPort = _port.intValue;

            // Ensure that OscOut scripts will be executed early, so that if Open On Awake is enabled the socket will open before other scripts are called.
            MonoScript script = MonoScript.FromMonoBehaviour( target as MonoBehaviour );
            if( MonoImporter.GetExecutionOrder( script ) != executionOrderNum ) MonoImporter.SetExecutionOrder( script, executionOrderNum );

            // When object is selected in Edit Mode then we start listening
            if( oscOut.enabled && !Application.isPlaying && !oscOut.isOpen ){
                oscOut.Open( oscOut.port, oscOut.ipAddress );
                statusInEditMode = oscOut.mode == OscSendMode.UnicastToSelf ? OscRemoteStatus.Connected : OscRemoteStatus.Unknown;
            }

            // Subscribe to OSC messages
            oscOut.onAnyMessage.AddListener( OnOSCMessage );

            // If in Edit Mode, then start a coroutine that will update the connection status. Unity can't start coroutines in Runtime.
            if( !Application.isPlaying && oscOut.mode == OscSendMode.Unicast ){
                pingEnumerator = OscHelper.StartCoroutineInEditMode( PingCoroutine(), ref lastPingTime );
            }
        }