|
6 | 6 | using UnityEngine.SceneManagement; |
7 | 7 | using UnityEngine.Rendering; |
8 | 8 | using UnityEngine.Serialization; |
| 9 | +using UnityEngine.Events; |
| 10 | + |
9 | 11 | #if UNITY_EDITOR |
10 | 12 | using UnityEditor; |
11 | 13 | using UnityEditor.SceneManagement; |
@@ -66,7 +68,8 @@ public sealed class LiteNetLibIdentity : MonoBehaviour |
66 | 68 | private bool muteAudioSourceWhileHidding = true; |
67 | 69 | #endif |
68 | 70 |
|
69 | | - public System.Action onGetInstance; |
| 71 | + public UnityEvent onGetInstance = new UnityEvent(); |
| 72 | + public UnityEvent onPushBack = new UnityEvent(); |
70 | 73 | public ConnectionEventDelegate onSubscriberAdded; |
71 | 74 | public ConnectionEventDelegate onSubscriberRemoved; |
72 | 75 | public System.Action onServerSubscribingAdded; |
@@ -952,7 +955,12 @@ internal void OnNetworkDestroy(byte reasons) |
952 | 955 | internal void OnGetInstance() |
953 | 956 | { |
954 | 957 | ResetSyncData(); |
955 | | - onGetInstance?.Invoke(); |
| 958 | + onGetInstance.Invoke(); |
| 959 | + } |
| 960 | + |
| 961 | + internal void OnPushBack() |
| 962 | + { |
| 963 | + onPushBack.Invoke(); |
956 | 964 | } |
957 | 965 |
|
958 | 966 | internal void ResetSyncData() |
@@ -981,7 +989,10 @@ private void OnDestroy() |
981 | 989 | { |
982 | 990 | syncElement.UnregisterUpdating(); |
983 | 991 | } |
| 992 | + onGetInstance?.RemoveAllListeners(); |
984 | 993 | onGetInstance = null; |
| 994 | + onPushBack?.RemoveAllListeners(); |
| 995 | + onPushBack = null; |
985 | 996 | onSubscriberAdded = null; |
986 | 997 | onSubscriberRemoved = null; |
987 | 998 | onServerSubscribingAdded = null; |
|
0 commit comments