Files
Echo/Assets/_Project/Scripts/LLM Manager/Commands/SetActiveCommandReceiver.cs
T

26 lines
841 B
C#
Raw Normal View History

2026-07-08 19:53:15 +08:00
using UnityEngine;
namespace LLM.Commands
{
public class SetActiveCommandReceiver : LLMCommandReceiverBase
{
[SerializeField] private GameObject target;
public override bool TryExecute(LLMCommand command)
{
if (command == null) return false;
if (!string.Equals(command.type, "SetActive", System.StringComparison.OrdinalIgnoreCase)) return false;
if (target == null) return false;
bool value = command.value;
if (string.Equals(command.action, "Enable", System.StringComparison.OrdinalIgnoreCase)) value = true;
else if (string.Equals(command.action, "Disable", System.StringComparison.OrdinalIgnoreCase)) value = false;
if (target.activeSelf != value) target.SetActive(value);
return true;
}
}
}