39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[CreateAssetMenu(fileName = "StringSharedField", menuName = "Wavefunction/Shared Fields/Types/StringSharedField", order = 1)]
|
|
public class StringSharedField : ScriptableObject
|
|
{
|
|
/// <summary>
|
|
/// GameEvent that is triggered when this value is changed.
|
|
/// </summary>
|
|
[Tooltip("GameEvent that is triggered when this value is changed.")]
|
|
[SerializeField] private GameEvent gameEvent;
|
|
|
|
|
|
[SerializeField] private string value;
|
|
public string 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();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Used to set a starting value to the shared field without triggering the Event.
|
|
/// </summary>
|
|
/// <param name="initValue"></param>
|
|
public void InitializeValue(string initValue)
|
|
{
|
|
this.value = initValue;
|
|
}
|
|
}
|