35 lines
591 B
C#
35 lines
591 B
C#
using Obvious.Soap;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
public class BindIntVariableToUnityEvent : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private IntVariable _IntToCheck;
|
|
|
|
[SerializeField]
|
|
private bool _CheckOnAwake;
|
|
|
|
[SerializeField]
|
|
private UnityEvent<int> OnValueChanged;
|
|
|
|
private void OnEnable()
|
|
{
|
|
if (_CheckOnAwake)
|
|
{
|
|
OnValueChanged?.Invoke(_IntToCheck.Value);
|
|
}
|
|
_IntToCheck.OnValueChanged += CheckValue;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
_IntToCheck.OnValueChanged -= CheckValue;
|
|
}
|
|
|
|
private void CheckValue(int value)
|
|
{
|
|
OnValueChanged?.Invoke(value);
|
|
}
|
|
}
|