per NI WIP

This commit is contained in:
miwarnec 2024-10-31 17:24:26 +01:00
parent 69d9aa2ff0
commit 4bebec8173

View File

@ -3,6 +3,7 @@
using System.Runtime.CompilerServices;
using Mirror.RemoteCalls;
using UnityEngine;
using UnityEngine.Profiling;
using UnityEngine.Serialization;
#if UNITY_EDITOR
@ -936,6 +937,8 @@ internal static bool IsDirty(ulong mask, int index)
// check ownerWritten/observersWritten to know if anything was written
internal void SerializeServer(bool initialState, NetworkWriter ownerWriter, NetworkWriter observersWriter)
{
// profiling marker for shallow profiling to show more than "UpdateFunction.Invoke
Profiler.BeginSample($"NetworkIdentity({name}): SerializeServer"); // TODO nonalloc
// ensure NetworkBehaviours are valid before usage
ValidateComponents();
NetworkBehaviour[] components = NetworkBehaviours;
@ -1004,11 +1007,16 @@ internal void SerializeServer(bool initialState, NetworkWriter ownerWriter, Netw
}
}
}
Profiler.EndSample();
}
// serialize components into writer on the client.
internal void SerializeClient(NetworkWriter writer)
{
// profiling marker for shallow profiling to show more than "UpdateFunction.Invoke
Profiler.BeginSample($"NetworkIdentity({name}): SerializeClient"); // TODO nonalloc
// ensure NetworkBehaviours are valid before usage
ValidateComponents();
NetworkBehaviour[] components = NetworkBehaviours;
@ -1061,6 +1069,8 @@ internal void SerializeClient(NetworkWriter writer)
}
}
}
Profiler.EndSample();
}
// deserialize components from the client on the server.