31 lines
831 B
C#
31 lines
831 B
C#
using UnityEngine;
|
|
using Ashwild.Settings;
|
|
|
|
namespace Ashwild.UI
|
|
{
|
|
public class CrosshairController : MonoBehaviour
|
|
{
|
|
[SerializeField] private GameObject crosshairRoot;
|
|
|
|
private void OnEnable()
|
|
{
|
|
if (SettingsManager.Instance != null)
|
|
SettingsManager.Instance.onSettingsChanged.AddListener(Apply);
|
|
Apply();
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
if (SettingsManager.Instance != null)
|
|
SettingsManager.Instance.onSettingsChanged.RemoveListener(Apply);
|
|
}
|
|
|
|
private void Apply()
|
|
{
|
|
if (crosshairRoot == null) return;
|
|
bool enabled = SettingsManager.Instance == null || SettingsManager.Instance.CrosshairEnabled;
|
|
crosshairRoot.SetActive(enabled);
|
|
}
|
|
}
|
|
}
|