Compare#
Can Read
Cannot Write
Description#
Compares two numbers using the selected operator
Parameters#
| Name | Description |
|---|---|
| Number 1 | The number targeted |
| Number 2 | The number to compare against |
| Comparison | The operator used between both numbers |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Compare")]
[Category("Math/Numbers/Compare")]
[Description("Compares two numbers using the selected operator")]
[Image(typeof(IconEqualsCircle), ColorTheme.Type.Yellow, typeof(BadgeHash))]
[Parameter("Number 1", "The number targeted")]
[Parameter("Number 2", "The number to compare against")]
[Parameter("Comparison", "The operator used between both numbers")]
[Keywords("Equal", "Different", "Greater", "Less", "Bigger", "Smaller", "Than")]
[Serializable]
public class TypeBoolMathNumbersCompare : TypeBool
{
[SerializeField] private GetNumber m_Number1 = new GetNumber();
[SerializeField] private CompareNumber m_Comparison = new CompareNumber();
[SerializeField] private GetNumber m_Number2 = new GetNumber();
public override bool GetPreview(GameObject source) => this.m_Comparison.Compare(
this.m_Number1.GetPreview(source),
this.m_Number2.GetPreview(source)
);
public override bool Get(Args args) => this.m_Comparison.Compare(
this.m_Number1.Get(args),
this.m_Number2.Get(args)
);
public override string ToString()
{
return $"{this.m_Number1} {this.m_Comparison} {this.m_Number2}";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}