TextblockBuilder新的属性绘制模块与ODIN插件绘制功能不兼容,在模式1绘制时提示模块代码中调用了一个声明但未实现的方法 #15

Open
opened 2025-07-29 14:16:54 +08:00 by lrss3 · 2 comments
Owner

报错内容:

NotImplementedException: The method or operation is not implemented.
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
Rethrow as OdinPropertyException: This error occurred while being drawn by Odin.
Current IMGUI event: Layout
Odin Property Path: contextBuilderRed
Odin Drawer Chain:

PropertyContextMenuDrawer<MacroMath.TextBlockBuilder>
ReferenceDrawer<MacroMath.TextBlockBuilder>
FixUnityNullDrawer<MacroMath.TextBlockBuilder>
NullableReferenceDrawer<MacroMath.TextBlockBuilder>
UnityPropertyDrawer<TextBlockBuilderDrawer, MacroMath.TextBlockBuilder>
CompositeDrawer.

[Exception] NotImplementedException: The method or operation is not implemented.
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
Rethrow as OdinPropertyException: This error occurred while being drawn by Odin.
Current IMGUI event: Layout
Odin Property Path: contextBuilderRed
Odin Drawer Chain:

PropertyContextMenuDrawer<MacroMath.TextBlockBuilder>
ReferenceDrawer<MacroMath.TextBlockBuilder>
FixUnityNullDrawer<MacroMath.TextBlockBuilder>
NullableReferenceDrawer<MacroMath.TextBlockBuilder>
UnityPropertyDrawer<TextBlockBuilderDrawer, MacroMath.TextBlockBuilder>
CompositeDrawer.
MacroMath+TextBlockBuilder.TryParse() at <32ccd1b2786241bf93afe92e258b8a2c>:0

TextBlockBuilderDrawer.OnGUI() at <2c1466ac687b4b1b9a6fd1a87801143b>:0

PropertyDrawer.OnGUISafe() at :0

PropertyHandler.OnGUI() at :0

PropertyHandler.OnGUI() at :0

RuntimeMethodInfo.Invoke() at <6073cf49ed704e958b8a66d540dea948>:0

UnityPropertyHandlerUtility.PropertyHandlerOnGUI() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/UnityPropertyHandlerUtility.cs:216

Sirenix.OdinInspector.Editor.UnityPropertyDrawer`2[TDrawer,TDrawnType].DrawPropertyLayout() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/UnityPropertyDrawer.cs:127

OdinDrawer.CallNextDrawer() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:155

Sirenix.OdinInspector.Editor.Drawers.NullableReferenceDrawer`1[T].DrawPropertyLayout() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/NullableReferenceDrawer.cs:104

OdinDrawer.CallNextDrawer() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:155

Sirenix.OdinInspector.Editor.Drawers.FixUnityNullDrawer`1[T].DrawPropertyLayout() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/FixUnityNullDrawer.cs:87

OdinDrawer.CallNextDrawer() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:155

Sirenix.OdinInspector.Editor.Drawers.ReferenceDrawer`1[T].DrawPropertyLayout() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/ReferenceDrawer.cs:118

OdinDrawer.CallNextDrawer() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:155

Sirenix.OdinInspector.Editor.Drawers.PropertyContextMenuDrawer`1[T].DrawPropertyLayout() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/PropertyContextMenuDrawer.cs:659

OdinDrawer.DrawProperty() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:109

InspectorProperty.Draw() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:849

Debug.LogException()

InspectorProperty.Draw() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:926

InspectorProperty.Draw() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:737

UnityObjectRootDrawer`1.DrawPropertyLayout() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/UnityObjectRootDrawer.cs:60

OdinDrawer.CallNextDrawer() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:155

