WinterJamSnowman/Assets/Scripts/LemonGenericLib/Generic Classes/Optional.cs

31 lines
574 B
C#
Raw Normal View History

2023-01-24 13:51:46 +00:00
using System;
using UnityEngine;
namespace Lemon.GenericLib.Generics
{
[Serializable]
public struct Optional<T>
{
[SerializeField] private bool enabled;
[SerializeField] private T value;
public bool Enabled => enabled;
public T Value => value;
public Optional(T initialValue)
{
enabled = true;
value = initialValue;
}
public void Set(T initialValue)
{
if (enabled)
{
value = initialValue;
}
}
}
}