Variable#
Can Read
Cannot Write
Description#
Any Variable or Local Variable reference
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Inline(nameof(m_Value), typeof(Variable), true)]
[Title("Variable")]
[Category("Variable")]
[Description("Any Variable or Local Variable reference")]
[Image(typeof(IconCubeOutline), ColorTheme.Type.TextLight, typeof(BadgeVariable))]
[Keywords("Value", "Reference", "Global", "Project", "Scriptable Object")]
[Serializable]
public class TypeVariableInstance : TypeVariable
{
[SerializeField] private UnityEngine.Object m_Value;
public override Variable GetPreview(GameObject source) => this.m_Value as Variable;
public TypeVariableInstance()
{
this.m_Value = null;
}
public TypeVariableInstance(Variable variable)
{
this.m_Value = variable as UnityEngine.Object;
}
public TypeVariableInstance(GlobalVariable variable)
{
this.m_Value = variable;
}
public TypeVariableInstance(LocalVariable variable)
{
this.m_Value = variable;
}
public TypeVariableInstance(UnityEngine.Object instance)
{
this.m_Value = instance is Variable ? instance : null;
}
public override Variable Get(Args args)
{
return this.m_Value as Variable;
}
public override string ToString()
{
return this.m_Value != null
? this.m_Value.name
: TextUtils.TEXT_NULL;
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnEditorChange;
}
}