using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class OnInstanceFinder : MonoBehaviour { [SerializeField] private Button backButton; private void Start() { backButton.onClick.AddListener(CloseMenu); } private void OnEnable() { if (Player.Instance != null && !UIManager.Instance.loginScreen) { Player.Instance.updatePlayer = false; Player.Instance.OnlyCastPlayerShadows(false); Player.Instance.LockCursor(false); } } private void CloseMenu() { if (Player.Instance != null) { UIManager.Instance.hideInterface(gameObject.name); Player.Instance.UpdatePlayerOnMenuClose(); Player.Instance.OnlyCastPlayerShadows(true); } } private void OnDisable() { if (gameObject.scene.isLoaded) { if (!UIManager.Instance.loginScreen) { if (Player.Instance != null) { Player.Instance.UpdatePlayerOnMenuClose(); Player.Instance.OnlyCastPlayerShadows(true); } } } } }