-
Notifications
You must be signed in to change notification settings - Fork 461
fix: reset static fields for Fast Enter Play Mode #3956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop-2.0.0
Are you sure you want to change the base?
Changes from 4 commits
c6f0d4b
702bb73
8dabded
aa33ed6
5ab98dc
69dce92
638855f
4cbec9b
0ecf34c
e65351c
551b989
689ecd2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,10 @@ public static class QuaternionCompressor | |
|
|
||
| // Used to store the absolute value of the 4 quaternion elements | ||
| private static Quaternion s_QuatAbsValues = Quaternion.identity; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace quaternion by 4 ints |
||
| #if UNITY_EDITOR | ||
| [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] | ||
| private static void ResetStaticsOnLoad() => s_QuatAbsValues = Quaternion.identity; | ||
| #endif | ||
|
|
||
| /// <summary> | ||
| /// Compresses a Quaternion into an unsigned integer | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| #if UNITY_EDITOR | ||
| using UnityEngine; | ||
| #endif | ||
|
Comment on lines
+3
to
+5
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this, add UnityEngine.Runtime... |
||
|
|
||
| namespace Unity.Netcode | ||
| { | ||
|
|
@@ -14,6 +17,10 @@ internal static class ComponentFactory | |
| internal delegate object CreateObjectDelegate(NetworkManager networkManager); | ||
|
|
||
| private static Dictionary<Type, CreateObjectDelegate> s_Delegates = new Dictionary<Type, CreateObjectDelegate>(); | ||
| #if UNITY_EDITOR | ||
| [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] | ||
| private static void ResetStaticsOnLoad() => s_Delegates = new Dictionary<Type, CreateObjectDelegate>(); | ||
| #endif | ||
|
|
||
| /// <summary> | ||
| /// Instantiates an instance of a given interface | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1809,6 +1809,19 @@ internal abstract class NetcodeAnalytics | |
| internal delegate void ResetNetworkManagerDelegate(NetworkManager manager); | ||
|
|
||
| internal static ResetNetworkManagerDelegate OnNetworkManagerReset; | ||
| //We already are in an #if UNITY_ENGINE def | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this comment |
||
| [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] | ||
| private static void ResetStaticsOnLoad() | ||
| { | ||
| Singleton = null; | ||
| OnInstantiated = null; | ||
| OnDestroying = null; | ||
| OnSingletonReady = null; | ||
| OnNetworkManagerReset = null; | ||
| IsDistributedAuthority = false; | ||
| s_SerializedType = new List<Type>(); | ||
| DisableNotOptimizedSerializedType = false; | ||
| } | ||
|
|
||
| private void Reset() | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add xml doc with: |
||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -291,6 +291,16 @@ public static PlayerLoopSystem CreateLoopSystem() | |
| [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] | ||
| private static void Initialize() | ||
| { | ||
| #if UNITY_EDITOR | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add comment //Reset Statics |
||
| s_UpdateSystem_Sets = new Dictionary<NetworkUpdateStage, HashSet<INetworkUpdateSystem>>(); | ||
| s_UpdateSystem_Arrays = new Dictionary<NetworkUpdateStage, INetworkUpdateSystem[]>(); | ||
| foreach (NetworkUpdateStage updateStage in Enum.GetValues(typeof(NetworkUpdateStage))) | ||
| { | ||
| s_UpdateSystem_Sets.Add(updateStage, new HashSet<INetworkUpdateSystem>()); | ||
| s_UpdateSystem_Arrays.Add(updateStage, new INetworkUpdateSystem[k_UpdateSystem_InitialArrayCapacity]); | ||
| } | ||
| UpdateStage = default; | ||
| #endif | ||
| UnregisterLoopSystems(); | ||
| RegisterLoopSystems(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| using System.Collections.Generic; | ||
| using Unity.Collections; | ||
| #if UNITY_EDITOR | ||
| using UnityEngine; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move it down to use UnityEngine.Runtime... |
||
| #endif | ||
|
|
||
| namespace Unity.Netcode | ||
| { | ||
|
|
@@ -96,6 +99,10 @@ public virtual unsafe void CleanupStaleTriggers() | |
| /// Used for testing purposes | ||
| /// </summary> | ||
| internal static bool IncludeMessageType = true; | ||
| #if UNITY_EDITOR | ||
| [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] | ||
| private static void ResetStaticsOnLoad() => IncludeMessageType = true; | ||
| #endif | ||
|
|
||
| private string GetWarningMessage(IDeferredNetworkMessageManager.TriggerType triggerType, ulong key, TriggerInfo triggerInfo, float spawnTimeout) | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
|
|
||
| namespace Unity.Netcode | ||
| { | ||
| /// <summary> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this at the top