Find by Name#
Game Object / Search / Find by Name
Description#
Stores the the first game object with the specified name or hierarchy path
Parameters#
| Name | Description |
|---|---|
| Name | The name or hierarchy path to search for |
| Set | Where the game object reference is optionally stored |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("Find by Name")]
[Image(typeof(IconCubeOutline), ColorTheme.Type.TextLight, typeof(BadgeMagnifier))]
[Description("Stores the the first game object with the specified name or hierarchy path")]
[Category("Game Object/Search/Find by Name")]
[Parameter("Name", "The name or hierarchy path to search for")]
[Parameter("Set", "Where the game object reference is optionally stored")]
[Serializable]
public class InstructionCoreGameObjectFindByName : Instruction
{
[SerializeField] private GetString m_Name = new GetString();
[SerializeField] private SetGameObject m_Set = new SetGameObject(new TypeGameObjectNoneSet());
protected override string GetTitle(GameObject source) => $"Find with {this.m_Name}";
protected override Awaitable Run(Args args)
{
string name = this.m_Name.Get(args);
GameObject gameObject = GameObject.Find(name);
this.m_Set.Set(gameObject, args);
return Done;
}
}
}