From ac4bff6a5664bb098d0ae8bf93bb346c9ecfe647 Mon Sep 17 00:00:00 2001 From: Eric Heine <erheine@nps.edu> Date: Tue, 26 Oct 2021 14:54:38 -0700 Subject: [PATCH] Added an implicit operator to get a value from a ScriptableVariable so you don't have to type .Value when using its value. --- .../Variables/Base Types/ScriptableVariable.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Scriptable Variables/Variables/Base Types/ScriptableVariable.cs b/Scriptable Variables/Variables/Base Types/ScriptableVariable.cs index c497733..adb329e 100644 --- a/Scriptable Variables/Variables/Base Types/ScriptableVariable.cs +++ b/Scriptable Variables/Variables/Base Types/ScriptableVariable.cs @@ -21,6 +21,14 @@ namespace Shared.ScriptableVariables { public delegate void ValueChangeHandler(); public event ValueChangeHandler OnValueChanged; + //--------------------------------------------------------------------------- + public static implicit operator T(ScriptableVariable<T> sv) { + if (sv != null) { + return sv.Value; + } + return default; + } + //--------------------------------------------------------------------------- public T Value { get { return value; } -- GitLab