Number#
Can Read
Cannot Write
Description#
A constant numeric value
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Inline(nameof(m_Value))]
[Title("Number")]
[Category("Number")]
[Description("A constant numeric value")]
[Image(typeof(IconNumber), ColorTheme.Type.Teal)]
[Keywords("Value", "Float", "Double", "Decimal", "Integer", "Constant")]
[Serializable]
public class TypeNumberConstant : TypeNumber
{
[SerializeField] private double m_Value;
public override double GetPreview(GameObject source) => this.m_Value;
public TypeNumberConstant() : this(0f)
{ }
public TypeNumberConstant(float value)
{
this.m_Value = value;
}
public TypeNumberConstant(double value)
{
this.m_Value = value;
}
public override double Get(Args args)
{
return this.m_Value;
}
public override string ToString()
{
return this.m_Value.ToString("0.##");
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnEditorChange;
}
}