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

31 lines
587 B
C#
Raw Permalink 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;
2023-01-29 06:57:08 +00:00
public Optional(T initialValue, bool start)
2023-01-24 13:51:46 +00:00
{
2023-01-29 06:57:08 +00:00
enabled = start;
2023-01-24 13:51:46 +00:00
value = initialValue;
}
public void Set(T initialValue)
{
if (enabled)
{
value = initialValue;
}
}
}
}