From 8123902c2e16f5804fa97dba0ea1ff62662beb80 Mon Sep 17 00:00:00 2001 From: miki Date: Fri, 16 Apr 2021 16:46:55 +0800 Subject: [PATCH] Fix issue the lrm inspector didn't set dirty while the value is changed --- .../Transport/LRM/Editor/LRMInspector.cs | 47 +++++++++++-------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/Editor/LRMInspector.cs b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/Editor/LRMInspector.cs index b2f9a73..143d810 100644 --- a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/Editor/LRMInspector.cs +++ b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/Editor/LRMInspector.cs @@ -194,11 +194,11 @@ namespace LightReflectiveMirror // They have completed the "setup guide" Show them the main UI // Remove unused transports... - foreach(var transport in lrm.GetComponentsInChildren()) + foreach (var transport in lrm.GetComponentsInChildren()) { - if(!(transport is LightReflectiveMirrorTransport)) + if (!(transport is LightReflectiveMirrorTransport)) { - if(transport != lrm.clientToServerTransport && (directModule == null ? true : directModule.directConnectTransport != transport)) + if (transport != lrm.clientToServerTransport && (directModule == null ? true : directModule.directConnectTransport != transport)) { if (transport.gameObject == lrm.gameObject) DestroyImmediate(transport); @@ -223,25 +223,34 @@ namespace LightReflectiveMirror switch (currentTab) { case 0: - // They are in the LRM Settings tab. - if (lrm.useLoadBalancer) + using (var change = new EditorGUI.ChangeCheckScope()) { - EditorGUILayout.HelpBox("While using a Load Balancer, you don't set the LRM node IP or port.", MessageType.Info); - GUI.enabled = false; - } - lrm.serverIP = EditorGUILayout.TextField("LRM Node IP", lrm.serverIP); - lrm.serverPort = (ushort)Mathf.Clamp(EditorGUILayout.IntField("LRM Node Port", lrm.serverPort), ushort.MinValue, ushort.MaxValue); - lrm.endpointServerPort = (ushort)Mathf.Clamp(EditorGUILayout.IntField("Endpoint Port", lrm.endpointServerPort), ushort.MinValue, ushort.MaxValue); - if (lrm.useLoadBalancer) - { - GUI.enabled = true; - } - lrm.authenticationKey = EditorGUILayout.TextField("LRM Auth Key", lrm.authenticationKey); - lrm.heartBeatInterval = EditorGUILayout.Slider("Heartbeat Time", lrm.heartBeatInterval, 0.1f, 5f); - lrm.connectOnAwake = EditorGUILayout.Toggle("Connect on Awake", lrm.connectOnAwake); - lrm.clientToServerTransport = (Transport)EditorGUILayout.ObjectField("LRM Transport", lrm.clientToServerTransport, typeof(Transport), true); + // They are in the LRM Settings tab. + if (lrm.useLoadBalancer) + { + EditorGUILayout.HelpBox("While using a Load Balancer, you don't set the LRM node IP or port.", MessageType.Info); + GUI.enabled = false; + } + lrm.serverIP = EditorGUILayout.TextField("LRM Node IP", lrm.serverIP); + lrm.serverPort = (ushort)Mathf.Clamp(EditorGUILayout.IntField("LRM Node Port", lrm.serverPort), ushort.MinValue, ushort.MaxValue); + lrm.endpointServerPort = (ushort)Mathf.Clamp(EditorGUILayout.IntField("Endpoint Port", lrm.endpointServerPort), ushort.MinValue, ushort.MaxValue); + + if (lrm.useLoadBalancer) + { + GUI.enabled = true; + } + + lrm.authenticationKey = EditorGUILayout.TextField("LRM Auth Key", lrm.authenticationKey); + lrm.heartBeatInterval = EditorGUILayout.Slider("Heartbeat Time", lrm.heartBeatInterval, 0.1f, 5f); + lrm.connectOnAwake = EditorGUILayout.Toggle("Connect on Awake", lrm.connectOnAwake); + lrm.clientToServerTransport = (Transport)EditorGUILayout.ObjectField("LRM Transport", lrm.clientToServerTransport, typeof(Transport), true); + if (change.changed) + { + EditorUtility.SetDirty(lrm); + } + } break; case 1: // NAT punch tab.