Description
When attempting to wire custom UnityEvent<T> fields via manage_components with set_property, MCP reports success but clears the m_Calls array instead of populating it with the provided callback data.
This affects both underscore-prefixed fields (_onEditClicked) and likely all UnityEvent fields.
Steps to Reproduce
- Create a MonoBehaviour with a UnityEvent field:
[SerializeField] private UnityEvent<MyType> _onCustomEvent;
-
Wire the event manually in Unity Inspector (so m_Calls has data)
-
Try to update via MCP:
{
"tool": "manage_components",
"params": {
"action": "set_property",
"target": 73018,
"search_method": "by_id",
"component_type": "NoteSystem.Views.UIRecurringNoteItem",
"properties": {
"_onEditClicked": {
"m_PersistentCalls": {
"m_Calls": [{
"m_Target": {"instanceID": 73180},
"m_TargetAssemblyTypeName": "NoteSystem.Views.UIRecurringNoteList, Assembly-CSharp",
"m_MethodName": "OnItemEditClicked",
"m_Mode": 0,
"m_CallState": 2
}]
}
}
}
}
}
-
MCP returns: {"success": true, "message": "Properties set..."}
-
Save scene and check .unity file - the event is now empty:
_onEditClicked:
m_PersistentCalls:
m_Calls: []
Expected Behavior
The m_Calls array should be populated with the provided callback:
_onEditClicked:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 794262283}
m_TargetAssemblyTypeName: NoteSystem.Views.UIRecurringNoteList, Assembly-CSharp
m_MethodName: OnItemEditClicked
m_Mode: 0
m_CallState: 2
Actual Behavior
- MCP reports success
m_Calls array is cleared/emptied
- Previously wired events are lost
Additional Context
- MCP version: Latest from main branch
- Unity version: 6000.1.2f1 (Unity 6)
- The field IS found (no "property not found" error)
- The issue is in serialization of the UnityEvent structure
Suggestion
The UnityEvent serialization likely needs special handling. When setting m_PersistentCalls.m_Calls, the code should:
- Create proper
PersistentCall objects
- Resolve
instanceID to proper Unity object references
- Use
SerializedObject/SerializedProperty API for reliable serialization
Workaround
Edit .unity scene file directly using fileIDs instead of instanceIDs.
Description
When attempting to wire custom
UnityEvent<T>fields viamanage_componentswithset_property, MCP reports success but clears them_Callsarray instead of populating it with the provided callback data.This affects both underscore-prefixed fields (
_onEditClicked) and likely all UnityEvent fields.Steps to Reproduce
Wire the event manually in Unity Inspector (so
m_Callshas data)Try to update via MCP:
{ "tool": "manage_components", "params": { "action": "set_property", "target": 73018, "search_method": "by_id", "component_type": "NoteSystem.Views.UIRecurringNoteItem", "properties": { "_onEditClicked": { "m_PersistentCalls": { "m_Calls": [{ "m_Target": {"instanceID": 73180}, "m_TargetAssemblyTypeName": "NoteSystem.Views.UIRecurringNoteList, Assembly-CSharp", "m_MethodName": "OnItemEditClicked", "m_Mode": 0, "m_CallState": 2 }] } } } } }MCP returns:
{"success": true, "message": "Properties set..."}Save scene and check
.unityfile - the event is now empty:Expected Behavior
The
m_Callsarray should be populated with the provided callback:Actual Behavior
m_Callsarray is cleared/emptiedAdditional Context
Suggestion
The UnityEvent serialization likely needs special handling. When setting
m_PersistentCalls.m_Calls, the code should:PersistentCallobjectsinstanceIDto proper Unity object referencesSerializedObject/SerializedPropertyAPI for reliable serializationWorkaround
Edit
.unityscene file directly using fileIDs instead of instanceIDs.