26 lines
841 B
C#
26 lines
841 B
C#
|
|
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;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|