Game Object#
Can Read
Cannot Write
Description#
A Local Variable attached to a Game Object instance
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Game Object")]
[Category("Game Object")]
[Description("A Local Variable attached to a Game Object instance")]
[Image(typeof(IconCubeOutline), ColorTheme.Type.TextLight)]
[Keywords("Component", "Reference")]
[Serializable]
public class TypeVariableGameObject : TypeVariable
{
[SerializeField] private GetGameObject m_GameObject;
public override Variable GetPreview(GameObject source)
{
GameObject gameObject = this.m_GameObject.GetPreview(source);
return gameObject != null
? gameObject.GetComponent<LocalVariable>()
: null;
}
public TypeVariableGameObject()
{
this.m_GameObject = new GetGameObject();
}
public TypeVariableGameObject(GameObject gameObject)
{
this.m_GameObject = new GetGameObject(gameObject);
}
public TypeVariableGameObject(Component component)
{
this.m_GameObject = new GetGameObject(component);
}
public override Variable Get(Args args)
{
return this.m_GameObject.Get<LocalVariable>(args);
}
public override string ToString()
{
return this.m_GameObject.ToString();
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnEditorChange;
}
}