Skip to content

Commit 2c6f4eb

Browse files
committed
Update
1 parent c12bd38 commit 2c6f4eb

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

MCPForUnity/Editor/Tools/ManageComponents.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private static object RemoveComponent(JObject @params, JToken targetToken, strin
161161
{
162162
success = true,
163163
message = $"Component '{componentTypeName}' (index {componentIndex.Value}) removed from '{targetGo.name}'.",
164-
data = new { instanceID = targetGo.GetInstanceID() }
164+
data = new { instanceID = targetGo.GetInstanceID(), componentIndex = componentIndex.Value }
165165
};
166166
}
167167

MCPForUnity/Editor/Tools/Physics/PhysicsMaterialOps.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,15 @@ public static object Assign(JObject @params)
120120
if (componentIndex.HasValue)
121121
{
122122
var type3D = !string.IsNullOrEmpty(colliderType) ? UnityTypeResolver.ResolveComponent(colliderType) : typeof(Collider);
123-
if (type3D != null)
123+
if (type3D != null && typeof(Collider).IsAssignableFrom(type3D))
124124
{
125125
int count3D = go.GetComponents(type3D).Length;
126126
return new ErrorResponse($"component_index {componentIndex.Value} out of range. Found {count3D} '{type3D.Name}' collider(s) on '{go.name}'.");
127127
}
128+
else if (!string.IsNullOrEmpty(colliderType))
129+
{
130+
return new ErrorResponse($"Unknown or invalid 3D collider type: '{colliderType}'.");
131+
}
128132
}
129133
}
130134

@@ -152,11 +156,15 @@ public static object Assign(JObject @params)
152156
if (componentIndex.HasValue)
153157
{
154158
var type2D = !string.IsNullOrEmpty(colliderType) ? UnityTypeResolver.ResolveComponent(colliderType) : typeof(Collider2D);
155-
if (type2D != null)
159+
if (type2D != null && typeof(Collider2D).IsAssignableFrom(type2D))
156160
{
157161
int count2D = go.GetComponents(type2D).Length;
158162
return new ErrorResponse($"component_index {componentIndex.Value} out of range. Found {count2D} '{type2D.Name}' collider(s) on '{go.name}'.");
159163
}
164+
else if (!string.IsNullOrEmpty(colliderType))
165+
{
166+
return new ErrorResponse($"Unknown or invalid 2D collider type: '{colliderType}'.");
167+
}
160168
}
161169
}
162170

0 commit comments

Comments
 (0)