A struct useful for showing in the inspector if the value is optional, and does not have to be set. Also allows for quicker checks if the value is set
More...
A struct useful for showing in the inspector if the value is optional, and does not have to be set. Also allows for quicker checks if the value is set
namespace Example
{
public class OptionalExample : MonoBehaviour
{
[SerializeField]
private Optional<HealthComponent> _healthComponent;
private void Start()
{
HealthComponent hc = _healthComponent ? _healthComponent : GetComponent<HealthComponent>();
hc.Damage(10);
}
}
}
Optional(T initialValue)
Definition: Optional.cs:34