Browse Source

Add functionality for addition and subtraction to the Vector2 and Vector3 variables

master
Jorge Ramirez 7 years ago
parent
commit
f19099853b
  1. 8
      Assets/Fungus/Scripts/VariableTypes/Vector2Variable.cs
  2. 8
      Assets/Fungus/Scripts/VariableTypes/Vector3Variable.cs

8
Assets/Fungus/Scripts/VariableTypes/Vector2Variable.cs

@ -15,7 +15,7 @@ namespace Fungus
public class Vector2Variable : VariableBase<Vector2>
{
public static readonly CompareOperator[] compareOperators = { CompareOperator.Equals, CompareOperator.NotEquals };
public static readonly SetOperator[] setOperators = { SetOperator.Assign };
public static readonly SetOperator[] setOperators = { SetOperator.Assign, SetOperator.Add, SetOperator.Subtract };
public virtual bool Evaluate(CompareOperator compareOperator, Vector2 value)
{
@ -44,6 +44,12 @@ namespace Fungus
case SetOperator.Assign:
Value = value;
break;
case SetOperator.Add:
Value += value;
break;
case SetOperator.Subtract:
Value -= value;
break;
default:
Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
break;

8
Assets/Fungus/Scripts/VariableTypes/Vector3Variable.cs

@ -15,7 +15,7 @@ namespace Fungus
public class Vector3Variable : VariableBase<Vector3>
{
public static readonly CompareOperator[] compareOperators = { CompareOperator.Equals, CompareOperator.NotEquals };
public static readonly SetOperator[] setOperators = { SetOperator.Assign };
public static readonly SetOperator[] setOperators = { SetOperator.Assign, SetOperator.Add, SetOperator.Subtract };
public virtual bool Evaluate(CompareOperator compareOperator, Vector3 value)
{
@ -44,6 +44,12 @@ namespace Fungus
case SetOperator.Assign:
Value = value;
break;
case SetOperator.Add:
Value += value;
break;
case SetOperator.Subtract:
Value -= value;
break;
default:
Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
break;

Loading…
Cancel
Save