private string _oscOutMulticastIPAddress = "224.0.1.0";//224.0.0.0 - 239.255.255.255 ! private void _ValidateOscOutIPAddress() { IPAddress addr; _isValidOscOutIPAddress = UniOSCUtils.ValidateIPAddress(_oscOutIPAddress, out addr); _oscOutIPAddressAsIPAddress = addr; }
override public void OnInspectorGUI() { GUILayout.Space(5f); if (_tex_logo != null) { UniOSCUtils.DrawClickableTextureHorizontal(_tex_logo, () => { EditorApplication.ExecuteMenuItem(UniOSCUtils.MENUITEM_EDITOR); }); } //EditorGUIUtility.LookLikeControls(150f,100f); EditorGUIUtility.labelWidth = 150f; EditorGUIUtility.fieldWidth = 100f; DrawDefaultInspector(); GUILayout.Space(5f); serializedObject.Update(); EditorGUI.BeginChangeCheck(); DrawConnectionSetup(); DrawConnectionInfo(); serializedObject.ApplyModifiedProperties(); if (EditorGUI.EndChangeCheck()) { _target.enabled = !_target.enabled; _target.enabled = !_target.enabled; } }
public static void Init() { if (_tex == null) { _tex = UniOSCUtils.MakeTexture(2, 2, new Color(0.95f, 0.95f, 0.95f, 0.25f)); } }
override public void OnInspectorGUI() { GUILayout.Space(5f); if (_tex_logo != null) { UniOSCUtils.DrawClickableTextureHorizontal(_tex_logo, () => { EditorApplication.ExecuteMenuItem(UniOSCUtils.MENUITEM_EDITOR); }); } //EditorGUIUtility.LookLikeControls(150f,50f); EditorGUIUtility.labelWidth = 150f; EditorGUIUtility.fieldWidth = 50f; DrawDefaultInspector(); GUILayout.Space(5f); serializedObject.Update(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(OSCAddressProp, new GUIContent("OSC Address", "")); DrawConnectionSetup(); DrawConnectionInfo(); serializedObject.ApplyModifiedProperties(); if (EditorGUI.EndChangeCheck() || _updateFlag) { ForceUpdate(); } }
private static void _ReadAllOSCSessionFiles(bool selectLastItem, UniOSCSessionFileObj selectedOSCSessionFileObj) { UniOSCSessionFileObj[] list = UniOSCUtils.GetAssetsOfType <UniOSCSessionFileObj>(UniOSCUtils.MAPPINGFILEEXTENSION); _config.OSCSessionFileObjList.Clear(); _optionsSessionFiles = new string[list.Length]; for (int i = 0; i < list.Length; i++) { _optionsSessionFiles[i] = Path.GetFileNameWithoutExtension(AssetDatabase.GetAssetPath(list[i])); _config.OSCSessionFileObjList.Add(list[i]); //we have to recalculte the guid on every import ,so we can import assets from other projects list[i].my_guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(list[i])); list[i].IsLearning = _config.isOSCLearning; } _config.selectedSessionFileObjIndex = Mathf.Max(0, Mathf.Min(_config.selectedSessionFileObjIndex, _config.OSCSessionFileObjList.Count - 1)); if (_config.OSCSessionFileObjList.Count > 0 && selectLastItem) { int index = _config.OSCSessionFileObjList.FindIndex(x => x.my_guid == selectedOSCSessionFileObj.my_guid); if (index > -1) { _config.selectedSessionFileObjIndex = index; } } }
private string _oscMulticastIPAddress = "224.0.1.0"; //224.0.0.0 - 239.255.255.255 ! private void _ValidateOscIPAddress() { //Debug.Log("OSCConnection.ValidateOscIPAddress"); IPAddress addr; _isValidOscIPAddress = UniOSCUtils.ValidateIPAddress(localIPAddress, out addr); _oscInIPAddressAsIPAddress = addr; }
void OnEnable() { _IPAddress = UniOSCUtils.GetLocalIPAddress(); foreach (var con in UniOSCConnection.Instances) { con.OSCMessageReceived += OnOSCMessageReceived; con.OSCMessageSend += OnOSCMessageSended; } tex_logo = Resources.Load(UniOSCUtils.LOGO32_NAME, typeof(Texture2D)) as Texture2D; }
override public void OnInspectorGUI() { GUILayout.Space(5f); if (_tex_logo != null) { UniOSCUtils.DrawClickableTextureHorizontal(_tex_logo, () => { EditorApplication.ExecuteMenuItem(UniOSCUtils.MENUITEM_EDITOR); }); } //EditorGUIUtility.LookLikeControls(150f,50f); EditorGUIUtility.labelWidth = 150f; EditorGUIUtility.fieldWidth = 50f; DrawDefaultInspector(); GUILayout.Space(5f); serializedObject.Update(); EditorGUI.BeginChangeCheck(); #region component List <Component> comps = _targetToggle.gameObject.GetComponents <Component>().ToList(); comps.Remove(comps.Find(c => c.GetType() == _targetToggle.GetType())); //security???? _options = new string[comps.Count]; for (int i = 0; i < comps.Count; i++) { _options[i] = comps[i].GetType().ToString(); } _componentIndex = comps.FindIndex(c => c.GetType() == _targetToggle.componentToToggle.GetType()); if (_componentIndex < 0) { //the current component was probably removed so we have to update our gameobject to prevent nasty exceptions (_compType) _updateFlag = true; } _componentIndex = Mathf.Max(0, _componentIndex); _componentIndex = EditorGUILayout.Popup("componentToToggle", _componentIndex, _options); _targetToggle.componentToToggle = comps[_componentIndex]; #endregion component ToggleStateProp.boolValue = GUILayout.Toggle(ToggleStateProp.boolValue, new GUIContent("Toggle State", "")); //,GUILayout.Width(100) EditorGUILayout.PropertyField(OSCAddressProp, new GUIContent("OSC Address", "")); DrawConnectionSetup(); DrawConnectionInfo(); serializedObject.ApplyModifiedProperties(); if (EditorGUI.EndChangeCheck() || _updateFlag) { //update data (EditorUtility.SetDirty(_target) doesn't work) ForceUpdate(); } }
/// <summary> /// Maps the incoming OSC data. /// </summary> /// <param name="args">Arguments.</param> public void MapData(UniOSCEventArgs args) { for (int i = 0; i < args.Message.Data.Count; i++) { System.Object obj = args.Message.Data[i]; if (obj is float) { args.Message.UpdateDataAt(i, UniOSCUtils.MapInterval((float)obj, min, max, mappingMIN, mappingMAX)); } } //for }
static void _CreateOSCConnection() { GameObject go = new GameObject("OSCConnection" + _osConnectionList.Count); UniOSCConnection oc = go.AddComponent <UniOSCConnection>(); oc.oscPort = 8000; oc.oscOutPort = 9000; oc.oscOutIPAddress = UniOSCUtils.GetLocalIPAddress(); go.name = "OSCConnection." + go.GetInstanceID(); oc.Awake(); }
public static void OnGUI_OSCSessionData_Inspector(UniOSCSessionFileObj obj, float screenWidth, float screenHeight) { EditorGUILayout.BeginVertical(GUILayout.MaxHeight(screenHeight)); #region Path EditorGUILayout.BeginHorizontal(); GUIContent guic = new GUIContent("Path: " + AssetDatabase.GUIDToAssetPath(obj.my_guid) + " .", ""); Rect area = GUILayoutUtility.GetRect(guic, GUIStyle.none, GUILayout.MinHeight(30f)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUI.Label(area, guic); if (UniOSCUtils.IsMouseUpInArea(area)) { UniOSCUtils.SelectObjectInHierachyFromGUID(obj.my_guid); } _StartDrag(area, obj); EditorGUILayout.EndHorizontal(); #endregion Path _OnGUI_DrawButtons(obj, false); #region ScrollView obj.scrollposInspector = EditorGUILayout.BeginScrollView(obj.scrollposInspector, GUILayout.ExpandHeight(true), GUILayout.Width(screenWidth)); //GUILayout.Width (100) EditorGUILayout.BeginHorizontal(); //Hardcoding layout for wrapping maxCols = (int)Math.Max(minCols, Math.Floor((screenWidth - 20f) / (UniOSCSessionItem.MAXWIDTH * 1.0f))); //Floor Ceiling for (var i = 0; i < obj.oscSessionItemList.Count; i++) { // Begin new row? if (i % maxCols == 0 && i > 0) { GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); } UniOSCSessionItem c = obj.oscSessionItemList[i]; UniOSCSessionItemEditor.OnGUI_Inspector(c); } //for EditorGUILayout.EndHorizontal(); EditorGUILayout.EndScrollView(); #endregion ScrollView EditorGUILayout.EndVertical(); }
private void _ValidateOscOutMulticastIPAddress() { IPAddress addr; _isValidOscOutMulticastIPAddress = UniOSCUtils.ValidateIPAddress(_oscOutMulticastIPAddress, out addr); _oscOutMulticastIPAddressAsIPAddress = addr; if (_isValidOscOutMulticastIPAddress) { //Second validation _isValidOscOutMulticastIPAddress = UniOSCUtils.RegexMatch(_oscOutMulticastIPAddress, UniOSCUtils.MULTICASTREGEX); } }
/// <summary> /// Maps the incoming OSC data. /// </summary> /// <param name="args">Arguments.</param> public void MapData(UniOSCEventArgs args) { OscMessage msg = ((OscMessage)args.Packet); for (int i = 0; i < msg.Data.Count; i++) { System.Object obj = msg.Data[i]; if (obj is float) { msg.UpdateDataAt(i, UniOSCUtils.MapInterval((float)obj, min, max, mappingMIN, mappingMAX)); } } //for }
override public void OnInspectorGUI(){ GUILayout.Space(5f); if(_tex_logo != null){ UniOSCUtils.DrawClickableTextureHorizontal(_tex_logo,()=>{EditorApplication.ExecuteMenuItem(UniOSCUtils.MENUITEM_EDITOR);}); } EditorGUI.BeginChangeCheck(); if (drawDefaultInspectorProp.boolValue) { DrawDefaultInspector (); } serializedObject.Update(); //EditorGUI.BeginChangeCheck(); GUILayout.BeginVertical("box"); EditorGUILayout.PropertyField(OSCOutAddressProp,new GUIContent("OSC Out Address","") ); GUILayout.EndVertical(); GUILayout.BeginVertical("box"); EditorGUILayout.PropertyField(UseExplicitConnectionProp,new GUIContent("Explicit Connection",UniOSCUtils.TOOLTIP_EXPLICITCONNECTION) ); if(UseExplicitConnectionProp.boolValue) { EditorGUILayout.PropertyField(ExplicitConnectionProp,new GUIContent("Selected Connection","") ); GUILayout.EndVertical(); } else { GUILayout.EndVertical(); GUILayout.BeginVertical("box"); DrawIPAddress(); DrawPort(); GUILayout.EndVertical(); } //EditorGUILayout.PropertyField(sendIntervalProp,new GUIContent("Send Interval","The interval in milliseconds to send OSC data.") ); DrawConnectionInfo(); serializedObject.ApplyModifiedProperties(); if(EditorGUI.EndChangeCheck()){ //update data (EditorUtility.SetDirty(_target) doesn't work) _target.ForceSetupChange(true); //_target.enabled = !_target.enabled; //_target.enabled = !_target.enabled; } }
override public void OnInspectorGUI() { GUILayout.Space(5f); if (_tex_logo != null) { UniOSCUtils.DrawClickableTextureHorizontal(_tex_logo, () => { EditorApplication.ExecuteMenuItem(UniOSCUtils.MENUITEM_EDITOR); }); } //EditorGUIUtility.LookLikeControls(150f,50f); EditorGUIUtility.labelWidth = 150f; EditorGUIUtility.fieldWidth = 50f; DrawDefaultInspector(); GUILayout.Space(5f); serializedObject.Update(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(ReceiveAllAddressesProp, new GUIContent("Receive all Addresses", "Listen to all OSC addresses. If you have performance problems it's better to specifiy the OSC address explicit and deselect this option.")); if (!ReceiveAllAddressesProp.boolValue) { GUILayout.BeginVertical("box"); EditorGUILayout.PropertyField(OSCAddressProp, new GUIContent("OSC Address", "OSC address string the component should listen to. Other addresses are skipped so in your component callback method you don't need to filter the addresses by yourself.")); GUILayout.EndVertical(); } else { if (!Application.isPlaying) { GUIContent gc = new GUIContent("Component listens to all addresses. Watch your performance on heavy OSC traffic."); Rect area = GUILayoutUtility.GetRect(gc, GUI.skin.box); EditorGUI.HelpBox(area, gc.text, MessageType.Info); } } DrawConnectionSetup(); DrawConnectionInfo(); serializedObject.ApplyModifiedProperties(); if (EditorGUI.EndChangeCheck()) { //update data (EditorUtility.SetDirty(_target) doesn't work) _target.ForceSetupChange(); //_target.enabled = !_target.enabled; //_target.enabled = !_target.enabled; } }
private void _ValidateOscMulticastIPAddress() { //Debug.Log("OSCConnection.ValidateOscMulticastIPAddress"); IPAddress addr; _isValidOscMulticastIPAddress = UniOSCUtils.ValidateIPAddress(_oscMulticastIPAddress, out addr); _oscMulticastIPAddressAsIPAddress = addr; if (_isValidOscMulticastIPAddress) { //Second validation _isValidOscMulticastIPAddress = UniOSCUtils.RegexMatch(_oscMulticastIPAddress, UniOSCUtils.MULTICASTREGEX); } }
private void _CreateConnectionOut() { if (_oscTransmitter != null) { _DeleteConnectionOut(); } //Debug.Log("UniOSCConnection._CreateConnectionOut:"+oscOutPort); IPAddress addr; if (UniOSCUtils.ValidateIPAddress(oscOutIPAddress, out addr)) { _oscTransmitter = new UniOSCTransmitter(addr, oscOutPort); } else { //Invalid IPAdress Debug.LogWarning("OSCConnection.Invalid IPAdress:" + oscOutIPAddress); } }
/// <summary> /// Init this instance. /// Is called from Awake and OSCAutoRun /// </summary> public static void Init() { if (_connectionInstances == null) { _connectionInstances = new List <UniOSCConnection>(); } if (_AvailableINPorts == null) { _AvailableINPorts = new List <int>(); } if (_AvailableOUTPorts == null) { _AvailableOUTPorts = new List <int>(); } if (_AvailableOUTIPAddresses == null) { _AvailableOUTIPAddresses = new List <string>(); } if (localIPAddress == null) { localIPAddress = UniOSCUtils.GetLocalIPAddress(); } }
override public void OnInspectorGUI() { GUILayout.Space(5); if (tex_logo != null) { UniOSCUtils.DrawClickableTextureHorizontal(tex_logo, () => { EditorApplication.ExecuteMenuItem(UniOSCUtils.MENUITEM_EDITOR); }); } serializedObject.Update(); EditorGUI.BeginChangeCheck(); FoldoutOSCInProp.boolValue = EditorGUILayout.Foldout(FoldoutOSCInProp.boolValue, "OSC IN"); if (FoldoutOSCInProp.boolValue) { GUILayout.BeginVertical("box"); EditorGUILayout.PropertyField(AutoConnectOSCInProp, new GUIContent("Auto connect on start", "")); EditorGUILayout.PropertyField(OSCPortProp, new GUIContent("Port:")); OSCPortProp.intValue = Mathf.Min(UniOSCUtils.MAXPORT, OSCPortProp.intValue); GUILayout.EndVertical(); } FoldoutOSCOutProp.boolValue = EditorGUILayout.Foldout(FoldoutOSCOutProp.boolValue, "OSC OUT"); if (FoldoutOSCOutProp.boolValue) { GUILayout.BeginVertical("box"); EditorGUILayout.PropertyField(AutoConnectOSCOutProp, new GUIContent("Auto connect on start", "")); EditorGUILayout.PropertyField(OSCOutPortProp, new GUIContent("Port", "")); OSCOutPortProp.intValue = Mathf.Min(UniOSCUtils.MAXPORT, OSCOutPortProp.intValue); EditorGUILayout.PropertyField(OSCOutIPAddressProp, new GUIContent("Target IPAddress", "")); GUILayout.EndVertical(); } GUILayout.Space(10); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); UniOSCConnection.Update_AvailablePorts(); } ShowOSCReciverStatus(_target); Show("Mapping Files", OSCMappingFileObjListProp); Show("Session Files", OSCSessionFileObjListProp); if (_target.hasOSCSessionFileAttached) { //EditorGUILayout.PropertyField(AutoConnectOSCInProp,new GUIContent("Auto connect on start","") ); if (GUILayout.Button(new GUIContent("Send Session Data", "Send the last OSC data that are recorded with your session files."), GUILayout.Width(150f))) { _target.SendSessionData(); } if (!_target.isConnectedOut) { EditorGUILayout.HelpBox("To send the session data you have to turn on OSC OUT!", MessageType.Warning); //EditorGUI.HelpBox(area,"OSC IN: "+UniOSCConnection.localIPAddress+"\nPort: "+oscConnection.oscPort+"\nListening", MessageType.Info); } } serializedObject.ApplyModifiedProperties(); if (GUI.changed) { EditorUtility.SetDirty(_target); } }
// void OnGUI(){ // // } /// <summary> /// Renders the GUI of a OSCConnection in the GameView. /// This is different from the rendering in the editor/inspector /// </summary> public void RenderGUI() { if (UniOSCUtils.TEX_CONNECTION_BG == null) { UniOSCUtils.TEX_CONNECTION_BG = UniOSCUtils.MakeTexture(2, 2, UniOSCUtils.CONNECTION_BG); } _gs = new GUIStyle(GUI.skin.box); _gs.normal.background = UniOSCUtils.TEX_CONNECTION_BG; _gs.fontSize = 11; GUILayout.BeginVertical(_gs); #region Header GUILayout.BeginHorizontal(); GUILayout.Label(name); GUILayout.EndHorizontal(); #endregion Header GUILayout.BeginHorizontal(); #region IN GUILayout.BeginVertical(); GUI.backgroundColor = _connected ? UniOSCUtils.CONNECTION_ON_COLOR : UniOSCUtils.CONNECTION_OFF_COLOR; GUIContent gc; StringBuilder sb = new StringBuilder(); sb.AppendLine("OSC IN"); sb.AppendLine(String.Format("Port:{0}", oscPort)); if (_connected) { sb.AppendLine(String.Format("Listening:{0}", localIPAddress)); gc = new GUIContent(sb.ToString()); Rect area = GUILayoutUtility.GetRect(gc, _gs, GUILayout.MinWidth(150f)); GUI.Box(area, gc, _gs); } else { //sb.AppendLine("Not listening"); GUIStyle _gs2 = new GUIStyle(GUI.skin.label); _gs2.normal.background = UniOSCUtils.TEX_CONNECTION_BG; _gs2.fontSize = 11; GUILayout.BeginVertical(_gs); GUILayout.Label(new GUIContent("OSC IN"), _gs); GUILayout.BeginHorizontal(_gs2); GUILayout.Label(new GUIContent("Port:"), _gs2); gc = new GUIContent("65536"); Rect areaPort = GUILayoutUtility.GetRect(gc, _gs, GUILayout.MinWidth(20f)); oscPort = Mathf.Min(UniOSCUtils.MAXPORT, Convert.ToInt32(GUI.TextField(areaPort, oscPort.ToString()))); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } GUI.backgroundColor = Color.white; if (GUILayout.Button(_connected ? "Disconnect":"Connect")) { if (_connected) { DisconnectOSC(); } else { ConnectOSC(); } } GUILayout.EndVertical(); #endregion IN GUILayout.Space(5f); #region OUT GUILayout.BeginVertical(); GUI.backgroundColor = _connectedOut ? UniOSCUtils.CONNECTION_ON_COLOR : UniOSCUtils.CONNECTION_OFF_COLOR; GUIContent gcOut; StringBuilder sb_out = new StringBuilder(); sb_out.AppendLine("OSC OUT"); if (_connectedOut) { sb_out.AppendLine(String.Format("Port:{0}", oscOutPort)); sb_out.AppendLine(String.Format("Sending:{0}", oscOutIPAddress)); gcOut = new GUIContent(sb_out.ToString()); Rect areaOut = GUILayoutUtility.GetRect(gcOut, _gs, GUILayout.MinWidth(150f)); //GUILayoutUtility.GetRect(150,50); GUI.Box(areaOut, gcOut, _gs); } else { //sb_out.AppendLine(String.Format("Not Sending:{0}",oscOutIPAddress)); GUIStyle _gs2 = new GUIStyle(GUI.skin.label); _gs2.normal.background = UniOSCUtils.TEX_CONNECTION_BG; _gs2.fontSize = 11; GUILayout.BeginVertical(_gs); GUILayout.Label(new GUIContent("OSC OUT"), _gs); GUILayout.BeginHorizontal(_gs2); GUILayout.Label(new GUIContent("Port:"), _gs2); gc = new GUIContent("65536"); Rect areaPort = GUILayoutUtility.GetRect(gc, _gs, GUILayout.MinWidth(20f)); oscOutPort = Mathf.Min(UniOSCUtils.MAXPORT, Convert.ToInt32(GUI.TextField(areaPort, oscOutPort.ToString()))); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(_gs2); GUILayout.Label(new GUIContent("IP:"), _gs); gc = new GUIContent("255.255.255.255"); Rect areaIp = GUILayoutUtility.GetRect(gc, _gs, GUILayout.MinWidth(100f)); if (_tfgs == null) { _tfgs = new GUIStyle(GUI.skin.textField); } string oscOutIPAddressTemp = GUI.TextField(areaIp, oscOutIPAddress, _tfgs); GUILayout.EndHorizontal(); IPAddress addr; if (UniOSCUtils.ValidateIPAddress(oscOutIPAddressTemp, out addr)) { //oscOutIPAddress = oscOutIPAddressTemp; _tfgs = new GUIStyle(GUI.skin.textField); } else { //When the IP-Address is invalid we get visual feedback _tfgs.normal.textColor = new Color(0.8f, 0.0f, 0.0f, 1f); _tfgs.hover.textColor = new Color(0.9f, 0.0f, 0.0f, 1f); _tfgs.active.textColor = Color.red; _tfgs.focused.textColor = Color.red; } oscOutIPAddress = oscOutIPAddressTemp; GUILayout.EndVertical(); } GUI.backgroundColor = Color.white; if (GUILayout.Button(_connectedOut ? "Disconnect":"Connect")) { if (_connectedOut) { DisconnectOSCOut(); } else { ConnectOSCOut(); } } GUILayout.EndVertical(); #endregion OUT GUILayout.EndHorizontal(); #region session GUILayout.BeginHorizontal(); if (hasOSCSessionFileAttached) { if (!_connectedOut) { GUI.backgroundColor = Color.red; GUI.contentColor = Color.red; } if (GUILayout.Button(new GUIContent("Send Session Data", "Tooltip"))) { SendSessionData(); } GUI.backgroundColor = Color.white; GUI.contentColor = Color.white; } GUILayout.EndHorizontal(); #endregion GUILayout.EndVertical(); }
void OnGUI() { if (this._recompile == null) { // if yes assume recompile then create a reference to a recompile class this._recompile = new RecompileClass(); //little hack for the editor,otherwise on start we have no OSC Connections in the Editor GUI. ([InitializeOnLoad] didn't work) //Init(); _GetOSCConnectionInstances(); } EditorGUI.BeginChangeCheck(); _editorWidth = position.width; if (_config.isOSCTracing) { _editorWidth = _editorWidth - TRACEWIDTH; } if (_config.mySkin != null) { GUI.skin = _config.mySkin; } //Rect for Learning Border Rect r_learn = new Rect(0f, 0f, position.width, position.height); EditorGUILayout.BeginHorizontal(); #region GUI_LEFT EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true)); if (_config == null) { Rect area = GUILayoutUtility.GetRect(500.0f, 80.0f); EditorGUI.HelpBox(area, "No configuration could be loaded! The Editor could not work in this state.", MessageType.Error); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); return; } GUILayout.Space(4); #region header #region logo GUILayout.BeginHorizontal(); GUILayout.Space(4); UniOSCUtils.DrawTexture(_config.tex_logo); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); #endregion logo GUILayout.BeginHorizontal(); GUI.backgroundColor = _config.isOSCTracing ? Color.green : Color.white; _config.isOSCTracing = GUILayout.Toggle(_config.isOSCTracing, new GUIContent("Trace OSC"), GUI.skin.button, GUILayout.Height(30f), GUILayout.Width(100f)); //OSCConnectionEditor.tex2 GUI.backgroundColor = Color.white; if (GUILayout.Button(new GUIContent("Create OSC Connection", ""), GUILayout.Width(160f), GUILayout.Height(30f))) { _CreateOSCConnection(); Init(); } ; if (GUILayout.Button("Create OSC Mapping File", GUILayout.Height(30f), GUILayout.Width(160f))) { _CreateOSCMappingFile(); } if (GUILayout.Button("Create OSC Session File", GUILayout.Height(30f), GUILayout.Width(160f))) { _CreateOSCSessionFile(); } GUI.backgroundColor = _config.isOSCLearning ? Color.green : Color.white; _config.isOSCLearning = GUILayout.Toggle(_config.isOSCLearning, new GUIContent("Learn OSC"), GUI.skin.button, GUILayout.Height(30f), GUILayout.Width(100f)); //OSCConnectionEditor.tex2 GUI.backgroundColor = Color.white; if (_isOSCLearning != _config.isOSCLearning) { //Toggle was clicked _isOSCLearning = _config.isOSCLearning; OSCLearning(_config.isOSCLearning); //EditorUtility.SetDirty(_config); } //_config.isEditorEnabled = UniOSCConnection.isEditorEnabled; GUI.backgroundColor = _config.isEditorEnabled ? Color.green : Color.white; _config.isEditorEnabled = GUILayout.Toggle(_config.isEditorEnabled, new GUIContent("Editor Mode"), GUI.skin.button, GUILayout.Height(30f), GUILayout.Width(100f)); GUI.backgroundColor = Color.white; UniOSCConnection.isEditorEnabled = _config.isEditorEnabled; GUILayout.EndHorizontal(); #endregion header GUILayout.Space(5); _DrawLineH(_editorWidth - 20f); GUILayout.Space(5); #region Connection GUILayout.BeginHorizontal(); GUIStyle gsCon = new GUIStyle(GUI.skin.label); gsCon.fontSize = 18; GUILayout.Label("OSC Connection", gsCon); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(3); OnGUI_OSCConnection(); #endregion Connection #region space GUI.contentColor = Color.white; GUI.backgroundColor = Color.white; GUILayout.Space(5); _DrawLineH(_editorWidth - 20f); GUILayout.Space(5); #endregion space #region toolbar _config.toolbarInt = GUILayout.Toolbar(_config.toolbarInt, toolbarStrings, GUILayout.Width(200 * toolbarStrings.Count()), GUILayout.Height(30f)); #endregion toolbar GUILayout.Space(5); // _DrawLineH(_editorWidth-20f); GUILayout.Space(5); #region Mapping switch (_config.toolbarInt) { case 0: OnGUI_OSCMapping(); break; case 1: OnGUI_OSCSessionFiles(); break; default: OnGUI_DefaultContent(); break; } #endregion Mapping #region footer GUI.contentColor = Color.white; if (_osConnectionIDList.Count > 0) { _DrawLineH(_editorWidth - 20f); GUILayout.Space(10f); } if (GUILayout.Button(new GUIContent("Refresh Editor", "Refresh the Editor. Reloads the available data"), GUILayout.Width(150), GUILayout.Height(30f))) { Init(); } ; GUILayout.Space(5f); #endregion footer EditorGUILayout.EndVertical(); #endregion GUI_LEFT #region GUI_RIGHT if (_config.isOSCTracing) { Rect r_tracing = GUILayoutUtility.GetRect(1.0f, position.height - 0f); GUI.Box(r_tracing, "", GUI.skin.box); //,GUI.skin.box GUI.skin.customStyles[1] OnGUI_Trace(); } #endregion GUI_RIGHT EditorGUILayout.EndHorizontal(); //draw Learning Border if (_config.isOSCLearning) { GUI.backgroundColor = Color.red; GUI.Box(r_learn, "", _config.learnStyle); GUI.backgroundColor = Color.white; } if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(_config); } }
// public static void OnGUI_OSCMappingData_Editor(UniOSCMappingFileObj obj, float screenWidth, float screenHeight) { EditorGUILayout.BeginVertical(GUILayout.MaxHeight(screenHeight)); #region Path EditorGUILayout.BeginHorizontal(); GUIContent guic = new GUIContent("Path: " + AssetDatabase.GUIDToAssetPath(obj.my_guid) + " .", ""); Rect area = GUILayoutUtility.GetRect(guic, GUIStyle.none, GUILayout.MinHeight(30f)); //GUILayout.MaxWidth(400f), GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUI.Label(area, guic); if (UniOSCUtils.IsMouseUpInArea(area)) { UniOSCUtils.SelectObjectInHierachyFromGUID(obj.my_guid); } _StartDrag(area, obj); EditorGUILayout.EndHorizontal(); #endregion Path #region Button _OnGUI_DrawButtons(obj, true); #endregion Button #region Header EditorGUILayout.BeginHorizontal(); GUIContent con0 = new GUIContent("OSC Address "); Rect rect0 = GUILayoutUtility.GetRect(con0, GUI.skin.label, GUILayout.MaxWidth(300f)); GUI.Label(rect0, con0); GUIContent con1 = new GUIContent("Min "); Rect rect1 = GUILayoutUtility.GetRect(con1, GUI.skin.label, GUILayout.MaxWidth(50f)); GUI.Label(rect1, con1); GUIContent con2 = new GUIContent("Max "); Rect rect2 = GUILayoutUtility.GetRect(con2, GUI.skin.label, GUILayout.MaxWidth(50f)); GUI.Label(rect2, con2); GUIContent con3 = new GUIContent("Mapping Min "); Rect rect3 = GUILayoutUtility.GetRect(con3, GUI.skin.label, GUILayout.MaxWidth(120f)); GUI.Label(rect3, con3); GUIContent con4 = new GUIContent("Mapping Max "); Rect rect4 = GUILayoutUtility.GetRect(con4, GUI.skin.label, GUILayout.MaxWidth(120f)); GUI.Label(rect4, con4); GUIContent con5 = new GUIContent(""); //Learn Rect rect5 = GUILayoutUtility.GetRect(con5, GUI.skin.toggle, GUILayout.Width(80f)); GUI.Label(rect5, con5); GUIContent con6 = new GUIContent(""); //Delete Rect rect6 = GUILayoutUtility.GetRect(con6, GUI.skin.label, GUILayout.Width(70f)); GUI.Label(rect6, con6); if (Event.current.type == EventType.Repaint) { UniOSCUtils.MAPPINGLISTLABELRECTS[0] = rect0; UniOSCUtils.MAPPINGLISTLABELRECTS[1] = rect1; UniOSCUtils.MAPPINGLISTLABELRECTS[2] = rect2; UniOSCUtils.MAPPINGLISTLABELRECTS[3] = rect3; UniOSCUtils.MAPPINGLISTLABELRECTS[4] = rect4; UniOSCUtils.MAPPINGLISTLABELRECTS[5] = rect5; UniOSCUtils.MAPPINGLISTLABELRECTS[6] = rect6; } EditorGUILayout.EndHorizontal(); #endregion Header #region List style = new GUIStyle(GUI.skin.box); style.normal.background = _tex; style.margin = new RectOffset(0, 0, 0, 2); //draw the mapping items EditorGUILayout.BeginHorizontal(); if (Event.current.type == EventType.Repaint) { screenWidth = UniOSCUtils.MAPPINGLISTHEADERLABELWIDTH; } obj.scrollpos = EditorGUILayout.BeginScrollView(obj.scrollpos, GUILayout.ExpandHeight(true), GUILayout.Width(screenWidth), GUILayout.MaxWidth(UniOSCUtils.MAPPINGLISTHEADERLABELWIDTH)); //GUILayout.Width(screenWidth) ,GUILayout.MaxWidth(OSCUtils.MAPPINGLISTHEADERLABELWIDTH int rowIndex = 0; try{ for (var i = 0; i < obj.oscMappingItemList.Count; i++) { GUI.backgroundColor = rowIndex % 2 == 0 ? UniOSCUtils.ITEM_LIST_COLOR_A : UniOSCUtils.ITEM_LIST_COLOR_B; UniOSCMappingItem c = obj.oscMappingItemList[i]; GUILayout.BeginHorizontal(style); UniOSCMappingItemEditor.OnGUI_Editor(c); GUILayout.EndHorizontal(); rowIndex++; } }catch (Exception) { //drag&drop Exception handling } GUI.backgroundColor = Color.white; EditorGUILayout.EndScrollView(); EditorGUILayout.EndHorizontal(); #endregion List EditorGUILayout.EndVertical(); }
// void OnGUI(){ // // } /// <summary> /// Renders the GUI of a OSCConnection in the GameView. /// This is different from the rendering in the editor/inspector /// </summary> public void RenderGUI() { if (UniOSCUtils.TEX_CONNECTION_BG == null) { UniOSCUtils.TEX_CONNECTION_BG = UniOSCUtils.MakeTexture(2, 2, UniOSCUtils.CONNECTION_BG); } _gs = new GUIStyle(GUI.skin.box); _gs.normal.background = UniOSCUtils.TEX_CONNECTION_BG; _gs.fontSize = 11; GUILayout.BeginVertical(_gs); #region Header GUILayout.BeginHorizontal(); GUILayout.Label(name); GUILayout.EndHorizontal(); #endregion Header GUILayout.BeginHorizontal(); #region IN GUILayout.BeginVertical(); GUI.backgroundColor = _connected ? UniOSCUtils.CONNECTION_ON_COLOR : UniOSCUtils.CONNECTION_OFF_COLOR; GUIContent gc; StringBuilder sb = new StringBuilder(); sb.AppendLine("OSC IN"); sb.AppendLine(String.Format("Port:{0}", oscPort)); GUIStyle _gs2 = new GUIStyle(GUI.skin.label); _gs2.normal.background = UniOSCUtils.TEX_CONNECTION_BG; _gs2.fontSize = 11; GUILayout.BeginVertical(_gs); GUILayout.Label(new GUIContent("OSC IN"), _gs); GUILayout.BeginHorizontal(_gs2); GUILayout.Label(new GUIContent("Port:"), _gs2); gc = new GUIContent("65535"); Rect areaPort = GUILayoutUtility.GetRect(gc, _gs, GUILayout.MinWidth(20f)); oscPort = Mathf.Min(UniOSCUtils.MAXPORT, Convert.ToInt32(GUI.TextField(areaPort, oscPort.ToString()))); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(_gs2); int toolbarInt = 0; toolbarInt = (int)transmissionTypeIn; string[] toolbarStrings = new string[] { "Unicast", "Multicast" }; GUIStyle _gs2b = new GUIStyle(GUI.skin.toggle); _gs2b.fontSize = 12; toolbarInt = GUILayout.Toolbar(toolbarInt, toolbarStrings, _gs2b, GUILayout.Width(75 * toolbarStrings.Count()), GUILayout.Height(25f)); transmissionTypeIn = (OSCsharp.Net.TransmissionType)toolbarInt; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(_gs2); GUILayout.Label(new GUIContent("IP:"), _gs); gc = new GUIContent("255.255.255.255"); Rect areaIpIn = GUILayoutUtility.GetRect(gc, _gs, GUILayout.MinWidth(100f)); _tfgs = (transmissionTypeIn == OSCsharp.Net.TransmissionType.Unicast) ? new GUIStyle(GUI.skin.label): new GUIStyle(GUI.skin.textField); if (!hasValidOscIPAddress) { //When the IP-Address is invalid we get visual feedback _tfgs.normal.textColor = new Color(0.8f, 0.0f, 0.0f, 1f); _tfgs.hover.textColor = new Color(0.9f, 0.0f, 0.0f, 1f); _tfgs.active.textColor = Color.red; _tfgs.focused.textColor = Color.red; } if (transmissionTypeIn == OSCsharp.Net.TransmissionType.Unicast) { GUI.Label(areaIpIn, oscInIPAddress, _tfgs); } else { oscInIPAddress = GUI.TextField(areaIpIn, oscInIPAddress, _tfgs); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUI.backgroundColor = Color.white; if (GUILayout.Button(_connected ? "Disconnect":"Connect")) { if (_connected) { DisconnectOSC(); } else { ConnectOSC(); } } GUILayout.EndVertical(); #endregion IN GUILayout.Space(5f); #region OUT GUILayout.BeginVertical(); GUI.backgroundColor = _connectedOut ? UniOSCUtils.CONNECTION_ON_COLOR : UniOSCUtils.CONNECTION_OFF_COLOR; GUIStyle _gs3 = new GUIStyle(GUI.skin.label); _gs3.normal.background = UniOSCUtils.TEX_CONNECTION_BG; _gs3.fontSize = 11; GUILayout.BeginVertical(_gs); GUILayout.Label(new GUIContent("OSC OUT"), _gs); GUILayout.BeginHorizontal(_gs3); GUILayout.Label(new GUIContent("Port:"), _gs3); gc = new GUIContent("65536"); Rect areaPort3 = GUILayoutUtility.GetRect(gc, _gs, GUILayout.MinWidth(20f)); oscOutPort = Mathf.Min(UniOSCUtils.MAXPORT, Convert.ToInt32(GUI.TextField(areaPort3, oscOutPort.ToString()))); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(_gs3); int toolbarIntOut = 0; toolbarIntOut = (int)transmissionTypeOut; string[] toolbarStringsOut = new string[] { "Unicast", "Multicast", "Broadcast" }; GUIStyle _gs3b = new GUIStyle(GUI.skin.toggle); _gs3b.fontSize = 12; toolbarIntOut = GUILayout.Toolbar(toolbarIntOut, toolbarStringsOut, _gs3b, GUILayout.Width(75 * toolbarStringsOut.Count()), GUILayout.Height(25f)); transmissionTypeOut = (OSCsharp.Net.TransmissionType)toolbarIntOut; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(_gs3); GUILayout.Label(new GUIContent("IP:"), _gs); gc = new GUIContent("255.255.255.255"); Rect areaIpOut = GUILayoutUtility.GetRect(gc, _gs, GUILayout.MinWidth(100f)); _tfgs = ((int)transmissionTypeOut >= (int)OSCsharp.Net.TransmissionType.Broadcast) ? new GUIStyle(GUI.skin.label) : new GUIStyle(GUI.skin.textField); if (!hasValidOscOutIPAddress) { //When the IP-Address is invalid we get visual feedback _tfgs.normal.textColor = new Color(0.8f, 0.0f, 0.0f, 1f); _tfgs.hover.textColor = new Color(0.9f, 0.0f, 0.0f, 1f); _tfgs.active.textColor = Color.red; _tfgs.focused.textColor = Color.red; } if ((int)transmissionTypeOut >= (int)OSCsharp.Net.TransmissionType.Broadcast) { GUI.Label(areaIpOut, oscOutIPAddress, _tfgs); } else { oscOutIPAddress = GUI.TextField(areaIpOut, oscOutIPAddress, _tfgs); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUI.backgroundColor = Color.white; if (GUILayout.Button(_connectedOut ? "Disconnect":"Connect")) { if (_connectedOut) { DisconnectOSCOut(); } else { ConnectOSCOut(); } } GUILayout.EndVertical(); #endregion OUT GUILayout.EndHorizontal(); #region session GUILayout.BeginHorizontal(); if (hasOSCSessionFileAttached) { if (!_connectedOut) { GUI.backgroundColor = Color.red; GUI.contentColor = Color.red; } if (GUILayout.Button(new GUIContent("Send Session Data", "Tooltip"))) { SendSessionData(); } GUI.backgroundColor = Color.white; GUI.contentColor = Color.white; } GUILayout.EndHorizontal(); #endregion GUILayout.EndVertical(); }
void OnGUI() { if (!Application.isPlaying) { if (!ShowInEditMode) { return; } } GUIScaler.Begin(); GUILayout.BeginVertical(GUILayout.Width(Screen.width / GUIScaler.GuiScale.x), GUILayout.Height(Screen.height / (GUIScaler.GuiScale.y))); // GUILayout.Space(10f); #region IPAddress GUILayout.BeginHorizontal(); GUILayout.Space(10f); UniOSCUtils.DrawTexture(tex_logo); GUILayout.FlexibleSpace(); GUILayout.Label(_IPAddress, GUILayout.Height(30f)); GUILayout.FlexibleSpace(); _showGUI = GUILayout.Toggle(_showGUI, new GUIContent(_showGUI? "Hide GUI":"Show GUI"), GUI.skin.button, GUILayout.Height(30), GUILayout.Width(130)); GUILayout.Space(10f); GUILayout.EndHorizontal(); #endregion IPAddress if (!_showGUI) { GUILayout.EndVertical(); GUIScaler.End(); return; } GUILayout.Space(10f); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); #region OSCConnections GUILayout.BeginVertical(); foreach (var con in UniOSCConnection.Instances) { if (con.gameObject.activeInHierarchy && con.enabled) { con.RenderGUI(); GUILayout.Space(5f); } //if } //for GUILayout.EndVertical(); #endregion OSCConnections GUILayout.FlexibleSpace(); #region trace if (gs_textArea == null) { gs_textArea = new GUIStyle(GUI.skin.textArea); gs_textArea.fontSize = 10; gs_textArea.normal.textColor = Color.yellow; } GUILayout.BeginVertical(GUILayout.Width(200f)); traceScrollpos = GUILayout.BeginScrollView(traceScrollpos, GUILayout.Height(((Screen.height / GUIScaler.GuiScale.y) * 0.75f) - 40f), GUILayout.ExpandHeight(false)); GUILayout.TextArea(_oscTraceStr, gs_textArea, GUILayout.ExpandHeight(true)); GUILayout.EndScrollView(); if (GUILayout.Button("Clear Trace", GUILayout.Height(30))) { _oscTraceStr = ""; _osctraceStrb = new StringBuilder(); } GUILayout.EndVertical(); #endregion trace GUILayout.Space(10f); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUIScaler.End(); }
override public void OnInspectorGUI() { GUILayout.Space(5); if (tex_logo != null) { UniOSCUtils.DrawClickableTextureHorizontal(tex_logo, () => { EditorApplication.ExecuteMenuItem(UniOSCUtils.MENUITEM_EDITOR); }); } serializedObject.Update(); EditorGUI.BeginChangeCheck(); FoldoutOSCInProp.boolValue = EditorGUILayout.Foldout(FoldoutOSCInProp.boolValue, "OSC IN"); if (FoldoutOSCInProp.boolValue) { GUILayout.BeginVertical("box"); EditorGUILayout.PropertyField(AutoConnectOSCInProp, new GUIContent("Auto connect on start", "")); EditorGUILayout.PropertyField(OSCPortProp, new GUIContent("Port:")); OSCPortProp.intValue = Mathf.Min(UniOSCUtils.MAXPORT, OSCPortProp.intValue); _TransmissionTypeIndex = TransmissionTypeInProp.enumValueIndex; _TransmissionTypeIndex = EditorGUILayout.Popup("TransmissionType", _TransmissionTypeIndex, _TransmissionTypes); TransmissionTypeInProp.enumValueIndex = _TransmissionTypeIndex; GUI.backgroundColor = _target.hasValidOscIPAddress ? Color.green : Color.red; if (TransmissionTypeInProp.enumValueIndex == (int)OSCsharp.Net.TransmissionType.Multicast) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(OSCMulticastIPAddressProp, new GUIContent("Multicast IP address", "")); EditorGUILayout.HelpBox("A valid multicast IP address is in the range between 224.0.0.0 and 239.255.255.255 !", MessageType.Warning); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); _target.ValidateOscInIPAddress(); } } else { GUI.backgroundColor = Color.white; GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField(new GUIContent("Local IP address ", ""), GUILayout.MaxWidth(115)); // GUILayout.FlexibleSpace(); EditorGUILayout.LabelField(new GUIContent(UniOSCConnection.localIPAddress, ""), GUILayout.MaxWidth(100)); // GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } GUI.backgroundColor = Color.white; GUILayout.EndVertical(); } if (EditorGUI.EndChangeCheck()) { // Debug.Log("CHANGE"); serializedObject.ApplyModifiedProperties(); UniOSCConnection.Update_AvailableOSCSettings(); _target.Force_SetupChanged_IN(); } EditorGUI.BeginChangeCheck(); FoldoutOSCOutProp.boolValue = EditorGUILayout.Foldout(FoldoutOSCOutProp.boolValue, "OSC OUT"); if (FoldoutOSCOutProp.boolValue) { GUILayout.BeginVertical("box"); EditorGUILayout.PropertyField(AutoConnectOSCOutProp, new GUIContent("Auto connect on start", "")); EditorGUILayout.PropertyField(OSCOutPortProp, new GUIContent("Port", "")); OSCOutPortProp.intValue = Mathf.Min(UniOSCUtils.MAXPORT, OSCOutPortProp.intValue); // _TransmissionTypes = TransmissionTypeOutProp.enumNames; _TransmissionTypeIndexOut = TransmissionTypeOutProp.enumValueIndex; _TransmissionTypeIndexOut = EditorGUILayout.Popup("TransmissionType", _TransmissionTypeIndexOut, _TransmissionTypesOut); TransmissionTypeOutProp.enumValueIndex = _TransmissionTypeIndexOut; GUI.backgroundColor = _target.hasValidOscOutIPAddress ? Color.green : Color.red; EditorGUI.BeginChangeCheck(); switch (TransmissionTypeOutProp.enumValueIndex) { case (int)OSCsharp.Net.TransmissionType.Unicast: EditorGUILayout.PropertyField(OSCOutIPAddressProp, new GUIContent("Target IP address", "")); break; case (int)OSCsharp.Net.TransmissionType.Multicast: EditorGUILayout.PropertyField(OSCOutMulticastIPAddressProp, new GUIContent("Multicast IP address", "")); EditorGUILayout.HelpBox("A valid multicast IP address is in the range between 224.0.0.0 and 239.255.255.255 !", MessageType.Warning); break; case (int)OSCsharp.Net.TransmissionType.Broadcast: case (int)OSCsharp.Net.TransmissionType.LocalBroadcast: GUI.backgroundColor = Color.white; GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField(new GUIContent("Target IP address", ""), GUILayout.MaxWidth(115)); GUILayout.FlexibleSpace(); EditorGUILayout.LabelField(new GUIContent(IPAddress.Broadcast.ToString(), ""), GUILayout.MaxWidth(100)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); break; } if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); _target.ValidateOscOutIPAddress(); } GUI.backgroundColor = Color.white; GUILayout.EndVertical(); } GUILayout.Space(10); if (EditorGUI.EndChangeCheck()) { // Debug.Log("CHANGE"); serializedObject.ApplyModifiedProperties(); UniOSCConnection.Update_AvailableOSCSettings(); _target.Force_SetupChanged_OUT(); } ShowOSCReciverStatus(_target); Show("Mapping Files", OSCMappingFileObjListProp); Show("Session Files", OSCSessionFileObjListProp); if (_target.hasOSCSessionFileAttached) { //EditorGUILayout.PropertyField(AutoConnectOSCInProp,new GUIContent("Auto connect on start","") ); if (GUILayout.Button(new GUIContent("Send Session Data", "Send the last OSC data that are recorded with your session files."), GUILayout.Width(150f))) { _target.SendSessionData(); } if (!_target.isConnectedOut) { EditorGUILayout.HelpBox("To send the session data you have to turn on OSC OUT!", MessageType.Warning); } } serializedObject.ApplyModifiedProperties(); if (GUI.changed) { EditorUtility.SetDirty(_target); } }
public static void ShowOSCReciverStatus(UniOSCConnection oscConnection) { EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); Event evt = Event.current; GUIStyle style = new GUIStyle(GUI.skin.button); style.padding = new RectOffset(0, 0, 0, 0); style.border = new RectOffset(0, 0, 0, 0); #region IN EditorGUILayout.BeginVertical(GUILayout.MaxWidth(200)); Rect area = GUILayoutUtility.GetRect(195.0f, 40.0f); area.width *= 1f; Rect r1 = GUILayoutUtility.GetRect(195.0f, 20.0f); r1.width *= 1f; int btnsize1 = 20; Rect r1b = new Rect(area); r1b.x += r1b.width - (btnsize1 * 1); r1b.y += r1b.height - btnsize1; r1b.width = btnsize1 * 1; r1b.height = btnsize1; if (oscConnection.isConnected) { GUI.contentColor = Color.white; //GUI.backgroundColor = UniOSCUtils.CONNECTION_BG; //GUI.Box(area,"");//to dimm the background GUI.backgroundColor = oscConnection.dispatchOSC ? UniOSCUtils.CONNECTION_ON_COLOR : UniOSCUtils.CONNECTION_PAUSE_COLOR; EditorGUI.HelpBox(area, "OSC IN: " + UniOSCConnection.localIPAddress + "\nPort: " + oscConnection.oscPort + "\nListening", MessageType.Info); if (GUI.Button(r1, "Disconnect")) { oscConnection.DisconnectOSC(); } GUI.backgroundColor = Color.white; GUI.contentColor = Color.white; //if (GUI.Button (r1b,new GUIContent(tex2,""),style ) ){oscConnection.SendTestMessage();} Texture2D currTex = oscConnection.dispatchOSC ? texON : texOFF; oscConnection.dispatchOSC = GUI.Toggle(r1b, oscConnection.dispatchOSC, new GUIContent(currTex, "Turn the OSC dispatching into Unity on/off"), style); } else { GUI.contentColor = Color.white; GUI.backgroundColor = UniOSCUtils.CONNECTION_BG; //GUI.Box(area,"");//GUI.skin.box GUI.backgroundColor = UniOSCUtils.CONNECTION_OFF_COLOR; EditorGUI.HelpBox(area, "OSC IN: " + UniOSCConnection.localIPAddress + "\nPort: " + oscConnection.oscPort + "\nNot listening", MessageType.Warning); if (GUI.Button(r1, "Connect")) { oscConnection.ConnectOSC(); } } _DropArea(evt, area, oscConnection); EditorGUILayout.EndVertical(); #endregion IN if (oscConnection.oscOut) { GUILayout.Space(5f); //GUILayout.FlexibleSpace(); //OUT------------------------- EditorGUILayout.BeginVertical(GUILayout.MaxWidth(200f)); Rect area_out = GUILayoutUtility.GetRect(100.0f, 40.0f); //, GUILayout.ExpandWidth (true) area_out.width *= 1f; //0.95f; Rect r2 = GUILayoutUtility.GetRect(100.0f, 20.0f); r2.width *= 1f; //0.95f; int btnsize = 20; Rect r2b = new Rect(area_out); r2b.x += r2b.width - (btnsize * 1); r2b.y += r2b.height - btnsize; r2b.width = btnsize * 1; r2b.height = btnsize; if (oscConnection.isConnectedOut) { GUI.contentColor = Color.white; GUI.backgroundColor = oscConnection.dispatchOSCOut ? UniOSCUtils.CONNECTION_ON_COLOR : UniOSCUtils.CONNECTION_PAUSE_COLOR; EditorGUI.HelpBox(area_out, "OSC OUT: " + oscConnection.oscOutIPAddress + "\nPort: " + oscConnection.oscOutPort + "\nIs sending", MessageType.Info); //oscConnection.name+ if (GUI.Button(r2, "Disconnect")) { oscConnection.DisconnectOSCOut(); } GUI.backgroundColor = Color.white; GUI.contentColor = Color.white; //if ( GUI.Button (r2b,new GUIContent(texTestMessage,""),style ) ){oscConnection.SendTestMessage();} Texture2D currTex = oscConnection.dispatchOSCOut ? texON : texOFF; oscConnection.dispatchOSCOut = GUI.Toggle(r2b, oscConnection.dispatchOSCOut, new GUIContent(currTex, "Turn the OSC sending from Unity on/off without start/stop the network resources"), style); } else { GUI.backgroundColor = Color.red; GUI.contentColor = Color.white; EditorGUI.HelpBox(area_out, "OSC OUT: " + oscConnection.oscOutIPAddress + "\nPort: " + oscConnection.oscOutPort + "\nNot sending", MessageType.Warning); //oscConnection.name+ if (GUI.Button(r2, "Connect")) { IPAddress addr; if (UniOSCUtils.ValidateIPAddress(oscConnection.oscOutIPAddress, out addr)) { oscConnection.ConnectOSCOut(); } else { EditorUtility.DisplayDialog("Invalid IP Address", "The IPAddress you have choosen is not valid! Please use a different.", "OK"); } //oscConnection.ConnectOSCOut(); } } _DropArea(evt, area_out, oscConnection); EditorGUILayout.EndVertical(); //OUT-------------------------------- } //if(oscConnection.OSCOut){ GUI.backgroundColor = Color.white; GUI.contentColor = Color.white; EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(oscConnection); } }