void UpdateStatusInEditMode() { switch (_oscOut.mode) { case OscSendMode.UnicastToSelf: _statusInEditMode = OscRemoteStatus.Connected; _pingEnumerator = null; break; case OscSendMode.Unicast: _statusInEditMode = OscRemoteStatus.Unknown; if (!Application.isPlaying) { _pingEnumerator = OscHelper.StartCoroutineInEditMode(PingCoroutine(), ref _lastPingTime); } break; case OscSendMode.Multicast: _statusInEditMode = OscRemoteStatus.Unknown; _pingEnumerator = null; break; case OscSendMode.Broadcast: _statusInEditMode = OscRemoteStatus.Unknown; _pingEnumerator = null; break; } }
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); } }
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); } }