Destroy#
Game Object / Creation / Destroy
Description#
Destroys a chosen instance of a game object
Parameters#
| Name | Description |
|---|---|
| Game Object | The template game object that makes a copy |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("Destroy")]
[Image(typeof(IconCubeOutline), ColorTheme.Type.TextLight, typeof(BadgeCross))]
[Description("Destroys a chosen instance of a game object")]
[Category("Game Object/Creation/Destroy")]
[Parameter("Game Object", "The template game object that makes a copy")]
[Keywords("Delete", "Remove", "Vanish")]
[Serializable]
public class InstructionCoreGameObjectDestroy : Instruction
{
[SerializeField] private GetGameObject m_GameObject = new GetGameObject();
protected override string GetTitle(GameObject source) => $"Destroy {this.m_GameObject}";
protected override Awaitable Run(Args args)
{
GameObject gameObject = this.m_GameObject.Get(args);
if (gameObject != null) UnityEngine.Object.Destroy(gameObject);
return Done;
}
}
}