Browse Source

Refactored Variable base class to use protected serialised value and public property accessor.

master
Christopher 9 years ago
parent
commit
63dadcb457
  1. 48
      Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs
  2. 8
      Assets/Fungus/Flowchart/Scripts/Commands/LoadVariable.cs
  3. 2
      Assets/Fungus/Flowchart/Scripts/Commands/RandomFloat.cs
  4. 2
      Assets/Fungus/Flowchart/Scripts/Commands/RandomInteger.cs
  5. 2
      Assets/Fungus/Flowchart/Scripts/Commands/ReadTextFile.cs
  6. 8
      Assets/Fungus/Flowchart/Scripts/Commands/SaveVariable.cs
  7. 26
      Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs
  8. 16
      Assets/Fungus/Flowchart/Scripts/Flowchart.cs
  9. 10
      Assets/Fungus/Flowchart/Scripts/Variable.cs
  10. 4
      Assets/Fungus/Flowchart/Scripts/VariableTypes/AnimatorVariable.cs
  11. 4
      Assets/Fungus/Flowchart/Scripts/VariableTypes/AudioSourceVariable.cs
  12. 6
      Assets/Fungus/Flowchart/Scripts/VariableTypes/BooleanVariable.cs
  13. 4
      Assets/Fungus/Flowchart/Scripts/VariableTypes/ColorVariable.cs
  14. 6
      Assets/Fungus/Flowchart/Scripts/VariableTypes/FloatVariable.cs
  15. 4
      Assets/Fungus/Flowchart/Scripts/VariableTypes/GameObjectVariable.cs
  16. 6
      Assets/Fungus/Flowchart/Scripts/VariableTypes/IntegerVariable.cs
  17. 4
      Assets/Fungus/Flowchart/Scripts/VariableTypes/MaterialVariable.cs
  18. 4
      Assets/Fungus/Flowchart/Scripts/VariableTypes/ObjectVariable.cs
  19. 4
      Assets/Fungus/Flowchart/Scripts/VariableTypes/SpriteVariable.cs
  20. 10
      Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs
  21. 4
      Assets/Fungus/Flowchart/Scripts/VariableTypes/TextureVariable.cs
  22. 4
      Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs
  23. 4
      Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector2Variable.cs
  24. 4
      Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector3Variable.cs
  25. 24
      Assets/Fungus/Lua/Scripts/Commands/ExecuteLua.cs
  26. 6
      Assets/Fungus/UI/Scripts/Commands/GetText.cs
  27. 8
      Assets/Tests/Scripting/TestInvoke.cs

48
Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs

@ -200,62 +200,62 @@ namespace Fungus
case "System.Int32": case "System.Int32":
var intvalue = flowChart.GetVariable<IntegerVariable>(item.variableKey); var intvalue = flowChart.GetVariable<IntegerVariable>(item.variableKey);
if (intvalue != null) if (intvalue != null)
objValue = intvalue.value; objValue = intvalue.Value;
break; break;
case "System.Boolean": case "System.Boolean":
var boolean = flowChart.GetVariable<BooleanVariable>(item.variableKey); var boolean = flowChart.GetVariable<BooleanVariable>(item.variableKey);
if (boolean != null) if (boolean != null)
objValue = boolean.value; objValue = boolean.Value;
break; break;
case "System.Single": case "System.Single":
var floatvalue = flowChart.GetVariable<FloatVariable>(item.variableKey); var floatvalue = flowChart.GetVariable<FloatVariable>(item.variableKey);
if (floatvalue != null) if (floatvalue != null)
objValue = floatvalue.value; objValue = floatvalue.Value;
break; break;
case "System.String": case "System.String":
var stringvalue = flowChart.GetVariable<StringVariable>(item.variableKey); var stringvalue = flowChart.GetVariable<StringVariable>(item.variableKey);
if (stringvalue != null) if (stringvalue != null)
objValue = stringvalue.value; objValue = stringvalue.Value;
break; break;
case "UnityEngine.Color": case "UnityEngine.Color":
var color = flowChart.GetVariable<ColorVariable>(item.variableKey); var color = flowChart.GetVariable<ColorVariable>(item.variableKey);
if (color != null) if (color != null)
objValue = color.value; objValue = color.Value;
break; break;
case "UnityEngine.GameObject": case "UnityEngine.GameObject":
var gameObject = flowChart.GetVariable<GameObjectVariable>(item.variableKey); var gameObject = flowChart.GetVariable<GameObjectVariable>(item.variableKey);
if (gameObject != null) if (gameObject != null)
objValue = gameObject.value; objValue = gameObject.Value;
break; break;
case "UnityEngine.Material": case "UnityEngine.Material":
var material = flowChart.GetVariable<MaterialVariable>(item.variableKey); var material = flowChart.GetVariable<MaterialVariable>(item.variableKey);
if (material != null) if (material != null)
objValue = material.value; objValue = material.Value;
break; break;
case "UnityEngine.Sprite": case "UnityEngine.Sprite":
var sprite = flowChart.GetVariable<SpriteVariable>(item.variableKey); var sprite = flowChart.GetVariable<SpriteVariable>(item.variableKey);
if (sprite != null) if (sprite != null)
objValue = sprite.value; objValue = sprite.Value;
break; break;
case "UnityEngine.Texture": case "UnityEngine.Texture":
var texture = flowChart.GetVariable<TextureVariable>(item.variableKey); var texture = flowChart.GetVariable<TextureVariable>(item.variableKey);
if (texture != null) if (texture != null)
objValue = texture.value; objValue = texture.Value;
break; break;
case "UnityEngine.Vector2": case "UnityEngine.Vector2":
var vector2 = flowChart.GetVariable<Vector2Variable>(item.variableKey); var vector2 = flowChart.GetVariable<Vector2Variable>(item.variableKey);
if (vector2 != null) if (vector2 != null)
objValue = vector2.value; objValue = vector2.Value;
break; break;
case "UnityEngine.Vector3": case "UnityEngine.Vector3":
var vector3 = flowChart.GetVariable<Vector3Variable>(item.variableKey); var vector3 = flowChart.GetVariable<Vector3Variable>(item.variableKey);
if (vector3 != null) if (vector3 != null)
objValue = vector3.value; objValue = vector3.Value;
break; break;
default: default:
var obj = flowChart.GetVariable<ObjectVariable>(item.variableKey); var obj = flowChart.GetVariable<ObjectVariable>(item.variableKey);
if (obj != null) if (obj != null)
objValue = obj.value; objValue = obj.Value;
break; break;
} }
@ -273,40 +273,40 @@ namespace Fungus
switch (returnType) switch (returnType)
{ {
case "System.Int32": case "System.Int32":
flowChart.GetVariable<IntegerVariable>(key).value = (int)value; flowChart.GetVariable<IntegerVariable>(key).Value = (int)value;
break; break;
case "System.Boolean": case "System.Boolean":
flowChart.GetVariable<BooleanVariable>(key).value = (bool)value; flowChart.GetVariable<BooleanVariable>(key).Value = (bool)value;
break; break;
case "System.Single": case "System.Single":
flowChart.GetVariable<FloatVariable>(key).value = (float)value; flowChart.GetVariable<FloatVariable>(key).Value = (float)value;
break; break;
case "System.String": case "System.String":
flowChart.GetVariable<StringVariable>(key).value = (string)value; flowChart.GetVariable<StringVariable>(key).Value = (string)value;
break; break;
case "UnityEngine.Color": case "UnityEngine.Color":
flowChart.GetVariable<ColorVariable>(key).value = (UnityEngine.Color)value; flowChart.GetVariable<ColorVariable>(key).Value = (UnityEngine.Color)value;
break; break;
case "UnityEngine.GameObject": case "UnityEngine.GameObject":
flowChart.GetVariable<GameObjectVariable>(key).value = (UnityEngine.GameObject)value; flowChart.GetVariable<GameObjectVariable>(key).Value = (UnityEngine.GameObject)value;
break; break;
case "UnityEngine.Material": case "UnityEngine.Material":
flowChart.GetVariable<MaterialVariable>(key).value = (UnityEngine.Material)value; flowChart.GetVariable<MaterialVariable>(key).Value = (UnityEngine.Material)value;
break; break;
case "UnityEngine.Sprite": case "UnityEngine.Sprite":
flowChart.GetVariable<SpriteVariable>(key).value = (UnityEngine.Sprite)value; flowChart.GetVariable<SpriteVariable>(key).Value = (UnityEngine.Sprite)value;
break; break;
case "UnityEngine.Texture": case "UnityEngine.Texture":
flowChart.GetVariable<TextureVariable>(key).value = (UnityEngine.Texture)value; flowChart.GetVariable<TextureVariable>(key).Value = (UnityEngine.Texture)value;
break; break;
case "UnityEngine.Vector2": case "UnityEngine.Vector2":
flowChart.GetVariable<Vector2Variable>(key).value = (UnityEngine.Vector2)value; flowChart.GetVariable<Vector2Variable>(key).Value = (UnityEngine.Vector2)value;
break; break;
case "UnityEngine.Vector3": case "UnityEngine.Vector3":
flowChart.GetVariable<Vector3Variable>(key).value = (UnityEngine.Vector3)value; flowChart.GetVariable<Vector3Variable>(key).Value = (UnityEngine.Vector3)value;
break; break;
default: default:
flowChart.GetVariable<ObjectVariable>(key).value = (UnityEngine.Object)value; flowChart.GetVariable<ObjectVariable>(key).Value = (UnityEngine.Object)value;
break; break;
} }
} }

8
Assets/Fungus/Flowchart/Scripts/Commands/LoadVariable.cs

@ -47,7 +47,7 @@ namespace Fungus
if (booleanVariable != null) if (booleanVariable != null)
{ {
// PlayerPrefs does not have bool accessors, so just use int // 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)) else if (variableType == typeof(IntegerVariable))
@ -55,7 +55,7 @@ namespace Fungus
IntegerVariable integerVariable = variable as IntegerVariable; IntegerVariable integerVariable = variable as IntegerVariable;
if (integerVariable != null) if (integerVariable != null)
{ {
integerVariable.value = PlayerPrefs.GetInt(prefsKey); integerVariable.Value = PlayerPrefs.GetInt(prefsKey);
} }
} }
else if (variableType == typeof(FloatVariable)) else if (variableType == typeof(FloatVariable))
@ -63,7 +63,7 @@ namespace Fungus
FloatVariable floatVariable = variable as FloatVariable; FloatVariable floatVariable = variable as FloatVariable;
if (floatVariable != null) if (floatVariable != null)
{ {
floatVariable.value = PlayerPrefs.GetFloat(prefsKey); floatVariable.Value = PlayerPrefs.GetFloat(prefsKey);
} }
} }
else if (variableType == typeof(StringVariable)) else if (variableType == typeof(StringVariable))
@ -71,7 +71,7 @@ namespace Fungus
StringVariable stringVariable = variable as StringVariable; StringVariable stringVariable = variable as StringVariable;
if (stringVariable != null) if (stringVariable != null)
{ {
stringVariable.value = PlayerPrefs.GetString(prefsKey); stringVariable.Value = PlayerPrefs.GetString(prefsKey);
} }
} }

2
Assets/Fungus/Flowchart/Scripts/Commands/RandomFloat.cs

@ -28,7 +28,7 @@ namespace Fungus
{ {
if (variable != null) if (variable != null)
{ {
variable.value = Random.Range(minValue.Value, maxValue.Value); variable.Value = Random.Range(minValue.Value, maxValue.Value);
} }
Continue(); Continue();

2
Assets/Fungus/Flowchart/Scripts/Commands/RandomInteger.cs

@ -28,7 +28,7 @@ namespace Fungus
{ {
if (variable != null) if (variable != null)
{ {
variable.value = Random.Range(minValue.Value, maxValue.Value); variable.Value = Random.Range(minValue.Value, maxValue.Value);
} }
Continue(); Continue();

2
Assets/Fungus/Flowchart/Scripts/Commands/ReadTextFile.cs

@ -31,7 +31,7 @@ namespace Fungus
return; return;
} }
stringVariable.value = textFile.text; stringVariable.Value = textFile.text;
Continue(); Continue();
} }

8
Assets/Fungus/Flowchart/Scripts/Commands/SaveVariable.cs

@ -49,7 +49,7 @@ namespace Fungus
if (booleanVariable != null) if (booleanVariable != null)
{ {
// PlayerPrefs does not have bool accessors, so just use int // 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)) else if (variableType == typeof(IntegerVariable))
@ -57,7 +57,7 @@ namespace Fungus
IntegerVariable integerVariable = variable as IntegerVariable; IntegerVariable integerVariable = variable as IntegerVariable;
if (integerVariable != null) if (integerVariable != null)
{ {
PlayerPrefs.SetInt(prefsKey, integerVariable.value); PlayerPrefs.SetInt(prefsKey, integerVariable.Value);
} }
} }
else if (variableType == typeof(FloatVariable)) else if (variableType == typeof(FloatVariable))
@ -65,7 +65,7 @@ namespace Fungus
FloatVariable floatVariable = variable as FloatVariable; FloatVariable floatVariable = variable as FloatVariable;
if (floatVariable != null) if (floatVariable != null)
{ {
PlayerPrefs.SetFloat(prefsKey, floatVariable.value); PlayerPrefs.SetFloat(prefsKey, floatVariable.Value);
} }
} }
else if (variableType == typeof(StringVariable)) else if (variableType == typeof(StringVariable))
@ -73,7 +73,7 @@ namespace Fungus
StringVariable stringVariable = variable as StringVariable; StringVariable stringVariable = variable as StringVariable;
if (stringVariable != null) if (stringVariable != null)
{ {
PlayerPrefs.SetString(prefsKey, stringVariable.value); PlayerPrefs.SetString(prefsKey, stringVariable.Value);
} }
} }

26
Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs

@ -133,10 +133,10 @@ namespace Fungus
{ {
default: default:
case SetOperator.Assign: case SetOperator.Assign:
lhs.value = rhs; lhs.Value = rhs;
break; break;
case SetOperator.Negate: case SetOperator.Negate:
lhs.value = !rhs; lhs.Value = !rhs;
break; break;
} }
} }
@ -149,19 +149,19 @@ namespace Fungus
{ {
default: default:
case SetOperator.Assign: case SetOperator.Assign:
lhs.value = rhs; lhs.Value = rhs;
break; break;
case SetOperator.Add: case SetOperator.Add:
lhs.value += rhs; lhs.Value += rhs;
break; break;
case SetOperator.Subtract: case SetOperator.Subtract:
lhs.value -= rhs; lhs.Value -= rhs;
break; break;
case SetOperator.Multiply: case SetOperator.Multiply:
lhs.value *= rhs; lhs.Value *= rhs;
break; break;
case SetOperator.Divide: case SetOperator.Divide:
lhs.value /= rhs; lhs.Value /= rhs;
break; break;
} }
} }
@ -174,19 +174,19 @@ namespace Fungus
{ {
default: default:
case SetOperator.Assign: case SetOperator.Assign:
lhs.value = rhs; lhs.Value = rhs;
break; break;
case SetOperator.Add: case SetOperator.Add:
lhs.value += rhs; lhs.Value += rhs;
break; break;
case SetOperator.Subtract: case SetOperator.Subtract:
lhs.value -= rhs; lhs.Value -= rhs;
break; break;
case SetOperator.Multiply: case SetOperator.Multiply:
lhs.value *= rhs; lhs.Value *= rhs;
break; break;
case SetOperator.Divide: case SetOperator.Divide:
lhs.value /= rhs; lhs.Value /= rhs;
break; break;
} }
} }
@ -199,7 +199,7 @@ namespace Fungus
{ {
default: default:
case SetOperator.Assign: case SetOperator.Assign:
lhs.value = rhs; lhs.Value = rhs;
break; break;
} }
} }

16
Assets/Fungus/Flowchart/Scripts/Flowchart.cs

@ -767,7 +767,7 @@ namespace Fungus
if(variable != null) if(variable != null)
{ {
return GetVariable<BooleanVariable>(key).value; return GetVariable<BooleanVariable>(key).Value;
} }
else else
{ {
@ -784,7 +784,7 @@ namespace Fungus
BooleanVariable variable = GetVariable<BooleanVariable>(key); BooleanVariable variable = GetVariable<BooleanVariable>(key);
if(variable != null) if(variable != null)
{ {
variable.value = value; variable.Value = value;
} }
} }
@ -798,7 +798,7 @@ namespace Fungus
if (variable != null) if (variable != null)
{ {
return GetVariable<IntegerVariable>(key).value; return GetVariable<IntegerVariable>(key).Value;
} }
else else
{ {
@ -815,7 +815,7 @@ namespace Fungus
IntegerVariable variable = GetVariable<IntegerVariable>(key); IntegerVariable variable = GetVariable<IntegerVariable>(key);
if (variable != null) if (variable != null)
{ {
variable.value = value; variable.Value = value;
} }
} }
@ -829,7 +829,7 @@ namespace Fungus
if (variable != null) if (variable != null)
{ {
return GetVariable<FloatVariable>(key).value; return GetVariable<FloatVariable>(key).Value;
} }
else else
{ {
@ -846,7 +846,7 @@ namespace Fungus
FloatVariable variable = GetVariable<FloatVariable>(key); FloatVariable variable = GetVariable<FloatVariable>(key);
if (variable != null) if (variable != null)
{ {
variable.value = value; variable.Value = value;
} }
} }
@ -860,7 +860,7 @@ namespace Fungus
if (variable != null) if (variable != null)
{ {
return GetVariable<StringVariable>(key).value; return GetVariable<StringVariable>(key).Value;
} }
else else
{ {
@ -877,7 +877,7 @@ namespace Fungus
StringVariable variable = GetVariable<StringVariable>(key); StringVariable variable = GetVariable<StringVariable>(key);
if (variable != null) if (variable != null)
{ {
variable.value = value; variable.Value = value;
} }
} }

