Files
Continentis/Assets/Scripts/SLSUtilities/CommandQueue/Examples/Cmd_GetAndLogVariable.cs
SoulliesOfficial d09b58fd80 架构大更
2026-03-20 11:56:50 -04:00

27 lines
920 B
C#

using Cysharp.Threading.Tasks;
using SLSFramework.General;
using UnityEngine;
namespace SLSFramework.General
{
/// <summary>从 outerContext 中读取一个变量并输出到控制台。</summary>
public class Cmd_GetAndLogVariable : CommandBase
{
private readonly string variableName;
public Cmd_GetAndLogVariable(string variableName)
{
this.variableName = variableName;
}
protected override UniTask ExecuteAsync(CommandContext outerContext)
{
if (outerContext.context.TryGetValue(variableName, out object value))
Debug.Log($"[Cmd_GetAndLogVariable] 获取变量 '{variableName}',值为: '{value?.ToString() ?? "null"}'");
else
Debug.LogWarning($"[Cmd_GetAndLogVariable] 变量 '{variableName}' 未在上下文中定义。");
return UniTask.CompletedTask;
}
}
}