fix: search inactive objects when setActive=true in modify (#581)
When trying to activate an inactive GameObject via manage_gameobject modify with setActive=true, the lookup would fail because inactive objects were not included in the search by default. Now automatically sets searchInactive=true when setActive=true is specified, allowing inactive objects to be found and activated.main
parent
e617753b4e
commit
8252e6debc
|
|
@ -14,7 +14,15 @@ namespace MCPForUnity.Editor.Tools.GameObjects
|
|||
{
|
||||
internal static object Handle(JObject @params, JToken targetToken, string searchMethod)
|
||||
{
|
||||
GameObject targetGo = ManageGameObjectCommon.FindObjectInternal(targetToken, searchMethod);
|
||||
// When setActive=true is specified, we need to search for inactive objects
|
||||
// otherwise we can't find an inactive object to activate it
|
||||
JObject findParams = null;
|
||||
if (@params["setActive"]?.ToObject<bool?>() == true)
|
||||
{
|
||||
findParams = new JObject { ["searchInactive"] = true };
|
||||
}
|
||||
|
||||
GameObject targetGo = ManageGameObjectCommon.FindObjectInternal(targetToken, searchMethod, findParams);
|
||||
if (targetGo == null)
|
||||
{
|
||||
return new ErrorResponse($"Target GameObject ('{targetToken}') not found using method '{searchMethod ?? "default"}'.");
|
||||
|
|
|
|||
Loading…
Reference in New Issue