31 lines
587 B
C#
31 lines
587 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, bool start)
|
|
{
|
|
enabled = start;
|
|
value = initialValue;
|
|
}
|
|
public void Set(T initialValue)
|
|
{
|
|
if (enabled)
|
|
{
|
|
value = initialValue;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
} |