FixBrokenUnityObjectWrapperDrawer`1.DrawPropertyLayout() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/FixBrokenUnityObjectWrapperDrawer.cs:41

OdinDrawer.DrawProperty() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:109

InspectorProperty.Draw() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:849

PropertyTree.DrawProperties() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:556

PropertyTree.Draw() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:448

OdinEditor.DrawTree() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:97

OdinEditor.DrawOdinInspector() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:254

OdinEditor.OnInspectorGUI() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:79

GUIUtility.ProcessEvent()

报错内容: NotImplementedException: The method or operation is not implemented. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. Rethrow as OdinPropertyException: This error occurred while being drawn by Odin. Current IMGUI event: Layout Odin Property Path: contextBuilderRed Odin Drawer Chain: > PropertyContextMenuDrawer<MacroMath.TextBlockBuilder> > ReferenceDrawer<MacroMath.TextBlockBuilder> > FixUnityNullDrawer<MacroMath.TextBlockBuilder> > NullableReferenceDrawer<MacroMath.TextBlockBuilder> > UnityPropertyDrawer<TextBlockBuilderDrawer, MacroMath.TextBlockBuilder> > CompositeDrawer. [Exception] NotImplementedException: The method or operation is not implemented. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. Rethrow as OdinPropertyException: This error occurred while being drawn by Odin. Current IMGUI event: Layout Odin Property Path: contextBuilderRed Odin Drawer Chain: > PropertyContextMenuDrawer<MacroMath.TextBlockBuilder> > ReferenceDrawer<MacroMath.TextBlockBuilder> > FixUnityNullDrawer<MacroMath.TextBlockBuilder> > NullableReferenceDrawer<MacroMath.TextBlockBuilder> > UnityPropertyDrawer<TextBlockBuilderDrawer, MacroMath.TextBlockBuilder> > CompositeDrawer. MacroMath+TextBlockBuilder.TryParse() at <32ccd1b2786241bf93afe92e258b8a2c>:0 TextBlockBuilderDrawer.OnGUI() at <2c1466ac687b4b1b9a6fd1a87801143b>:0 PropertyDrawer.OnGUISafe() at <a017e354f3154926a5617fbac3a64fcc>:0 PropertyHandler.OnGUI() at <a017e354f3154926a5617fbac3a64fcc>:0 PropertyHandler.OnGUI() at <a017e354f3154926a5617fbac3a64fcc>:0 RuntimeMethodInfo.Invoke() at <6073cf49ed704e958b8a66d540dea948>:0 UnityPropertyHandlerUtility.PropertyHandlerOnGUI() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/UnityPropertyHandlerUtility.cs:216 Sirenix.OdinInspector.Editor.UnityPropertyDrawer`2[TDrawer,TDrawnType].DrawPropertyLayout() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/UnityPropertyDrawer.cs:127 OdinDrawer.CallNextDrawer() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:155 Sirenix.OdinInspector.Editor.Drawers.NullableReferenceDrawer`1[T].DrawPropertyLayout() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/NullableReferenceDrawer.cs:104 OdinDrawer.CallNextDrawer() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:155 Sirenix.OdinInspector.Editor.Drawers.FixUnityNullDrawer`1[T].DrawPropertyLayout() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/FixUnityNullDrawer.cs:87 OdinDrawer.CallNextDrawer() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:155 Sirenix.OdinInspector.Editor.Drawers.ReferenceDrawer`1[T].DrawPropertyLayout() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/ReferenceDrawer.cs:118 OdinDrawer.CallNextDrawer() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:155 Sirenix.OdinInspector.Editor.Drawers.PropertyContextMenuDrawer`1[T].DrawPropertyLayout() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/PropertyContextMenuDrawer.cs:659 OdinDrawer.DrawProperty() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:109 InspectorProperty.Draw() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:849 Debug.LogException() InspectorProperty.Draw() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:926 InspectorProperty.Draw() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:737 UnityObjectRootDrawer`1.DrawPropertyLayout() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/UnityObjectRootDrawer.cs:60 OdinDrawer.CallNextDrawer() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:155 FixBrokenUnityObjectWrapperDrawer`1.DrawPropertyLayout() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/FixBrokenUnityObjectWrapperDrawer.cs:41 OdinDrawer.DrawProperty() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:109 InspectorProperty.Draw() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:849 PropertyTree.DrawProperties() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:556 PropertyTree.Draw() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:448 OdinEditor.DrawTree() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:97 OdinEditor.DrawOdinInspector() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:254 OdinEditor.OnInspectorGUI() at W:/Odin/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:79 GUIUtility.ProcessEvent()
lrss3 added this to the XericLibrary下一更新阶段 milestone 2025-07-29 14:16:54 +08:00
lrss3 self-assigned this 2025-07-29 14:16:54 +08:00
Author
Owner

这个错误是典型的 NotImplementedException,通常表示代码中调用了一个声明但未实现的方法。结合 Odin 插件的上下文,问题可能出在以下几个方面:

自定义序列化或绘制器中存在未实现的方法
Odin 插件与项目代码的兼容性问题
特定属性的绘制逻辑不完整
解决步骤

  1. 检查 MacroMath.TextBlockBuilder 类
    首先查看该类是否包含未实现的虚方法、抽象方法或接口方法。特别注意:

任何标记为 abstract 的方法是否在子类中实现
接口实现是否完整
是否有方法体为空或抛出 NotImplementedException 的代码

例如,以下代码会触发此错误:

csharp
public class TextBlockBuilder
{
public virtual string BuildText()
{
throw new NotImplementedException(); // 问题所在
}
}
2. 检查 Odin 自定义绘制器
如果你为 TextBlockBuilder 类创建了自定义 Odin 绘制器(如 [DrawerPriority] 或 [Sirenix.OdinInspector.Editor.CustomDrawer]),请确保所有必需的方法都已实现。

例如,一个不完整的绘制器:

