|
@@ -36,7 +36,7 @@ namespace LLM.Editor.Commands
|
|
|
|
|
|
_params.scriptName ??= _params.componentName;
|
|
_params.scriptName ??= _params.componentName;
|
|
|
|
|
|
- var targetObject = ResolveIdentifier(_params.targetIdentifier);
|
|
|
|
|
|
+ var targetObject = ResolveIdentifier(context, _params.targetIdentifier);
|
|
if (!targetObject)
|
|
if (!targetObject)
|
|
{
|
|
{
|
|
Debug.LogError($"[AddComponentCommand] Could not find target with identifier '{_params.targetIdentifier}'.");
|
|
Debug.LogError($"[AddComponentCommand] Could not find target with identifier '{_params.targetIdentifier}'.");
|
|
@@ -118,8 +118,12 @@ namespace LLM.Editor.Commands
|
|
return foundChild ? foundChild.gameObject : null;
|
|
return foundChild ? foundChild.gameObject : null;
|
|
}
|
|
}
|
|
|
|
|
|
- private static UnityEngine.Object ResolveIdentifier(string identifier)
|
|
|
|
|
|
+ private static UnityEngine.Object ResolveIdentifier(Data.CommandContext context, string identifier)
|
|
{
|
|
{
|
|
|
|
+ if (context.CurrentSubject is GameObject subjectGo && subjectGo.name == identifier)
|
|
|
|
+ {
|
|
|
|
+ return subjectGo;
|
|
|
|
+ }
|
|
if (string.IsNullOrEmpty(identifier)) return null;
|
|
if (string.IsNullOrEmpty(identifier)) return null;
|
|
if (int.TryParse(identifier, out var instanceId))
|
|
if (int.TryParse(identifier, out var instanceId))
|
|
{
|
|
{
|