39 lines
1017 B
C#
39 lines
1017 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace BrewMonster
|
|
{
|
|
/// <summary>
|
|
/// Wires a UI <see cref="Button"/> to <see cref="CameraController.ToggleViewLocked"/>.
|
|
/// Add to the same GameObject as the button or assign the reference in the Inspector.
|
|
/// </summary>
|
|
public class CameraViewLockButton : MonoBehaviour
|
|
{
|
|
[SerializeField] private Button lockToggleButton;
|
|
|
|
private void OnEnable()
|
|
{
|
|
if (lockToggleButton != null)
|
|
{
|
|
lockToggleButton.onClick.AddListener(OnLockButtonClicked);
|
|
}
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
if (lockToggleButton != null)
|
|
{
|
|
lockToggleButton.onClick.RemoveListener(OnLockButtonClicked);
|
|
}
|
|
}
|
|
|
|
private void OnLockButtonClicked()
|
|
{
|
|
if (CameraController.Instance != null)
|
|
{
|
|
CameraController.Instance.ToggleViewLocked();
|
|
}
|
|
}
|
|
}
|
|
}
|