From 63dadcb4579b979cf4c08ec9b12ac0ba4d35502f Mon Sep 17 00:00:00 2001 From: Christopher Date: Mon, 22 Aug 2016 11:26:30 +0100 Subject: [PATCH] Refactored Variable base class to use protected serialised value and public property accessor. --- .../Scripts/Commands/InvokeMethod.cs | 48 +++++++++---------- .../Scripts/Commands/LoadVariable.cs | 8 ++-- .../Flowchart/Scripts/Commands/RandomFloat.cs | 2 +- .../Scripts/Commands/RandomInteger.cs | 2 +- .../Scripts/Commands/ReadTextFile.cs | 2 +- .../Scripts/Commands/SaveVariable.cs | 8 ++-- .../Flowchart/Scripts/Commands/SetVariable.cs | 26 +++++----- Assets/Fungus/Flowchart/Scripts/Flowchart.cs | 16 +++---- Assets/Fungus/Flowchart/Scripts/Variable.cs | 10 ++-- .../Scripts/VariableTypes/AnimatorVariable.cs | 4 +- .../VariableTypes/AudioSourceVariable.cs | 4 +- .../Scripts/VariableTypes/BooleanVariable.cs | 6 +-- .../Scripts/VariableTypes/ColorVariable.cs | 4 +- .../Scripts/VariableTypes/FloatVariable.cs | 6 +-- .../VariableTypes/GameObjectVariable.cs | 4 +- .../Scripts/VariableTypes/IntegerVariable.cs | 6 +-- .../Scripts/VariableTypes/MaterialVariable.cs | 4 +- .../Scripts/VariableTypes/ObjectVariable.cs | 4 +- .../Scripts/VariableTypes/SpriteVariable.cs | 4 +- .../Scripts/VariableTypes/StringVariable.cs | 10 ++-- .../Scripts/VariableTypes/TextureVariable.cs | 4 +- .../VariableTypes/TransformVariable.cs | 4 +- .../Scripts/VariableTypes/Vector2Variable.cs | 4 +- .../Scripts/VariableTypes/Vector3Variable.cs | 4 +- .../Fungus/Lua/Scripts/Commands/ExecuteLua.cs | 24 +++++----- Assets/Fungus/UI/Scripts/Commands/GetText.cs | 6 +-- Assets/Tests/Scripting/TestInvoke.cs | 8 ++-- 27 files changed, 117 insertions(+), 115 deletions(-) diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs b/Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs index 73715a70..3233c953 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs @@ -200,62 +200,62 @@ namespace Fungus case "System.Int32": var intvalue = flowChart.GetVariable(item.variableKey); if (intvalue != null) - objValue = intvalue.value; + objValue = intvalue.Value; break; case "System.Boolean": var boolean = flowChart.GetVariable(item.variableKey); if (boolean != null) - objValue = boolean.value; + objValue = boolean.Value; break; case "System.Single": var floatvalue = flowChart.GetVariable(item.variableKey); if (floatvalue != null) - objValue = floatvalue.value; + objValue = floatvalue.Value; break; case "System.String": var stringvalue = flowChart.GetVariable(item.variableKey); if (stringvalue != null) - objValue = stringvalue.value; + objValue = stringvalue.Value; break; case "UnityEngine.Color": var color = flowChart.GetVariable(item.variableKey); if (color != null) - objValue = color.value; + objValue = color.Value; break; case "UnityEngine.GameObject": var gameObject = flowChart.GetVariable(item.variableKey); if (gameObject != null) - objValue = gameObject.value; + objValue = gameObject.Value; break; case "UnityEngine.Material": var material = flowChart.GetVariable(item.variableKey); if (material != null) - objValue = material.value; + objValue = material.Value; break; case "UnityEngine.Sprite": var sprite = flowChart.GetVariable(item.variableKey); if (sprite != null) - objValue = sprite.value; + objValue = sprite.Value; break; case "UnityEngine.Texture": var texture = flowChart.GetVariable(item.variableKey); if (texture != null) - objValue = texture.value; + objValue = texture.Value; break; case "UnityEngine.Vector2": var vector2 = flowChart.GetVariable(item.variableKey); if (vector2 != null) - objValue = vector2.value; + objValue = vector2.Value; break; case "UnityEngine.Vector3": var vector3 = flowChart.GetVariable(item.variableKey); if (vector3 != null) - objValue = vector3.value; + objValue = vector3.Value; break; default: var obj = flowChart.GetVariable(item.variableKey); if (obj != null) - objValue = obj.value; + objValue = obj.Value; break; } @@ -273,40 +273,40 @@ namespace Fungus switch (returnType) { case "System.Int32": - flowChart.GetVariable(key).value = (int)value; + flowChart.GetVariable(key).Value = (int)value; break; case "System.Boolean": - flowChart.GetVariable(key).value = (bool)value; + flowChart.GetVariable(key).Value = (bool)value; break; case "System.Single": - flowChart.GetVariable(key).value = (float)value; + flowChart.GetVariable(key).Value = (float)value; break; case "System.String": - flowChart.GetVariable(key).value = (string)value; + flowChart.GetVariable(key).Value = (string)value; break; case "UnityEngine.Color": - flowChart.GetVariable(key).value = (UnityEngine.Color)value; + flowChart.GetVariable(key).Value = (UnityEngine.Color)value; break; case "UnityEngine.GameObject": - flowChart.GetVariable(key).value = (UnityEngine.GameObject)value; + flowChart.GetVariable(key).Value = (UnityEngine.GameObject)value; break; case "UnityEngine.Material": - flowChart.GetVariable(key).value = (UnityEngine.Material)value; + flowChart.GetVariable(key).Value = (UnityEngine.Material)value; break; case "UnityEngine.Sprite": - flowChart.GetVariable(key).value = (UnityEngine.Sprite)value; + flowChart.GetVariable(key).Value = (UnityEngine.Sprite)value; break; case "UnityEngine.Texture": - flowChart.GetVariable(key).value = (UnityEngine.Texture)value; + flowChart.GetVariable(key).Value = (UnityEngine.Texture)value; break; case "UnityEngine.Vector2": - flowChart.GetVariable(key).value = (UnityEngine.Vector2)value; + flowChart.GetVariable(key).Value = (UnityEngine.Vector2)value; break; case "UnityEngine.Vector3": - flowChart.GetVariable(key).value = (UnityEngine.Vector3)value; + flowChart.GetVariable(key).Value = (UnityEngine.Vector3)value; break; default: - flowChart.GetVariable(key).value = (UnityEngine.Object)value; + flowChart.GetVariable(key).Value = (UnityEngine.Object)value; break; } } diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/LoadVariable.cs b/Assets/Fungus/Flowchart/Scripts/Commands/LoadVariable.cs index e93d6e3a..6b6e52e9 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/LoadVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/LoadVariable.cs @@ -47,7 +47,7 @@ namespace Fungus if (booleanVariable != null) { // PlayerPrefs does not have bool accessors, so just use int - booleanVariable.value = (PlayerPrefs.GetInt(prefsKey) == 1); + booleanVariable.Value = (PlayerPrefs.GetInt(prefsKey) == 1); } } else if (variableType == typeof(IntegerVariable)) @@ -55,7 +55,7 @@ namespace Fungus IntegerVariable integerVariable = variable as IntegerVariable; if (integerVariable != null) { - integerVariable.value = PlayerPrefs.GetInt(prefsKey); + integerVariable.Value = PlayerPrefs.GetInt(prefsKey); } } else if (variableType == typeof(FloatVariable)) @@ -63,7 +63,7 @@ namespace Fungus FloatVariable floatVariable = variable as FloatVariable; if (floatVariable != null) { - floatVariable.value = PlayerPrefs.GetFloat(prefsKey); + floatVariable.Value = PlayerPrefs.GetFloat(prefsKey); } } else if (variableType == typeof(StringVariable)) @@ -71,7 +71,7 @@ namespace Fungus StringVariable stringVariable = variable as StringVariable; if (stringVariable != null) { - stringVariable.value = PlayerPrefs.GetString(prefsKey); + stringVariable.Value = PlayerPrefs.GetString(prefsKey); } } diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/RandomFloat.cs b/Assets/Fungus/Flowchart/Scripts/Commands/RandomFloat.cs index 670268c6..cf16f8bd 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/RandomFloat.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/RandomFloat.cs @@ -28,7 +28,7 @@ namespace Fungus { if (variable != null) { - variable.value = Random.Range(minValue.Value, maxValue.Value); + variable.Value = Random.Range(minValue.Value, maxValue.Value); } Continue(); diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/RandomInteger.cs b/Assets/Fungus/Flowchart/Scripts/Commands/RandomInteger.cs index c0b20112..4a077ac5 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/RandomInteger.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/RandomInteger.cs @@ -28,7 +28,7 @@ namespace Fungus { if (variable != null) { - variable.value = Random.Range(minValue.Value, maxValue.Value); + variable.Value = Random.Range(minValue.Value, maxValue.Value); } Continue(); diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/ReadTextFile.cs b/Assets/Fungus/Flowchart/Scripts/Commands/ReadTextFile.cs index e4b4fe2a..0c9a8948 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/ReadTextFile.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/ReadTextFile.cs @@ -31,7 +31,7 @@ namespace Fungus return; } - stringVariable.value = textFile.text; + stringVariable.Value = textFile.text; Continue(); } diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/SaveVariable.cs b/Assets/Fungus/Flowchart/Scripts/Commands/SaveVariable.cs index c95f1a5a..7f9fd22d 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/SaveVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/SaveVariable.cs @@ -49,7 +49,7 @@ namespace Fungus if (booleanVariable != null) { // PlayerPrefs does not have bool accessors, so just use int - PlayerPrefs.SetInt(prefsKey, booleanVariable.value ? 1 : 0); + PlayerPrefs.SetInt(prefsKey, booleanVariable.Value ? 1 : 0); } } else if (variableType == typeof(IntegerVariable)) @@ -57,7 +57,7 @@ namespace Fungus IntegerVariable integerVariable = variable as IntegerVariable; if (integerVariable != null) { - PlayerPrefs.SetInt(prefsKey, integerVariable.value); + PlayerPrefs.SetInt(prefsKey, integerVariable.Value); } } else if (variableType == typeof(FloatVariable)) @@ -65,7 +65,7 @@ namespace Fungus FloatVariable floatVariable = variable as FloatVariable; if (floatVariable != null) { - PlayerPrefs.SetFloat(prefsKey, floatVariable.value); + PlayerPrefs.SetFloat(prefsKey, floatVariable.Value); } } else if (variableType == typeof(StringVariable)) @@ -73,7 +73,7 @@ namespace Fungus StringVariable stringVariable = variable as StringVariable; if (stringVariable != null) { - PlayerPrefs.SetString(prefsKey, stringVariable.value); + PlayerPrefs.SetString(prefsKey, stringVariable.Value); } } diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs b/Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs index 3805a214..1979a133 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs @@ -133,10 +133,10 @@ namespace Fungus { default: case SetOperator.Assign: - lhs.value = rhs; + lhs.Value = rhs; break; case SetOperator.Negate: - lhs.value = !rhs; + lhs.Value = !rhs; break; } } @@ -149,19 +149,19 @@ namespace Fungus { default: case SetOperator.Assign: - lhs.value = rhs; + lhs.Value = rhs; break; case SetOperator.Add: - lhs.value += rhs; + lhs.Value += rhs; break; case SetOperator.Subtract: - lhs.value -= rhs; + lhs.Value -= rhs; break; case SetOperator.Multiply: - lhs.value *= rhs; + lhs.Value *= rhs; break; case SetOperator.Divide: - lhs.value /= rhs; + lhs.Value /= rhs; break; } } @@ -174,19 +174,19 @@ namespace Fungus { default: case SetOperator.Assign: - lhs.value = rhs; + lhs.Value = rhs; break; case SetOperator.Add: - lhs.value += rhs; + lhs.Value += rhs; break; case SetOperator.Subtract: - lhs.value -= rhs; + lhs.Value -= rhs; break; case SetOperator.Multiply: - lhs.value *= rhs; + lhs.Value *= rhs; break; case SetOperator.Divide: - lhs.value /= rhs; + lhs.Value /= rhs; break; } } @@ -199,7 +199,7 @@ namespace Fungus { default: case SetOperator.Assign: - lhs.value = rhs; + lhs.Value = rhs; break; } } diff --git a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs index 63a08506..b401398d 100644 --- a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs +++ b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs @@ -767,7 +767,7 @@ namespace Fungus if(variable != null) { - return GetVariable(key).value; + return GetVariable(key).Value; } else { @@ -784,7 +784,7 @@ namespace Fungus BooleanVariable variable = GetVariable(key); if(variable != null) { - variable.value = value; + variable.Value = value; } } @@ -798,7 +798,7 @@ namespace Fungus if (variable != null) { - return GetVariable(key).value; + return GetVariable(key).Value; } else { @@ -815,7 +815,7 @@ namespace Fungus IntegerVariable variable = GetVariable(key); if (variable != null) { - variable.value = value; + variable.Value = value; } } @@ -829,7 +829,7 @@ namespace Fungus if (variable != null) { - return GetVariable(key).value; + return GetVariable(key).Value; } else { @@ -846,7 +846,7 @@ namespace Fungus FloatVariable variable = GetVariable(key); if (variable != null) { - variable.value = value; + variable.Value = value; } } @@ -860,7 +860,7 @@ namespace Fungus if (variable != null) { - return GetVariable(key).value; + return GetVariable(key).Value; } else { @@ -877,7 +877,7 @@ namespace Fungus StringVariable variable = GetVariable(key); if (variable != null) { - variable.value = value; + variable.Value = value; } } diff --git a/Assets/Fungus/Flowchart/Scripts/Variable.cs b/Assets/Fungus/Flowchart/Scripts/Variable.cs index 2b6f6d17..56886bef 100644 --- a/Assets/Fungus/Flowchart/Scripts/Variable.cs +++ b/Assets/Fungus/Flowchart/Scripts/Variable.cs @@ -64,24 +64,26 @@ namespace Fungus public abstract class VariableBase : Variable { - public T value; + [SerializeField] protected T value; + + public T Value { get { return this.value; } set { this.value = value; } } protected T startValue; public override void OnReset() { - value = startValue; + Value = startValue; } public override string ToString() { - return value.ToString(); + return Value.ToString(); } protected virtual void Start() { // Remember the initial value so we can reset later on - startValue = value; + startValue = Value; } } } diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/AnimatorVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/AnimatorVariable.cs index 96759529..6393c7a2 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/AnimatorVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/AnimatorVariable.cs @@ -37,8 +37,8 @@ namespace Fungus public Animator Value { - get { return (animatorRef == null) ? animatorVal : animatorRef.value; } - set { if (animatorRef == null) { animatorVal = value; } else { animatorRef.value = value; } } + get { return (animatorRef == null) ? animatorVal : animatorRef.Value; } + set { if (animatorRef == null) { animatorVal = value; } else { animatorRef.Value = value; } } } public string GetDescription() diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/AudioSourceVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/AudioSourceVariable.cs index 439f97c4..138af1ec 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/AudioSourceVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/AudioSourceVariable.cs @@ -37,8 +37,8 @@ namespace Fungus public AudioSource Value { - get { return (audioSourceRef == null) ? audioSourceVal : audioSourceRef.value; } - set { if (audioSourceRef == null) { audioSourceVal = value; } else { audioSourceRef.value = value; } } + get { return (audioSourceRef == null) ? audioSourceVal : audioSourceRef.Value; } + set { if (audioSourceRef == null) { audioSourceVal = value; } else { audioSourceRef.Value = value; } } } public string GetDescription() diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/BooleanVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/BooleanVariable.cs index cdd752d2..f8ada5c2 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/BooleanVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/BooleanVariable.cs @@ -19,7 +19,7 @@ namespace Fungus { bool condition = false; - bool lhs = value; + bool lhs = Value; bool rhs = booleanValue; switch (compareOperator) @@ -61,8 +61,8 @@ namespace Fungus public bool Value { - get { return (booleanRef == null) ? booleanVal : booleanRef.value; } - set { if (booleanRef == null) { booleanVal = value; } else { booleanRef.value = value; } } + get { return (booleanRef == null) ? booleanVal : booleanRef.Value; } + set { if (booleanRef == null) { booleanVal = value; } else { booleanRef.Value = value; } } } public string GetDescription() diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/ColorVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/ColorVariable.cs index 40c802c0..560b3455 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/ColorVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/ColorVariable.cs @@ -37,8 +37,8 @@ namespace Fungus public Color Value { - get { return (colorRef == null) ? colorVal : colorRef.value; } - set { if (colorRef == null) { colorVal = value; } else { colorRef.value = value; } } + get { return (colorRef == null) ? colorVal : colorRef.Value; } + set { if (colorRef == null) { colorVal = value; } else { colorRef.Value = value; } } } public string GetDescription() diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/FloatVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/FloatVariable.cs index 09a9a953..a1a982d0 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/FloatVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/FloatVariable.cs @@ -15,7 +15,7 @@ namespace Fungus { public virtual bool Evaluate(CompareOperator compareOperator, float floatValue) { - float lhs = value; + float lhs = Value; float rhs = floatValue; bool condition = false; @@ -69,8 +69,8 @@ namespace Fungus public float Value { - get { return (floatRef == null) ? floatVal : floatRef.value; } - set { if (floatRef == null) { floatVal = value; } else { floatRef.value = value; } } + get { return (floatRef == null) ? floatVal : floatRef.Value; } + set { if (floatRef == null) { floatVal = value; } else { floatRef.Value = value; } } } public string GetDescription() diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/GameObjectVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/GameObjectVariable.cs index f6fa5d3f..0c2f9707 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/GameObjectVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/GameObjectVariable.cs @@ -37,8 +37,8 @@ namespace Fungus public GameObject Value { - get { return (gameObjectRef == null) ? gameObjectVal : gameObjectRef.value; } - set { if (gameObjectRef == null) { gameObjectVal = value; } else { gameObjectRef.value = value; } } + get { return (gameObjectRef == null) ? gameObjectVal : gameObjectRef.Value; } + set { if (gameObjectRef == null) { gameObjectVal = value; } else { gameObjectRef.Value = value; } } } public string GetDescription() diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/IntegerVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/IntegerVariable.cs index 2ecbfd37..c8b150b3 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/IntegerVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/IntegerVariable.cs @@ -15,7 +15,7 @@ namespace Fungus { public virtual bool Evaluate(CompareOperator compareOperator, int integerValue) { - int lhs = value; + int lhs = Value; int rhs = integerValue; bool condition = false; @@ -69,8 +69,8 @@ namespace Fungus public int Value { - get { return (integerRef == null) ? integerVal : integerRef.value; } - set { if (integerRef == null) { integerVal = value; } else { integerRef.value = value; } } + get { return (integerRef == null) ? integerVal : integerRef.Value; } + set { if (integerRef == null) { integerVal = value; } else { integerRef.Value = value; } } } public string GetDescription() diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/MaterialVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/MaterialVariable.cs index c27b5e2d..d5c41b92 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/MaterialVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/MaterialVariable.cs @@ -37,8 +37,8 @@ namespace Fungus public Material Value { - get { return (materialRef == null) ? materialVal : materialRef.value; } - set { if (materialRef == null) { materialVal = value; } else { materialRef.value = value; } } + get { return (materialRef == null) ? materialVal : materialRef.Value; } + set { if (materialRef == null) { materialVal = value; } else { materialRef.Value = value; } } } public string GetDescription() diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/ObjectVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/ObjectVariable.cs index 2ffbe3e0..09ba223f 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/ObjectVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/ObjectVariable.cs @@ -37,8 +37,8 @@ namespace Fungus public Object Value { - get { return (objectRef == null) ? objectVal : objectRef.value; } - set { if (objectRef == null) { objectVal = value; } else { objectRef.value = value; } } + get { return (objectRef == null) ? objectVal : objectRef.Value; } + set { if (objectRef == null) { objectVal = value; } else { objectRef.Value = value; } } } public string GetDescription() diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/SpriteVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/SpriteVariable.cs index 04bae03d..5f5b4366 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/SpriteVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/SpriteVariable.cs @@ -37,8 +37,8 @@ namespace Fungus public Sprite Value { - get { return (spriteRef == null) ? spriteVal : spriteRef.value; } - set { if (spriteRef == null) { spriteVal = value; } else { spriteRef.value = value; } } + get { return (spriteRef == null) ? spriteVal : spriteRef.Value; } + set { if (spriteRef == null) { spriteVal = value; } else { spriteRef.Value = value; } } } public string GetDescription() diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs index 1be6aa09..ee1459cd 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs @@ -16,7 +16,7 @@ namespace Fungus { public virtual bool Evaluate(CompareOperator compareOperator, string stringValue) { - string lhs = value; + string lhs = Value; string rhs = stringValue; bool condition = false; @@ -67,9 +67,9 @@ namespace Fungus get { if (stringVal == null) stringVal = ""; - return (stringRef == null) ? stringVal : stringRef.value; + return (stringRef == null) ? stringVal : stringRef.Value; } - set { if (stringRef == null) { stringVal = value; } else { stringRef.value = value; } } + set { if (stringRef == null) { stringVal = value; } else { stringRef.Value = value; } } } public string GetDescription() @@ -117,9 +117,9 @@ namespace Fungus get { if (stringVal == null) stringVal = ""; - return (stringRef == null) ? stringVal : stringRef.value; + return (stringRef == null) ? stringVal : stringRef.Value; } - set { if (stringRef == null) { stringVal = value; } else { stringRef.value = value; } } + set { if (stringRef == null) { stringVal = value; } else { stringRef.Value = value; } } } public string GetDescription() diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/TextureVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/TextureVariable.cs index 016011d9..cec9978f 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/TextureVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/TextureVariable.cs @@ -37,8 +37,8 @@ namespace Fungus public Texture Value { - get { return (textureRef == null) ? textureVal : textureRef.value; } - set { if (textureRef == null) { textureVal = value; } else { textureRef.value = value; } } + get { return (textureRef == null) ? textureVal : textureRef.Value; } + set { if (textureRef == null) { textureVal = value; } else { textureRef.Value = value; } } } public string GetDescription() diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs index d15d72cf..96783a35 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs @@ -37,8 +37,8 @@ namespace Fungus public Transform Value { - get { return (transformRef == null) ? transformVal : transformRef.value; } - set { if (transformRef == null) { transformVal = value; } else { transformRef.value = value; } } + get { return (transformRef == null) ? transformVal : transformRef.Value; } + set { if (transformRef == null) { transformVal = value; } else { transformRef.Value = value; } } } public string GetDescription() diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector2Variable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector2Variable.cs index f3e73d9e..2b8a3cd8 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector2Variable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector2Variable.cs @@ -37,8 +37,8 @@ namespace Fungus public Vector2 Value { - get { return (vector2Ref == null) ? vector2Val : vector2Ref.value; } - set { if (vector2Ref == null) { vector2Val = value; } else { vector2Ref.value = value; } } + get { return (vector2Ref == null) ? vector2Val : vector2Ref.Value; } + set { if (vector2Ref == null) { vector2Val = value; } else { vector2Ref.Value = value; } } } public string GetDescription() diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector3Variable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector3Variable.cs index fa4d857f..2cc891f2 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector3Variable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector3Variable.cs @@ -37,8 +37,8 @@ namespace Fungus public Vector3 Value { - get { return (vector3Ref == null) ? vector3Val : vector3Ref.value; } - set { if (vector3Ref == null) { vector3Val = value; } else { vector3Ref.value = value; } } + get { return (vector3Ref == null) ? vector3Val : vector3Ref.Value; } + set { if (vector3Ref == null) { vector3Val = value; } else { vector3Ref.Value = value; } } } public string GetDescription() diff --git a/Assets/Fungus/Lua/Scripts/Commands/ExecuteLua.cs b/Assets/Fungus/Lua/Scripts/Commands/ExecuteLua.cs index 7cbebea5..360306f3 100644 --- a/Assets/Fungus/Lua/Scripts/Commands/ExecuteLua.cs +++ b/Assets/Fungus/Lua/Scripts/Commands/ExecuteLua.cs @@ -141,51 +141,51 @@ namespace Fungus System.Type variableType = returnVariable.GetType(); if (variableType == typeof(BooleanVariable) && returnValue.Type == DataType.Boolean) { - (returnVariable as BooleanVariable).value = returnValue.Boolean; + (returnVariable as BooleanVariable).Value = returnValue.Boolean; } else if (variableType == typeof(IntegerVariable) && returnValue.Type == DataType.Number) { - (returnVariable as IntegerVariable).value = (int)returnValue.Number; + (returnVariable as IntegerVariable).Value = (int)returnValue.Number; } else if (variableType == typeof(FloatVariable) && returnValue.Type == DataType.Number) { - (returnVariable as FloatVariable).value = (float)returnValue.Number; + (returnVariable as FloatVariable).Value = (float)returnValue.Number; } else if (variableType == typeof(StringVariable) && returnValue.Type == DataType.String) { - (returnVariable as StringVariable).value = returnValue.String; + (returnVariable as StringVariable).Value = returnValue.String; } else if (variableType == typeof(ColorVariable) && returnValue.Type == DataType.UserData) { - (returnVariable as ColorVariable).value = returnValue.CheckUserDataType("ExecuteLua.StoreReturnVariable"); + (returnVariable as ColorVariable).Value = returnValue.CheckUserDataType("ExecuteLua.StoreReturnVariable"); } else if (variableType == typeof(GameObjectVariable) && returnValue.Type == DataType.UserData) { - (returnVariable as GameObjectVariable).value = returnValue.CheckUserDataType("ExecuteLua.StoreReturnVariable"); + (returnVariable as GameObjectVariable).Value = returnValue.CheckUserDataType("ExecuteLua.StoreReturnVariable"); } else if (variableType == typeof(MaterialVariable) && returnValue.Type == DataType.UserData) { - (returnVariable as MaterialVariable).value = returnValue.CheckUserDataType("ExecuteLua.StoreReturnVariable"); + (returnVariable as MaterialVariable).Value = returnValue.CheckUserDataType("ExecuteLua.StoreReturnVariable"); } else if (variableType == typeof(ObjectVariable) && returnValue.Type == DataType.UserData) { - (returnVariable as ObjectVariable).value = returnValue.CheckUserDataType("ExecuteLua.StoreReturnVariable"); + (returnVariable as ObjectVariable).Value = returnValue.CheckUserDataType("ExecuteLua.StoreReturnVariable"); } else if (variableType == typeof(SpriteVariable) && returnValue.Type == DataType.UserData) { - (returnVariable as SpriteVariable).value = returnValue.CheckUserDataType("ExecuteLua.StoreReturnVariable"); + (returnVariable as SpriteVariable).Value = returnValue.CheckUserDataType("ExecuteLua.StoreReturnVariable"); } else if (variableType == typeof(TextureVariable) && returnValue.Type == DataType.UserData) { - (returnVariable as TextureVariable).value = returnValue.CheckUserDataType("ExecuteLua.StoreReturnVariable"); + (returnVariable as TextureVariable).Value = returnValue.CheckUserDataType("ExecuteLua.StoreReturnVariable"); } else if (variableType == typeof(Vector2Variable) && returnValue.Type == DataType.UserData) { - (returnVariable as Vector2Variable).value = returnValue.CheckUserDataType("ExecuteLua.StoreReturnVariable"); + (returnVariable as Vector2Variable).Value = returnValue.CheckUserDataType("ExecuteLua.StoreReturnVariable"); } else if (variableType == typeof(Vector3Variable) && returnValue.Type == DataType.UserData) { - (returnVariable as Vector3Variable).value = returnValue.CheckUserDataType("ExecuteLua.StoreReturnVariable"); + (returnVariable as Vector3Variable).Value = returnValue.CheckUserDataType("ExecuteLua.StoreReturnVariable"); } else { diff --git a/Assets/Fungus/UI/Scripts/Commands/GetText.cs b/Assets/Fungus/UI/Scripts/Commands/GetText.cs index 5a2620a9..a8bd4e7d 100644 --- a/Assets/Fungus/UI/Scripts/Commands/GetText.cs +++ b/Assets/Fungus/UI/Scripts/Commands/GetText.cs @@ -39,21 +39,21 @@ namespace Fungus Text uiText = targetTextObject.GetComponent(); if (uiText != null) { - stringVariable.value = uiText.text; + stringVariable.Value = uiText.text; } else { InputField inputField = targetTextObject.GetComponent(); if (inputField != null) { - stringVariable.value = inputField.text; + stringVariable.Value = inputField.text; } else { TextMesh textMesh = targetTextObject.GetComponent(); if (textMesh != null) { - stringVariable.value = textMesh.text; + stringVariable.Value = textMesh.text; } } } diff --git a/Assets/Tests/Scripting/TestInvoke.cs b/Assets/Tests/Scripting/TestInvoke.cs index 4ce85601..66f022f0 100644 --- a/Assets/Tests/Scripting/TestInvoke.cs +++ b/Assets/Tests/Scripting/TestInvoke.cs @@ -100,10 +100,10 @@ namespace Fungus } // Check Fungus variables are populated with expected values - if (flowchart.GetVariable("BoolVar").value != true || - flowchart.GetVariable("IntVar").value != 5 || - flowchart.GetVariable("FloatVar").value != 22.1f || - flowchart.GetVariable("StringVar").value != "a string") + if (flowchart.GetVariable("BoolVar").Value != true || + flowchart.GetVariable("IntVar").Value != 5 || + flowchart.GetVariable("FloatVar").Value != 22.1f || + flowchart.GetVariable("StringVar").Value != "a string") { IntegrationTest.Fail("Fungus variables do not match expected values"); return;