Set Layer#
Game Object / Set Layer
Description#
Sets the layer of the Game Object instance
Parameters#
| Name | Description |
|---|---|
| Game Object | The game object reference |
| Layer | The new layer for the game object |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("Set Layer")]
[Image(typeof(IconLayers), ColorTheme.Type.TextLight)]
[Description("Sets the layer of the Game Object instance")]
[Category("Game Object/Set Layer")]
[Parameter("Game Object", "The game object reference")]
[Parameter("Layer", "The new layer for the game object")]
[Serializable]
public class InstructionCoreGameObjectSetLayer : Instruction
{
[SerializeField] private GetGameObject m_GameObject = new GetGameObject();
[SerializeField] private GetInteger m_Layer = new GetInteger();
protected override string GetTitle(GameObject source) => $"Set {this.m_GameObject} Layer = {this.m_Layer}";
protected override Awaitable Run(Args args)
{
GameObject gameObject = this.m_GameObject.Get(args);
if (gameObject == null) return Done;
int layer = this.m_Layer.GetInt(args);
gameObject.layer = layer;
return Done;
}
}
}