fgm24/Assets/Scripts/Multiplayer/UIZDisabler.cs

32 lines
736 B
C#
Raw Normal View History

2024-03-04 17:41:37 +01:00
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using Unity.Netcode;
using UnityEngine;
public class UIZDisabler : MonoBehaviour
{
[Tooltip("Keep enabled if is [BLANK]")]
public KeepIf KeepEnabledIf = KeepIf.IsHost;
[SerializeField] private GameObject target;
private void OnEnable()
{
if (NetworkManager.Singleton == null) return;
if (KeepEnabledIf == KeepIf.IsHost && NetworkManager.Singleton.IsHost) return;
if (KeepEnabledIf == KeepIf.IsJoin && !NetworkManager.Singleton.IsHost) return;
target.SetActive(false);
}
// Keep enabled if is [blank]
public enum KeepIf
{
IsHost,
IsJoin
}
}