-
Notifications
You must be signed in to change notification settings - Fork 694
Description
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_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:
_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: 2Actual Behavior
- MCP reports success
m_Callsarray 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
PersistentCallobjects - Resolve
instanceIDto proper Unity object references - Use
SerializedObject/SerializedPropertyAPI for reliable serialization
Workaround
Edit .unity scene file directly using fileIDs instead of instanceIDs.