fgm24/Assets/Scripts/Multiplayer/UIZDisabler.cs

35 lines
819 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using Unity.Netcode;
using UnityEngine;
public class UIZDisabler : MonoBehaviour
{
[Tooltip("enable if is [BLANK]")]
public KeepIf EnableIf = KeepIf.IsHost;
[SerializeField] private GameObject target;
private void OnEnable()
{
if (NetworkManager.Singleton == null) return;
if (EnableIf == KeepIf.IsHost && NetworkManager.Singleton.IsHost) return;
if (EnableIf == KeepIf.IsJoin && !NetworkManager.Singleton.IsHost) return;
if (EnableIf == KeepIf.IsOffline && NetworkSetup.serverType == ServerType.Offline)
target.SetActive(true);
}
// enable if is [blank]
public enum KeepIf
{
IsHost,
IsJoin,
IsOffline
}
}