mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkIdentity.visibility: assign from Awake instead of lazy get
This commit is contained in:
parent
a10cdd6cbf
commit
8adede43a2
@ -129,19 +129,8 @@ internal set
|
||||
public NetworkBehaviour[] NetworkBehaviours { get; private set; }
|
||||
|
||||
#pragma warning disable 618
|
||||
NetworkVisibility visibilityCache;
|
||||
[Obsolete(NetworkVisibilityObsoleteMessage.Message)]
|
||||
public NetworkVisibility visibility
|
||||
{
|
||||
get
|
||||
{
|
||||
if (visibilityCache == null)
|
||||
{
|
||||
visibilityCache = GetComponent<NetworkVisibility>();
|
||||
}
|
||||
return visibilityCache;
|
||||
}
|
||||
}
|
||||
public NetworkVisibility visibility { get; private set; }
|
||||
#pragma warning restore 618
|
||||
|
||||
// current visibility
|
||||
@ -287,6 +276,11 @@ internal void Awake()
|
||||
// => doing it here is the fastest and easiest solution.
|
||||
InitializeNetworkBehaviours();
|
||||
|
||||
// initialize visibility component. only call GetComponent once.
|
||||
#pragma warning disable 618
|
||||
visibility = GetComponent<NetworkVisibility>();
|
||||
#pragma warning restore 618
|
||||
|
||||
if (hasSpawned)
|
||||
{
|
||||
Debug.LogError($"{name} has already spawned. Don't call Instantiate for NetworkIdentities that were in the scene since the beginning (aka scene objects). Otherwise the client won't know which object to use for a SpawnSceneObject message.");
|
||||
|
Loading…
Reference in New Issue
Block a user