csharp
public class TextBlockBuilderDrawer : OdinValueDrawer
{
protected override void DrawPropertyLayout(GUIContent label)
{
// 未实现任何绘制逻辑
}
}
3. 检查 Odin 插件版本兼容性
确保使用的 Odin 版本与你的 Unity 版本兼容。某些版本的 Odin 可能不支持特定的 Unity 功能或 API。建议:

更新 Odin 插件到最新稳定版本
查看 Odin 官方文档或论坛,确认已知的兼容性问题
调试建议
添加断点或日志
在 TextBlockBuilder 类的关键方法中添加日志输出,确认错误发生的具体位置:

csharp
public class TextBlockBuilder
{
public virtual string BuildText()
{
Debug.Log("BuildText method called"); // 添加日志
// 实现代码...
}
}

临时禁用 Odin 绘制器
在属性上添加 [ShowInInspector] 或 [OdinSerialize] 特性,绕过可能的自定义绘制器:

csharp
[ShowInInspector]
public TextBlockBuilder contextBuilderRed { get; set; }

检查 Odin 插件配置
在 Unity 的菜单栏中选择 Tools > Sirenix > Odin Inspector > Preferences,检查是否有影响序列化或绘制的配置选项。
常见原因总结
原因 解决方法
抽象方法未实现 在子类中实现所有抽象方法
接口方法未实现 确保类实现了所有接口方法
自定义绘制器不完整 补全 DrawPropertyLayout 或其他必需的绘制方法
Odin 版本不兼容 更新 Odin 插件或调整 Unity 版本
反射调用的方法缺失 检查通过反射调用的方法是否存在并正确实现

通过以上步骤,应该能定位并解决 NotImplementedException 的问题。如果问题仍然存在,建议提供更多的代码细节(特别是 TextBlockBuilder 类的实现)以便进一步分析。

这个错误是典型的 NotImplementedException,通常表示代码中调用了一个声明但未实现的方法。结合 Odin 插件的上下文,问题可能出在以下几个方面: 自定义序列化或绘制器中存在未实现的方法 Odin 插件与项目代码的兼容性问题 特定属性的绘制逻辑不完整 解决步骤 1. 检查 MacroMath.TextBlockBuilder 类 首先查看该类是否包含未实现的虚方法、抽象方法或接口方法。特别注意: 任何标记为 abstract 的方法是否在子类中实现 接口实现是否完整 是否有方法体为空或抛出 NotImplementedException 的代码 例如,以下代码会触发此错误: csharp public class TextBlockBuilder { public virtual string BuildText() { throw new NotImplementedException(); // 问题所在 } } 2. 检查 Odin 自定义绘制器 如果你为 TextBlockBuilder 类创建了自定义 Odin 绘制器(如 [DrawerPriority] 或 [Sirenix.OdinInspector.Editor.CustomDrawer]),请确保所有必需的方法都已实现。 例如,一个不完整的绘制器: csharp public class TextBlockBuilderDrawer : OdinValueDrawer<TextBlockBuilder> { protected override void DrawPropertyLayout(GUIContent label) { // 未实现任何绘制逻辑 } } 3. 检查 Odin 插件版本兼容性 确保使用的 Odin 版本与你的 Unity 版本兼容。某些版本的 Odin 可能不支持特定的 Unity 功能或 API。建议: 更新 Odin 插件到最新稳定版本 查看 Odin 官方文档或论坛,确认已知的兼容性问题 调试建议 添加断点或日志 在 TextBlockBuilder 类的关键方法中添加日志输出,确认错误发生的具体位置: csharp public class TextBlockBuilder { public virtual string BuildText() { Debug.Log("BuildText method called"); // 添加日志 // 实现代码... } } 临时禁用 Odin 绘制器 在属性上添加 [ShowInInspector] 或 [OdinSerialize] 特性,绕过可能的自定义绘制器: csharp [ShowInInspector] public TextBlockBuilder contextBuilderRed { get; set; } 检查 Odin 插件配置 在 Unity 的菜单栏中选择 Tools > Sirenix > Odin Inspector > Preferences,检查是否有影响序列化或绘制的配置选项。 常见原因总结 原因 解决方法 抽象方法未实现 在子类中实现所有抽象方法 接口方法未实现 确保类实现了所有接口方法 自定义绘制器不完整 补全 DrawPropertyLayout 或其他必需的绘制方法 Odin 版本不兼容 更新 Odin 插件或调整 Unity 版本 反射调用的方法缺失 检查通过反射调用的方法是否存在并正确实现 通过以上步骤,应该能定位并解决 NotImplementedException 的问题。如果问题仍然存在,建议提供更多的代码细节(特别是 TextBlockBuilder 类的实现)以便进一步分析。
Author
Owner

目前最佳的方案还是将这个对象在代码中声名好,然后定义为静态,然后尽量避免被绘制

目前最佳的方案还是将这个对象在代码中声名好,然后定义为静态,然后尽量避免被绘制
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LiRuochen_WorkFlow/XericLibrary-Publish#15