Upgraded ZDisabler with support of IsServer
This commit is contained in:
parent
a706cd7e45
commit
8b60e45bab
|
@ -5,13 +5,19 @@ using UnityEngine;
|
|||
|
||||
public class ZDisablerV2 : NetworkBehaviour
|
||||
{
|
||||
[Tooltip("Keep enabled if is [BLANK]")]
|
||||
public KeepIf KeepEnabledIf = KeepIf.IsOwner;
|
||||
[Tooltip("Add all the objects to disable on join, if not owner")]
|
||||
public UnityEngine.Object[] objectsToDisable;
|
||||
|
||||
public override void OnNetworkSpawn()
|
||||
{
|
||||
// Run if networked
|
||||
if (NetworkManager.Singleton == null || IsOwner) return;
|
||||
if (NetworkManager.Singleton == null) return;
|
||||
|
||||
if (KeepEnabledIf == KeepIf.IsOwner && IsOwner) return;
|
||||
|
||||
if (KeepEnabledIf == KeepIf.IsServer && IsServer) return;
|
||||
|
||||
for (int i = 0; i < objectsToDisable.Length; i++)
|
||||
{
|
||||
|
@ -37,4 +43,11 @@ public class ZDisablerV2 : NetworkBehaviour
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Keep enabled if is [blank]
|
||||
public enum KeepIf
|
||||
{
|
||||
IsServer,
|
||||
IsOwner
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue