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":
var intvalue = flowChart.GetVariable<IntegerVariable>(item.variableKey);
if (intvalue != null)
objValue = intvalue.value;
objValue = intvalue.Value;
break;
case "System.Boolean":
var boolean = flowChart.GetVariable<BooleanVariable>(item.variableKey);
if (boolean != null)
objValue = boolean.value;
objValue = boolean.Value;
break;
case "System.Single":
var floatvalue = flowChart.GetVariable<FloatVariable>(item.variableKey);
if (floatvalue != null)
objValue = floatvalue.value;
objValue = floatvalue.Value;
break;
case "System.String":
var stringvalue = flowChart.GetVariable<StringVariable>(item.variableKey);
if (stringvalue != null)
objValue = stringvalue.value;
objValue = stringvalue.Value;
break;
case "UnityEngine.Color":
var color = flowChart.GetVariable<ColorVariable>(item.variableKey);
if (color != null)
objValue = color.value;
objValue = color.Value;
break;
case "UnityEngine.GameObject":
var gameObject = flowChart.GetVariable<GameObjectVariable>(item.variableKey);
if (gameObject != null)
objValue = gameObject.value;
objValue = gameObject.Value;
break;
case "UnityEngine.Material":
var material = flowChart.GetVariable<MaterialVariable>(item.variableKey);
if (material != null)
objValue = material.value;
objValue = material.Value;
break;
case "UnityEngine.Sprite":
var sprite = flowChart.GetVariable<SpriteVariable>(item.variableKey);
if (sprite != null)
objValue = sprite.value;
objValue = sprite.Value;
break;
case "UnityEngine.Texture":
var texture = flowChart.GetVariable<TextureVariable>(item.variableKey);
if (texture != null)
objValue = texture.value;
objValue = texture.Value;
break;
case "UnityEngine.Vector2":
var vector2 = flowChart.GetVariable<Vector2Variable>(item.variableKey);
if (vector2 != null)
objValue = vector2.value;
objValue = vector2.Value;
break;
case "UnityEngine.Vector3":
var vector3 = flowChart.GetVariable<Vector3Variable>(item.variableKey);
if (vector3 != null)
objValue = vector3.value;
objValue = vector3.Value;
break;
default:
var obj = flowChart.GetVariable<ObjectVariable>(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<IntegerVariable>(key).value = (int)value;
flowChart.GetVariable<IntegerVariable>(key).Value = (int)value;
break;
case "System.Boolean":
flowChart.GetVariable<BooleanVariable>(key).value = (bool)value;
flowChart.GetVariable<BooleanVariable>(key).Value = (bool)value;
break;
case "System.Single":
flowChart.GetVariable<FloatVariable>(key).value = (float)value;
flowChart.GetVariable<FloatVariable>(key).Value = (float)value;
break;
case "System.String":
flowChart.GetVariable<StringVariable>(key).value = (string)value;
flowChart.GetVariable<StringVariable>(key).Value = (string)value;
break;
case "UnityEngine.Color":
flowChart.GetVariable<ColorVariable>(key).value = (UnityEngine.Color)value;
flowChart.GetVariable<ColorVariable>(key).Value = (UnityEngine.Color)value;
break;
case "UnityEngine.GameObject":
flowChart.GetVariable<GameObjectVariable>(key).value = (UnityEngine.GameObject)value;
flowChart.GetVariable<GameObjectVariable>(key).Value = (UnityEngine.GameObject)value;
break;
case "UnityEngine.Material":
flowChart.GetVariable<MaterialVariable>(key).value = (UnityEngine.Material)value;
flowChart.GetVariable<MaterialVariable>(key).Value = (UnityEngine.Material)value;
break;
case "UnityEngine.Sprite":
flowChart.GetVariable<SpriteVariable>(key).value = (UnityEngine.Sprite)value;
flowChart.GetVariable<SpriteVariable>(key).Value = (UnityEngine.Sprite)value;
break;
case "UnityEngine.Texture":
flowChart.GetVariable<TextureVariable>(key).value = (UnityEngine.Texture)value;
flowChart.GetVariable<TextureVariable>(key).Value = (UnityEngine.Texture)value;
break;
case "UnityEngine.Vector2":
flowChart.GetVariable<Vector2Variable>(key).value = (UnityEngine.Vector2)value;
flowChart.GetVariable<Vector2Variable>(key).Value = (UnityEngine.Vector2)value;
break;
case "UnityEngine.Vector3":
flowChart.GetVariable<Vector3Variable>(key).value = (UnityEngine.Vector3)value;
flowChart.GetVariable<Vector3Variable>(key).Value = (UnityEngine.Vector3)value;
break;
default:
flowChart.GetVariable<ObjectVariable>(key).value = (UnityEngine.Object)value;
flowChart.GetVariable<ObjectVariable>(key).Value = (UnityEngine.Object)value;
break;
}
}

8
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);
}
}

2
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();

2
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();

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

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

8
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);
}
}

26
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;
}
}

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

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

4
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()

4
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()

6
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()

4
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()

6
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()

4
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()

6
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()

4
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()

4
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()

4
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()

10
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()

4
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()

4
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()

4
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()

4
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()

24
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<Color>("ExecuteLua.StoreReturnVariable");
(returnVariable as ColorVariable).Value = returnValue.CheckUserDataType<Color>("ExecuteLua.StoreReturnVariable");
}
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)
{
(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)
{
(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)
{
(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)
{
(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)
{
(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)
{
(returnVariable as Vector3Variable).value = returnValue.CheckUserDataType<Vector3>("ExecuteLua.StoreReturnVariable");
(returnVariable as Vector3Variable).Value = returnValue.CheckUserDataType<Vector3>("ExecuteLua.StoreReturnVariable");
}
else
{

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

@ -39,21 +39,21 @@ namespace Fungus
Text uiText = targetTextObject.GetComponent<Text>();
if (uiText != null)
{
stringVariable.value = uiText.text;
stringVariable.Value = uiText.text;
}
else
{
InputField inputField = targetTextObject.GetComponent<InputField>();
if (inputField != null)
{
stringVariable.value = inputField.text;
stringVariable.Value = inputField.text;
}
else
{
TextMesh textMesh = targetTextObject.GetComponent<TextMesh>();
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
if (flowchart.GetVariable<BooleanVariable>("BoolVar").value != true ||
flowchart.GetVariable<IntegerVariable>("IntVar").value != 5 ||
flowchart.GetVariable<FloatVariable>("FloatVar").value != 22.1f ||
flowchart.GetVariable<StringVariable>("StringVar").value != "a string")
if (flowchart.GetVariable<BooleanVariable>("BoolVar").Value != true ||
flowchart.GetVariable<IntegerVariable>("IntVar").Value != 5 ||
flowchart.GetVariable<FloatVariable>("FloatVar").Value != 22.1f ||
flowchart.GetVariable<StringVariable>("StringVar").Value != "a string")
{
IntegrationTest.Fail("Fungus variables do not match expected values");
return;

Loading…
Cancel
Save