Browse Source

Add functionality for addition, subtraction and multiplication to the Color variable

master
Jorge Ramirez 7 years ago
parent
commit
fccfb6c542
  1. 16
      Assets/Fungus/Scripts/VariableTypes/ColorVariable.cs

16
Assets/Fungus/Scripts/VariableTypes/ColorVariable.cs

@ -15,7 +15,12 @@ namespace Fungus
public class ColorVariable : VariableBase<Color>
{
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,
SetOperator.Multiply
};
protected static bool ColorsEqual(Color a, Color b) {
return ColorUtility.ToHtmlStringRGBA(a) == ColorUtility.ToHtmlStringRGBA(b);
@ -48,6 +53,15 @@ namespace Fungus
case SetOperator.Assign:
Value = value;
break;
case SetOperator.Add:
Value += value;
break;
case SetOperator.Subtract:
Value -= value;
break;
case SetOperator.Multiply:
Value *= value;
break;
default:
Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
break;

Loading…
Cancel
Save