mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
explain SetupLocalConnection order properly
This commit is contained in:
parent
cfe9520f7c
commit
892acf272c
@ -391,8 +391,30 @@ public virtual void StartHost()
|
|||||||
{
|
{
|
||||||
OnStartHost();
|
OnStartHost();
|
||||||
|
|
||||||
// SetupLocalConnection needs to be called BEFORE StartServer
|
// SetupLocalConnection needs to be called BEFORE StartServer:
|
||||||
// (https://github.com/vis2k/Mirror/pull/1249/)
|
// https://github.com/vis2k/Mirror/pull/1249/
|
||||||
|
// -> this sets NetworkServer.localConnection.
|
||||||
|
// -> localConnection needs to be set before StartServer because:
|
||||||
|
// -> StartServer calls OnStartServer
|
||||||
|
// -> OnStartServer might spawn an object and set [SyncVar(hook="OnColorChanged")] object.color = green;
|
||||||
|
// -> this calls SyncVar.set (generated by Weaver), which has
|
||||||
|
// a custom case for host mode (because host mode doesn't
|
||||||
|
// get OnDeserialize calls, where SyncVar hooks are usually
|
||||||
|
// called):
|
||||||
|
//
|
||||||
|
// if (!SyncVarEqual(value, ref color))
|
||||||
|
// {
|
||||||
|
// if (NetworkServer.localClientActive && !getSyncVarHookGuard(1uL))
|
||||||
|
// {
|
||||||
|
// setSyncVarHookGuard(1uL, value: true);
|
||||||
|
// OnColorChangedHook(value);
|
||||||
|
// setSyncVarHookGuard(1uL, value: false);
|
||||||
|
// }
|
||||||
|
// SetSyncVar(value, ref color, 1uL);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// -> localClientActive needs to be true, otherwise the hook
|
||||||
|
// isn't called in host mode!
|
||||||
NetworkClient.SetupLocalConnection();
|
NetworkClient.SetupLocalConnection();
|
||||||
if (StartServer())
|
if (StartServer())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user