[注意事项] 程序启动路径句柄的editor部分依赖odin的属性包裹,如果没有odin还能运行吗? #50

Closed
opened 2026-07-15 15:01:14 +08:00 by lrss3 · 1 comment
Owner

如果在propertydrawer里自己写了EditorGUI.BeginProperty / EndProperty,就会发生下列报错:

InvalidOperationException: Stack empty.
System.Collections.Generic.Stack`1[T].ThrowForEmptyStack () (at <6073cf49ed704e958b8a66d540dea948>:0)
System.Collections.Generic.Stack`1[T].Pop () (at <6073cf49ed704e958b8a66d540dea948>:0)
UnityEditor.EditorGUI.EndProperty () (at <a017e354f3154926a5617fbac3a64fcc>:0)
XericLibraryEditor.MacroLibrary.MacroProgramFileDrawer.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at <c81f2816fcfe4f3ba88fb774450b841e>:0)
UnityEditor.PropertyDrawer.OnGUISafe (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at <a017e354f3154926a5617fbac3a64fcc>:0)
UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.Rect visibleArea) (at <a017e354f3154926a5617fbac3a64fcc>:0)
UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at <a017e354f3154926a5617fbac3a64fcc>:0)
System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <6073cf49ed704e958b8a66d540dea948>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
Sirenix.OdinInspector.Editor.UnityPropertyHandlerUtility.PropertyHandlerOnGUI (System.Object handler, UnityEngine.Rect rect, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.UnityPropertyDrawer`2[TDrawer,TDrawnType].DrawPropertyLayout (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.OdinDrawer.CallNextDrawer (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.Drawers.NullableReferenceDrawer`1[T].DrawPropertyLayout (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.OdinDrawer.CallNextDrawer (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.Drawers.FixUnityNullDrawer`1[T].DrawPropertyLayout (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.OdinDrawer.CallNextDrawer (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.Drawers.ReferenceDrawer`1[T].DrawPropertyLayout (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.OdinDrawer.CallNextDrawer (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.Drawers.PropertyContextMenuDrawer`1[T].DrawPropertyLayout (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.OdinDrawer.DrawProperty (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.InspectorProperty.Draw (UnityEngine.GUIContent defaultLabel) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Rethrow as OdinPropertyException: This error occurred while being drawn by Odin.
Current IMGUI event: Used
Odin Property Path: ProgramFile
Odin Drawer Chain:
> PropertyContextMenuDrawer<MacroProcess.ProgramFile>
> ReferenceDrawer<MacroProcess.ProgramFile>
> FixUnityNullDrawer<MacroProcess.ProgramFile>
> NullableReferenceDrawer<MacroProcess.ProgramFile>
> UnityPropertyDrawer<MacroProgramFileDrawer, MacroProcess.ProgramFile>
> CompositeDrawer.
UnityEngine.Debug:LogException(Exception)
Sirenix.OdinInspector.Editor.InspectorProperty:Draw(GUIContent)
Sirenix.OdinInspector.Editor.InspectorProperty:Draw()
Sirenix.OdinInspector.Editor.Drawers.UnityObjectRootDrawer`1:DrawPropertyLayout(GUIContent)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent)
Sirenix.OdinInspector.Editor.Drawers.FixBrokenUnityObjectWrapperDrawer`1:DrawPropertyLayout(GUIContent)
Sirenix.OdinInspector.Editor.OdinDrawer:DrawProperty(GUIContent)
Sirenix.OdinInspector.Editor.InspectorProperty:Draw(GUIContent)
Sirenix.OdinInspector.Editor.PropertyTree:DrawProperties()
Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean)
Sirenix.OdinInspector.Editor.OdinEditor:DrawTree()
Sirenix.OdinInspector.Editor.OdinEditor:DrawOdinInspector()
Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI()
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

InvalidOperationException: Stack empty.
System.Collections.Generic.Stack`1[T].ThrowForEmptyStack () (at <6073cf49ed704e958b8a66d540dea948>:0)
System.Collections.Generic.Stack`1[T].Pop () (at <6073cf49ed704e958b8a66d540dea948>:0)
Sirenix.OdinInspector.Editor.InspectorProperty.PopDraw () (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.InspectorProperty.Draw (UnityEngine.GUIContent defaultLabel) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.InspectorProperty.Draw () (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.Drawers.UnityObjectRootDrawer`1[T].DrawPropertyLayout (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.OdinDrawer.CallNextDrawer (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.Drawers.FixBrokenUnityObjectWrapperDrawer`1[T].DrawPropertyLayout (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.OdinDrawer.DrawProperty (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.InspectorProperty.Draw (UnityEngine.GUIContent defaultLabel) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Rethrow as OdinPropertyException: This error occurred while being drawn by Odin.
Current IMGUI event: Used
Odin Property Path: $ROOT
Odin Drawer Chain:
> FixBrokenUnityObjectWrapperDrawer<AlgorithmService>
> UnityObjectRootDrawer<AlgorithmService>
> AbstractTypeUnityPropertyDrawer<ObjectDrawer, Object, AlgorithmService>
> CompositeDrawer.
UnityEngine.Debug:LogException(Exception)
Sirenix.OdinInspector.Editor.InspectorProperty:Draw(GUIContent)
Sirenix.OdinInspector.Editor.PropertyTree:DrawProperties()
Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean)
Sirenix.OdinInspector.Editor.OdinEditor:DrawTree()
Sirenix.OdinInspector.Editor.OdinEditor:DrawOdinInspector()
Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI()
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

InvalidOperationException: Stack empty.
System.Collections.Generic.Stack`1[T].ThrowForEmptyStack () (at <6073cf49ed704e958b8a66d540dea948>:0)
System.Collections.Generic.Stack`1[T].Pop () (at <6073cf49ed704e958b8a66d540dea948>:0)
Sirenix.OdinInspector.Editor.InspectorProperty.PopDraw () (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.InspectorProperty.Draw (UnityEngine.GUIContent defaultLabel) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.PropertyTree.DrawProperties () (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.PropertyTree.Draw (System.Boolean applyUndo) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.OdinEditor.DrawTree () (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.OdinEditor.DrawOdinInspector () (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
Sirenix.OdinInspector.Editor.OdinEditor.OnInspectorGUI () (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <5cf6bb2c14f1476f9cd6b153e70ca8b2>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)


如果在propertydrawer里自己写了EditorGUI.BeginProperty / EndProperty,就会发生下列报错: ``` InvalidOperationException: Stack empty. System.Collections.Generic.Stack`1[T].ThrowForEmptyStack () (at <6073cf49ed704e958b8a66d540dea948>:0) System.Collections.Generic.Stack`1[T].Pop () (at <6073cf49ed704e958b8a66d540dea948>:0) UnityEditor.EditorGUI.EndProperty () (at <a017e354f3154926a5617fbac3a64fcc>:0) XericLibraryEditor.MacroLibrary.MacroProgramFileDrawer.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at <c81f2816fcfe4f3ba88fb774450b841e>:0) UnityEditor.PropertyDrawer.OnGUISafe (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at <a017e354f3154926a5617fbac3a64fcc>:0) UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.Rect visibleArea) (at <a017e354f3154926a5617fbac3a64fcc>:0) UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at <a017e354f3154926a5617fbac3a64fcc>:0) System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <6073cf49ed704e958b8a66d540dea948>:0) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. Sirenix.OdinInspector.Editor.UnityPropertyHandlerUtility.PropertyHandlerOnGUI (System.Object handler, UnityEngine.Rect rect, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.UnityPropertyDrawer`2[TDrawer,TDrawnType].DrawPropertyLayout (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.OdinDrawer.CallNextDrawer (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.Drawers.NullableReferenceDrawer`1[T].DrawPropertyLayout (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.OdinDrawer.CallNextDrawer (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.Drawers.FixUnityNullDrawer`1[T].DrawPropertyLayout (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.OdinDrawer.CallNextDrawer (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.Drawers.ReferenceDrawer`1[T].DrawPropertyLayout (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.OdinDrawer.CallNextDrawer (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.Drawers.PropertyContextMenuDrawer`1[T].DrawPropertyLayout (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.OdinDrawer.DrawProperty (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.InspectorProperty.Draw (UnityEngine.GUIContent defaultLabel) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Rethrow as OdinPropertyException: This error occurred while being drawn by Odin. Current IMGUI event: Used Odin Property Path: ProgramFile Odin Drawer Chain: > PropertyContextMenuDrawer<MacroProcess.ProgramFile> > ReferenceDrawer<MacroProcess.ProgramFile> > FixUnityNullDrawer<MacroProcess.ProgramFile> > NullableReferenceDrawer<MacroProcess.ProgramFile> > UnityPropertyDrawer<MacroProgramFileDrawer, MacroProcess.ProgramFile> > CompositeDrawer. UnityEngine.Debug:LogException(Exception) Sirenix.OdinInspector.Editor.InspectorProperty:Draw(GUIContent) Sirenix.OdinInspector.Editor.InspectorProperty:Draw() Sirenix.OdinInspector.Editor.Drawers.UnityObjectRootDrawer`1:DrawPropertyLayout(GUIContent) Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) Sirenix.OdinInspector.Editor.Drawers.FixBrokenUnityObjectWrapperDrawer`1:DrawPropertyLayout(GUIContent) Sirenix.OdinInspector.Editor.OdinDrawer:DrawProperty(GUIContent) Sirenix.OdinInspector.Editor.InspectorProperty:Draw(GUIContent) Sirenix.OdinInspector.Editor.PropertyTree:DrawProperties() Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean) Sirenix.OdinInspector.Editor.OdinEditor:DrawTree() Sirenix.OdinInspector.Editor.OdinEditor:DrawOdinInspector() Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI() UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) InvalidOperationException: Stack empty. System.Collections.Generic.Stack`1[T].ThrowForEmptyStack () (at <6073cf49ed704e958b8a66d540dea948>:0) System.Collections.Generic.Stack`1[T].Pop () (at <6073cf49ed704e958b8a66d540dea948>:0) Sirenix.OdinInspector.Editor.InspectorProperty.PopDraw () (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.InspectorProperty.Draw (UnityEngine.GUIContent defaultLabel) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.InspectorProperty.Draw () (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.Drawers.UnityObjectRootDrawer`1[T].DrawPropertyLayout (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.OdinDrawer.CallNextDrawer (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.Drawers.FixBrokenUnityObjectWrapperDrawer`1[T].DrawPropertyLayout (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.OdinDrawer.DrawProperty (UnityEngine.GUIContent label) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.InspectorProperty.Draw (UnityEngine.GUIContent defaultLabel) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Rethrow as OdinPropertyException: This error occurred while being drawn by Odin. Current IMGUI event: Used Odin Property Path: $ROOT Odin Drawer Chain: > FixBrokenUnityObjectWrapperDrawer<AlgorithmService> > UnityObjectRootDrawer<AlgorithmService> > AbstractTypeUnityPropertyDrawer<ObjectDrawer, Object, AlgorithmService> > CompositeDrawer. UnityEngine.Debug:LogException(Exception) Sirenix.OdinInspector.Editor.InspectorProperty:Draw(GUIContent) Sirenix.OdinInspector.Editor.PropertyTree:DrawProperties() Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean) Sirenix.OdinInspector.Editor.OdinEditor:DrawTree() Sirenix.OdinInspector.Editor.OdinEditor:DrawOdinInspector() Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI() UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) InvalidOperationException: Stack empty. System.Collections.Generic.Stack`1[T].ThrowForEmptyStack () (at <6073cf49ed704e958b8a66d540dea948>:0) System.Collections.Generic.Stack`1[T].Pop () (at <6073cf49ed704e958b8a66d540dea948>:0) Sirenix.OdinInspector.Editor.InspectorProperty.PopDraw () (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.InspectorProperty.Draw (UnityEngine.GUIContent defaultLabel) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.PropertyTree.DrawProperties () (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.PropertyTree.Draw (System.Boolean applyUndo) (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.OdinEditor.DrawTree () (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.OdinEditor.DrawOdinInspector () (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) Sirenix.OdinInspector.Editor.OdinEditor.OnInspectorGUI () (at <c7e3bb3232664ef4be3a8d9615bf0a19>:0) UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <5cf6bb2c14f1476f9cd6b153e70ca8b2>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) ```
Author
Owner

解耦了

解耦了
lrss3 closed this issue 2026-07-25 11:10:53 +08:00
Sign in to join this conversation.