Sign#
Math / Arithmetic / Sign
Can Read
Cannot Write
Description#
Returns +1 if the value is zero or positive and returns -1 otherwise
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Sign")]
[Category("Math/Arithmetic/Sign")]
[Description("Returns +1 if the value is zero or positive and returns -1 otherwise")]
[Image(typeof(IconSign), ColorTheme.Type.Yellow)]
[Keywords("Positive", "Negative", "Symbol")]
[Serializable]
public class TypeNumberMathSign : TypeNumber
{
[SerializeField] private GetNumber m_Number = new GetNumber();
public override double GetPreview(GameObject source) => Math.Sign(this.m_Number.GetPreview(source));
public override double Get(Args args)
{
double number = this.m_Number.Get(args);
return Math.Sign(number);
}
public override string ToString()
{
return $"Sign({this.m_Number})";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}