Game Object Exists#
Game Object / Game Object Exists
Can Read
Cannot Write
Description#
Returns true if the game object exists and is not null
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Game Object Exists")]
[Category("Game Object/Exists")]
[Description("Returns true if the game object exists and is not null")]
[Image(typeof(IconCubeOutline), ColorTheme.Type.Blue)]
[Serializable]
public class TypeBoolGameObjectExists : TypeBool
{
[SerializeField] private GetGameObject m_GameObject = new GetGameObject();
public override bool GetPreview(GameObject source)
{
GameObject gameObject = this.m_GameObject.GetPreview(source);
return gameObject != null;
}
public override bool Get(Args args)
{
GameObject gameObject = this.m_GameObject.Get(args);
return gameObject != null;
}
public override string ToString()
{
return $"{this.m_GameObject} Exists";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}