Skip to content

Commit 632488c

Browse files
Sebastian Muehrclaude
andcommitted
fix(manage_gameobject): compare flags directly for partial static objects
targetGo.isStatic returns true when *any* flag is set, so a partially static object (e.g. only Navigation) would skip the update when is_static=true was requested. Compare GetStaticEditorFlags() against the desired flags instead. Also adds a "false" string coercion test per review feedback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2d3c71e commit 632488c

2 files changed

Lines changed: 35 additions & 4 deletions

File tree

MCPForUnity/Editor/Tools/GameObjects/GameObjectModify.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,16 @@ internal static object Handle(JObject @params, JToken targetToken, string search
152152
}
153153

154154
bool? isStatic = @params["isStatic"]?.ToObject<bool?>();
155-
if (isStatic.HasValue && targetGo.isStatic != isStatic.Value)
155+
if (isStatic.HasValue)
156156
{
157-
var flags = isStatic.Value ? (StaticEditorFlags)~0 : 0;
158-
GameObjectUtility.SetStaticEditorFlags(targetGo, flags);
159-
modified = true;
157+
var desiredFlags = isStatic.Value ? (StaticEditorFlags)~0 : 0;
158+
var currentFlags = GameObjectUtility.GetStaticEditorFlags(targetGo);
159+
160+
if (currentFlags != desiredFlags)
161+
{
162+
GameObjectUtility.SetStaticEditorFlags(targetGo, desiredFlags);
163+
modified = true;
164+
}
160165
}
161166

162167
Vector3? position = VectorParsing.ParseVector3(@params["position"]);

Server/tests/integration/test_manage_gameobject_is_static.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,32 @@ async def fake_send(cmd, params, **kwargs):
8484
assert captured["params"]["isStatic"] is True
8585

8686

87+
@pytest.mark.asyncio
88+
async def test_manage_gameobject_is_static_string_false_coercion(monkeypatch):
89+
"""Test that string 'false' is coerced to bool for is_static."""
90+
captured = {}
91+
92+
async def fake_send(cmd, params, **kwargs):
93+
captured["params"] = params
94+
return {"success": True, "data": {}}
95+
96+
monkeypatch.setattr(
97+
manage_go_mod,
98+
"async_send_command_with_retry",
99+
fake_send,
100+
)
101+
102+
resp = await manage_go_mod.manage_gameobject(
103+
ctx=DummyContext(),
104+
action="modify",
105+
target="Ground",
106+
is_static="false",
107+
)
108+
109+
assert resp.get("success") is True
110+
assert captured["params"]["isStatic"] is False
111+
112+
87113
@pytest.mark.asyncio
88114
async def test_manage_gameobject_is_static_omitted(monkeypatch):
89115
"""Test that omitting is_static does not include isStatic in params."""

0 commit comments

Comments
 (0)