Example #1
0
        private void _HandleOnPlayModeChanged()
        {
            // This method is run whenever the playmode state is changed.
            if (Application.isPlaying)
            {
                //Debug.Log("PLAY");
            }
            else
            {
                //Debug.Log("STOP");
            }

            //When we change the playmode we have to trigger a new Connection setup on our oscTargets, otherwise we lose our event binding!

            UniOSCConnection actualCon = null;

            if (OSCConnectionID >= 0)
            {
                actualCon = EditorUtility.InstanceIDToObject(OSCConnectionID) as UniOSCConnection;
            }
            //Debug.Log("OSC Connections (playmodechanged):" + _myOSCConnections.Count);
            //Debug.Log("OSCConnectionID="+OSCConnectionID);


            if (oscSender1.isEnabled)
            {
                oscSender1.Disable();
                oscSender1.SetExplicitConnection(actualCon);
                oscSender1.Enable();
            }

            if (oscSender2.isEnabled)
            {
                oscSender2.Disable();
                oscSender2.SetExplicitConnection(actualCon);
                oscSender2.Enable();
            }

            if (oscSender3.isEnabled)
            {
                oscSender3.Disable();
                oscSender3.SetExplicitConnection(actualCon);
                oscSender3.Enable();
            }

            if (oscSender4.isEnabled)
            {
                oscSender4.Disable();
                oscSender4.SetExplicitConnection(actualCon);
                oscSender4.Enable();
            }

            /*
             * if (! EditorApplication.isPlaying && EditorApplication.isPlayingOrWillChangePlaymode)
             * {
             *
             *      Debug.Log("PLAY");
             * }
             *
             * if (EditorApplication.isPlaying && !EditorApplication.isPlayingOrWillChangePlaymode)
             * {
             *              Debug.Log("STOP");
             * }
             */
        }