2022-11-14 12:55:53 +03:00
|
|
|
using System;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2022-11-14 13:01:16 +03:00
|
|
|
namespace Syntriax.Modules.ToggleState
|
2022-11-14 12:55:53 +03:00
|
|
|
{
|
2022-11-14 13:01:16 +03:00
|
|
|
public class ToggleStateMonobehaviour : MonoBehaviour, IToggleState
|
2022-11-14 12:55:53 +03:00
|
|
|
{
|
|
|
|
private bool _toggled = true;
|
|
|
|
public bool Toggled
|
|
|
|
{
|
|
|
|
get => _toggled;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
bool oldValue = _toggled;
|
|
|
|
|
|
|
|
_toggled = value;
|
|
|
|
|
|
|
|
if (oldValue = !value)
|
|
|
|
OnToggleStateChanged?.Invoke(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Action<bool> OnToggleStateChanged { get; set; } = null;
|
|
|
|
}
|
|
|
|
}
|