using System.Collections; using System.Collections.Generic; using UnityEngine; [CreateAssetMenu(fileName = "FloatSharedField", menuName = "Wavefunction/Shared Fields/Types/FloatSharedField", order = 1)] public class FloatSharedField : ScriptableObject { /// /// GameEvent that is triggered when this value is changed. /// [Tooltip("GameEvent that is triggered when this value is changed.")] [SerializeField] private GameEvent gameEvent; [SerializeField] private float value; public float Value { get { return value; } set { if(this.value != value) //if the new value is different from the previous one, raise the event. { this.value = value; if(gameEvent != null) gameEvent.Raise(); } } } /// /// Used to set a starting value to the shared field without triggering the Event. /// /// public void InitializeValue(float initValue) { this.value = initValue; } }