10
Assets/Fungus/Flowchart/Scripts/Variable.cs

@ -64,24 +64,26 @@ namespace Fungus
public abstract class VariableBase<T> : Variable public abstract class VariableBase<T> : Variable
{ {
public T value; [SerializeField] protected T value;
public T Value { get { return this.value; } set { this.value = value; } }
protected T startValue; protected T startValue;
public override void OnReset() public override void OnReset()
{ {
value = startValue; Value = startValue;
} }
public override string ToString() public override string ToString()
{ {
return value.ToString(); return Value.ToString();
} }
protected virtual void Start() protected virtual void Start()
{ {
// Remember the initial value so we can reset later on // Remember the initial value so we can reset later on
startValue = value; startValue = Value;
} }
} }
} }

4
Assets/Fungus/Flowchart/Scripts/VariableTypes/AnimatorVariable.cs

@ -37,8 +37,8 @@ namespace Fungus
public Animator Value public Animator Value
{ {
get { return (animatorRef == null) ? animatorVal : animatorRef.value; } get { return (animatorRef == null) ? animatorVal : animatorRef.Value; }
set { if (animatorRef == null) { animatorVal = value; } else { animatorRef.value = value; } } set { if (animatorRef == null) { animatorVal = value; } else { animatorRef.Value = value; } }
} }
public string GetDescription() public string GetDescription()

4
Assets/Fungus/Flowchart/Scripts/VariableTypes/AudioSourceVariable.cs

@ -37,8 +37,8 @@ namespace Fungus
public AudioSource Value public AudioSource Value
{ {
get { return (audioSourceRef == null) ? audioSourceVal : audioSourceRef.value; } get { return (audioSourceRef == null) ? audioSourceVal : audioSourceRef.Value; }
set { if (audioSourceRef == null) { audioSourceVal = value; } else { audioSourceRef.value = value; } } set { if (audioSourceRef == null) { audioSourceVal = value; } else { audioSourceRef.Value = value; } }
} }
public string GetDescription() public string GetDescription()

6
Assets/Fungus/Flowchart/Scripts/VariableTypes/BooleanVariable.cs

