You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.4 KiB
61 lines
1.4 KiB
using UnityEngine; |
|
|
|
namespace Fungus |
|
{ |
|
/// <summary> |
|
/// Command to store the min or max of 2 values |
|
/// </summary> |
|
[CommandInfo("Math", |
|
"MinMax", |
|
"Command to store the min or max of 2 values")] |
|
[AddComponentMenu("")] |
|
public class MinMax : Command |
|
{ |
|
public enum Function |
|
{ |
|
Min, |
|
Max |
|
} |
|
|
|
[Tooltip("Min Or Max")] |
|
[SerializeField] |
|
protected Function function = Function.Min; |
|
|
|
//[Tooltip("LHS Value ")] |
|
[SerializeField] |
|
protected FloatData inLHSValue, inRHSValue; |
|
|
|
//[Tooltip("Where the result of the function is stored.")] |
|
[SerializeField] |
|
protected FloatData outValue; |
|
|
|
public override void OnEnter() |
|
{ |
|
switch (function) |
|
{ |
|
case Function.Min: |
|
outValue.Value = Mathf.Min(inLHSValue.Value, inRHSValue.Value); |
|
break; |
|
case Function.Max: |
|
outValue.Value = Mathf.Max(inLHSValue.Value, inRHSValue.Value); |
|
break; |
|
default: |
|
break; |
|
} |
|
|
|
|
|
Continue(); |
|
} |
|
|
|
public override string GetSummary() |
|
{ |
|
return function.ToString(); |
|
} |
|
|
|
public override Color GetButtonColor() |
|
{ |
|
return new Color32(235, 191, 217, 255); |
|
} |
|
|
|
} |
|
} |