From 66c9f71462488f6c340a2e30fd6eaffb44bd66b6 Mon Sep 17 00:00:00 2001 From: James Frowen Date: Mon, 25 Mar 2024 22:05:05 +0000 Subject: [PATCH] refactor: removing convert code from NetworkInspectorCallbacks --- .../NetworkIdentityInspectorCallbacks.cs | 52 ------------------- 1 file changed, 52 deletions(-) diff --git a/Assets/Mirage/Runtime/NetworkIdentityInspectorCallbacks.cs b/Assets/Mirage/Runtime/NetworkIdentityInspectorCallbacks.cs index b5067d066b..b3b5814571 100644 --- a/Assets/Mirage/Runtime/NetworkIdentityInspectorCallbacks.cs +++ b/Assets/Mirage/Runtime/NetworkIdentityInspectorCallbacks.cs @@ -26,57 +26,5 @@ private void Awake() Identity.OnStopClient.AddListener(_onStopClient.Invoke); Identity.OnStopServer.AddListener(_onStopServer.Invoke); } - - -#if UNITY_EDITOR - public void Convert() - { - _onStartServer = GetAndClear(nameof(_onStartServer)); - _onStartClient = GetAndClear(nameof(_onStartClient)); - _onStartLocalPlayer = GetAndClear(nameof(_onStartLocalPlayer)); - _onAuthorityChanged = GetAndClear(nameof(_onAuthorityChanged)); - _onOwnerChanged = GetAndClear(nameof(_onOwnerChanged)); - _onStopClient = GetAndClear(nameof(_onStopClient)); - _onStopServer = GetAndClear(nameof(_onStopServer)); - - UnityEditor.EditorUtility.SetDirty(this); - UnityEditor.EditorUtility.SetDirty(Identity); - - if (Identity.gameObject.scene.IsValid()) - { - UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(Identity.gameObject.scene); - } - } - - private T GetAndClear(string field) where T : new() - { - var type = typeof(NetworkIdentity); - var flags = System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic; - var info = type.GetField(field, flags); - var value = (T)info.GetValue(Identity); - info.SetValue(Identity, new T()); - return value; - } -#endif - } -} - -#if UNITY_EDITOR -namespace Mirage.EditorScripts -{ - [UnityEditor.CustomEditor(typeof(NetworkInspectorCallbacks))] - public class NetworkInspectorCallbacksEditor : UnityEditor.Editor - { - public override void OnInspectorGUI() - { - DrawDefaultInspector(); - - var target = (NetworkInspectorCallbacks)base.target; - if (GUILayout.Button("Move Identity events")) - { - target.Convert(); - } - } } } -#endif