31 lines
574 B
C#
31 lines
574 B
C#
|
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;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|