@ -19,7 +19,7 @@ namespace Fungus
{ {
bool condition = false; bool condition = false;
bool lhs = value; bool lhs = Value;
bool rhs = booleanValue; bool rhs = booleanValue;
switch (compareOperator) switch (compareOperator)
@ -61,8 +61,8 @@ namespace Fungus
public bool Value public bool Value
{ {
get { return (booleanRef == null) ? booleanVal : booleanRef.value; } get { return (booleanRef == null) ? booleanVal : booleanRef.Value; }
set { if (booleanRef == null) { booleanVal = value; } else { booleanRef.value = value; } } set { if (booleanRef == null) { booleanVal = value; } else { booleanRef.Value = value; } }
} }
public string GetDescription() public string GetDescription()

4
Assets/Fungus/Flowchart/Scripts/VariableTypes/ColorVariable.cs

@ -37,8 +37,8 @@ namespace Fungus
public Color Value public Color Value
{ {
get { return (colorRef == null) ? colorVal : colorRef.value; } get { return (colorRef == null) ? colorVal : colorRef.Value; }
set { if (colorRef == null) { colorVal = value; } else { colorRef.value = value; } } set { if (colorRef == null) { colorVal = value; } else { colorRef.Value = value; } }
} }
public string GetDescription() public string GetDescription()

6
Assets/Fungus/Flowchart/Scripts/VariableTypes/FloatVariable.cs

@ -15,7 +15,7 @@ namespace Fungus
{ {
public virtual bool Evaluate(CompareOperator compareOperator, float floatValue) public virtual bool Evaluate(CompareOperator compareOperator, float floatValue)
{ {
float lhs = value; float lhs = Value;
float rhs = floatValue; float rhs = floatValue;
bool condition = false; bool condition = false;
@ -69,8 +69,8 @@ namespace Fungus
public float Value public float Value
{ {
get { return (floatRef == null) ? floatVal : floatRef.value; } get { return (floatRef == null) ? floatVal : floatRef.Value; }
set { if (floatRef == null) { floatVal = value; } else { floatRef.value = value; } } set { if (floatRef == null) { floatVal = value; } else { floatRef.Value = value; } }
} }
public string GetDescription() public string GetDescription()

4
Assets/Fungus/Flowchart/Scripts/VariableTypes/GameObjectVariable.cs

@ -37,8 +37,8 @@ namespace Fungus
public GameObject Value public GameObject Value
{ {
get { return (gameObjectRef == null) ? gameObjectVal : gameObjectRef.value; } get { return (gameObjectRef == null) ? gameObjectVal : gameObjectRef.Value; }
set { if (gameObjectRef == null) { gameObjectVal = value; } else { gameObjectRef.value = value; } } set { if (gameObjectRef == null) { gameObjectVal = value; } else { gameObjectRef.Value = value; } }
} }
public string GetDescription() public string GetDescription()

6
Assets/Fungus/Flowchart/Scripts/VariableTypes/IntegerVariable.cs

@ -15,7 +15,7 @@ namespace Fungus
{ {
public virtual bool Evaluate(CompareOperator compareOperator, int integerValue) public virtual bool Evaluate(CompareOperator compareOperator, int integerValue)
{ {
int lhs = value; int lhs = Value;
int rhs = integerValue; int rhs = integerValue;
bool condition = false; bool condition = false;
@ -69,8 +69,8 @@ namespace Fungus
public int Value public int Value
{ {
get { return (integerRef == null) ? integerVal : integerRef.value; } get { return (integerRef == null) ? integerVal : integerRef.Value; }
set { if (integerRef == null) { integerVal = value; } else { integerRef.value = value; } } set { if (integerRef == null) { integerVal = value; } else { integerRef.Value = value; } }
} }
public string GetDescription() public string GetDescription()

4
Assets/Fungus/Flowchart/Scripts/VariableTypes/MaterialVariable.cs

@ -37,8 +37,8 @@ namespace Fungus
public Material Value public Material Value
{ {
get { return (materialRef == null) ? materialVal : materialRef.value; } get { return (materialRef == null) ? materialVal : materialRef.Value; }
set { if (materialRef == null) { materialVal = value; } else { materialRef.value = value; } } set { if (materialRef == null) { materialVal = value; } else { materialRef.Value = value; } }
} }
public string GetDescription() public string GetDescription()

4
Assets/Fungus/Flowchart/Scripts/VariableTypes/ObjectVariable.cs

@ -37,8 +37,8 @@ namespace Fungus
public Object Value public Object Value
{ {
get { return (objectRef == null) ? objectVal : objectRef.value; } get { return (objectRef == null) ? objectVal : objectRef.Value; }
set { if (objectRef == null) { objectVal = value; } else { objectRef.value = value; } } set { if (objectRef == null) { objectVal = value; } else { objectRef.Value = value; } }
} }
public string GetDescription() public string GetDescription()

4
Assets/Fungus/Flowchart/Scripts/VariableTypes/SpriteVariable.cs

@ -37,8 +37,8 @@ namespace Fungus
public Sprite Value public Sprite Value
{ {
get { return (spriteRef == null) ? spriteVal : spriteRef.value; } get { return (spriteRef == null) ? spriteVal : spriteRef.Value; }
set { if (spriteRef == null) { spriteVal = value; } else { spriteRef.value = value; } } set { if (spriteRef == null) { spriteVal = value; } else { spriteRef.Value = value; } }
} }
public string GetDescription() public string GetDescription()

10
Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs

@ -16,7 +16,7 @@ namespace Fungus
{ {
public virtual bool Evaluate(CompareOperator compareOperator, string stringValue) public virtual bool Evaluate(CompareOperator compareOperator, string stringValue)
{ {
string lhs = value; string lhs = Value;
string rhs = stringValue; string rhs = stringValue;
bool condition = false; bool condition = false;
@ -67,9 +67,9 @@ namespace Fungus
get get
{ {
if (stringVal == null) stringVal = ""; 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() public string GetDescription()
@ -117,9 +117,9 @@ namespace Fungus
get get
{ {
if (stringVal == null) stringVal = ""; 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() public string GetDescription()

4
Assets/Fungus/Flowchart/Scripts/VariableTypes/TextureVariable.cs

@ -37,8 +37,8 @@ namespace Fungus
public Texture Value public Texture Value
{ {
get { return (textureRef == null) ? textureVal : textureRef.value; } get { return (textureRef == null) ? textureVal : textureRef.Value; }
set { if (textureRef == null) { textureVal = value; } else { textureRef.value = value; } } set { if (textureRef == null) { textureVal = value; } else { textureRef.Value = value; } }
} }
public string GetDescription() public string GetDescription()

4
Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs

@ -37,8 +37,8 @@ namespace Fungus
public Transform Value public Transform Value
{ {
get { return (transformRef == null) ? transformVal : transformRef.value; } get { return (transformRef == null) ? transformVal : transformRef.Value; }
set { if (transformRef == null) { transformVal = value; } else { transformRef.value = value; } } set { if (transformRef == null) { transformVal = value; } else { transformRef.Value = value; } }
} }
public string GetDescription() public string GetDescription()

4
Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector2Variable.cs

@ -37,8 +37,8 @@ namespace Fungus
public Vector2 Value public Vector2 Value
{ {
get { return (vector2Ref == null) ? vector2Val : vector2Ref.value; } get { return (vector2Ref == null) ? vector2Val : vector2Ref.Value; }
set { if (vector2Ref == null) { vector2Val = value; } else { vector2Ref.value = value; } } set { if (vector2Ref == null) { vector2Val = value; } else { vector2Ref.Value = value; } }
} }
public string GetDescription() public string GetDescription()

4
Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector3Variable.cs

@ -37,8 +37,8 @@ namespace Fungus
public Vector3 Value public Vector3 Value
{ {
get { return (vector3Ref == null) ? vector3Val : vector3Ref.value; } get { return (vector3Ref == null) ? vector3Val : vector3Ref.Value; }
set { if (vector3Ref == null) { vector3Val = value; } else { vector3Ref.value = value; } } set { if (vector3Ref == null) { vector3Val = value; } else { vector3Ref.Value = value; } }
} }
public string GetDescription() public string GetDescription()

24
Assets/Fungus/Lua/Scripts/Commands/ExecuteLua.cs

@ -141,51 +141,51 @@ namespace Fungus
System.Type variableType = returnVariable.GetType(); System.Type variableType = returnVariable.GetType();
if (variableType == typeof(BooleanVariable) && returnValue.Type == DataType.Boolean) 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) 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) 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) 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) else if (variableType == typeof(ColorVariable) && returnValue.Type == DataType.UserData)
{ {
(returnVariable as ColorVariable).value = returnValue.CheckUserDataType<Color>("ExecuteLua.StoreReturnVariable"); (returnVariable as ColorVariable).Value = returnValue.CheckUserDataType<Color>("ExecuteLua.StoreReturnVariable");
} }
else if (variableType == typeof(GameObjectVariable) && returnValue.Type == DataType.UserData) else if (variableType == typeof(GameObjectVariable) && returnValue.Type == DataType.UserData)
{ {
(returnVariable as GameObjectVariable).value = returnValue.CheckUserDataType<GameObject>("ExecuteLua.StoreReturnVariable"); (returnVariable as GameObjectVariable).Value = returnValue.CheckUserDataType<GameObject>("ExecuteLua.StoreReturnVariable");
} }
else if (variableType == typeof(MaterialVariable) && returnValue.Type == DataType.UserData) else if (variableType == typeof(MaterialVariable) && returnValue.Type == DataType.UserData)
{ {
(returnVariable as MaterialVariable).value = returnValue.CheckUserDataType<Material>("ExecuteLua.StoreReturnVariable"); (returnVariable as MaterialVariable).Value = returnValue.CheckUserDataType<Material>("ExecuteLua.StoreReturnVariable");
} }
else if (variableType == typeof(ObjectVariable) && returnValue.Type == DataType.UserData) else if (variableType == typeof(ObjectVariable) && returnValue.Type == DataType.UserData)
{ {
(returnVariable as ObjectVariable).value = returnValue.CheckUserDataType<Object>("ExecuteLua.StoreReturnVariable"); (returnVariable as ObjectVariable).Value = returnValue.CheckUserDataType<Object>("ExecuteLua.StoreReturnVariable");
} }
else if (variableType == typeof(SpriteVariable) && returnValue.Type == DataType.UserData) else if (variableType == typeof(SpriteVariable) && returnValue.Type == DataType.UserData)
{ {
(returnVariable as SpriteVariable).value = returnValue.CheckUserDataType<Sprite>("ExecuteLua.StoreReturnVariable"); (returnVariable as SpriteVariable).Value = returnValue.CheckUserDataType<Sprite>("ExecuteLua.StoreReturnVariable");
} }
else if (variableType == typeof(TextureVariable) && returnValue.Type == DataType.UserData) else if (variableType == typeof(TextureVariable) && returnValue.Type == DataType.UserData)
{ {
(returnVariable as TextureVariable).value = returnValue.CheckUserDataType<Texture>("ExecuteLua.StoreReturnVariable"); (returnVariable as TextureVariable).Value = returnValue.CheckUserDataType<Texture>("ExecuteLua.StoreReturnVariable");
} }
else if (variableType == typeof(Vector2Variable) && returnValue.Type == DataType.UserData) else if (variableType == typeof(Vector2Variable) && returnValue.Type == DataType.UserData)
{ {
(returnVariable as Vector2Variable).value = returnValue.CheckUserDataType<Vector2>("ExecuteLua.StoreReturnVariable"); (returnVariable as Vector2Variable).Value = returnValue.CheckUserDataType<Vector2>("ExecuteLua.StoreReturnVariable");
} }
else if (variableType == typeof(Vector3Variable) && returnValue.Type == DataType.UserData) else if (variableType == typeof(Vector3Variable) && returnValue.Type == DataType.UserData)
{ {
(returnVariable as Vector3Variable).value = returnValue.CheckUserDataType<Vector3>("ExecuteLua.StoreReturnVariable"); (returnVariable as Vector3Variable).Value = returnValue.CheckUserDataType<Vector3>("ExecuteLua.StoreReturnVariable");
} }
else else
{ {

6
Assets/Fungus/UI/Scripts/Commands/GetText.cs

@ -39,21 +39,21 @@ namespace Fungus
Text uiText = targetTextObject.GetComponent<Text>(); Text uiText = targetTextObject.GetComponent<Text>();
if (uiText != null) if (uiText != null)
{ {
stringVariable.value = uiText.text; stringVariable.Value = uiText.text;
} }
else else
{ {
InputField inputField = targetTextObject.GetComponent<InputField>(); InputField inputField = targetTextObject.GetComponent<InputField>();
if (inputField != null) if (inputField != null)
{ {
stringVariable.value = inputField.text; stringVariable.Value = inputField.text;
} }
else else
{ {
TextMesh textMesh = targetTextObject.GetComponent<TextMesh>(); TextMesh textMesh = targetTextObject.GetComponent<TextMesh>();
if (textMesh != null) if (textMesh != null)
{ {
stringVariable.value = textMesh.text; stringVariable.Value = textMesh.text;
} }
} }
} }

8
Assets/Tests/Scripting/TestInvoke.cs

@ -100,10 +100,10 @@ namespace Fungus
} }
// Check Fungus variables are populated with expected values // Check Fungus variables are populated with expected values
if (flowchart.GetVariable<BooleanVariable>("BoolVar").value != true || if (flowchart.GetVariable<BooleanVariable>("BoolVar").Value != true ||
flowchart.GetVariable<IntegerVariable>("IntVar").value != 5 || flowchart.GetVariable<IntegerVariable>("IntVar").Value != 5 ||
flowchart.GetVariable<FloatVariable>("FloatVar").value != 22.1f || flowchart.GetVariable<FloatVariable>("FloatVar").Value != 22.1f ||
flowchart.GetVariable<StringVariable>("StringVar").value != "a string") flowchart.GetVariable<StringVariable>("StringVar").Value != "a string")
{ {
IntegrationTest.Fail("Fungus variables do not match expected values"); IntegrationTest.Fail("Fungus variables do not match expected values");
return; return;

Loading…
Cancel
Save