Game Object Layer#
Game Object / Game Object Layer
Can Read
Cannot Write
Description#
Integer identifying the layer the GameObject is assigned to
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Game Object Layer")]
[Category("Game Object/Layer")]
[Description("Integer identifying the layer the GameObject is assigned to")]
[Image(typeof(IconLayers), ColorTheme.Type.TextLight)]
[Serializable]
public class TypeNumberGameObjectLayer : TypeNumber
{
[SerializeField] private GetGameObject m_GameObject = new GetGameObject();
public override double GetPreview(GameObject source)
{
GameObject gameObject = this.m_GameObject.GetPreview(source);
return gameObject != null ? gameObject.layer : 0;
}
public override double Get(Args args)
{
GameObject gameObject = this.m_GameObject.Get(args);
return gameObject != null ? gameObject.layer : 0;
}
public override string ToString()
{
return $"{this.m_GameObject} Layer";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}