fgm24/Assets/Scripts/Multiplayer/UIZDisabler.cs

35 lines
819 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("enable if is [BLANK]")]
public KeepIf EnableIf = KeepIf.IsHost;
2024-03-04 17:41:37 +01:00
[SerializeField] private GameObject target;
private void OnEnable()
{
if (NetworkManager.Singleton == null) return;
if (EnableIf == KeepIf.IsHost && NetworkManager.Singleton.IsHost) return;
2024-03-04 17:41:37 +01:00
if (EnableIf == KeepIf.IsJoin && !NetworkManager.Singleton.IsHost) return;
2024-03-04 17:41:37 +01:00
if (EnableIf == KeepIf.IsOffline && NetworkSetup.serverType == ServerType.Offline)
target.SetActive(true);
2024-03-04 17:41:37 +01:00
}
// enable if is [blank]
2024-03-04 17:41:37 +01:00
public enum KeepIf
{
IsHost,
IsJoin,
IsOffline
2024-03-04 17:41:37 +01:00
}
}