在向顶点列表添加顶点后,界面排版会发生错误:
并伴随错误:
NullReferenceException: Object reference not set to an instance of an object XericLibraryEditor.XericComponent.XericRectSplineEditor.OnSceneGUI () (at <4777c8ad8dad48df8c6a74057062d189>: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. 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) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <6073cf49ed704e958b8a66d540dea948>:0) UnityEditor.SceneView.CallOnSceneGUI () (at <a017e354f3154926a5617fbac3a64fcc>:0) UnityEditor.SceneView.HandleSelectionAndOnSceneGUI () (at <a017e354f3154926a5617fbac3a64fcc>:0) UnityEditor.SceneView.DoOnGUI () (at <a017e354f3154926a5617fbac3a64fcc>:0) UnityEditor.SceneView.OnSceneGUI () (at <a017e354f3154926a5617fbac3a64fcc>:0) UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <22a7125907634f27b5049762847405c6>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) NullReferenceException: Object reference not set to an instance of an object XericLibraryEditor.XericComponent.XericRectSplineEditor.OnSceneGUI () (at <4777c8ad8dad48df8c6a74057062d189>: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. 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) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <6073cf49ed704e958b8a66d540dea948>:0) UnityEditor.SceneView.CallOnSceneGUI () (at <a017e354f3154926a5617fbac3a64fcc>:0) UnityEditor.SceneView.HandleSelectionAndOnSceneGUI () (at <a017e354f3154926a5617fbac3a64fcc>:0) UnityEditor.SceneView.DoOnGUI () (at <a017e354f3154926a5617fbac3a64fcc>:0) UnityEditor.SceneView.OnSceneGUI () (at <a017e354f3154926a5617fbac3a64fcc>:0) UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <22a7125907634f27b5049762847405c6>:0) UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <22a7125907634f27b5049762847405c6>:0) UnityEngine.UIElements.IMGUIContainer.DoIMGUIRepaint () (at <22a7125907634f27b5049762847405c6>:0) UnityEngine.UIElements.UIR.RenderChainCommand.ExecuteNonDrawMesh (UnityEngine.UIElements.UIR.DrawParams drawParams, System.Single pixelsPerPoint, System.Exception& immediateException) (at <22a7125907634f27b5049762847405c6>:0) Rethrow as ImmediateModeException UnityEngine.UIElements.UIR.RenderChain.Render () (at <22a7125907634f27b5049762847405c6>:0) UnityEngine.UIElements.UIRRepaintUpdater.Update () (at <22a7125907634f27b5049762847405c6>:0) UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) (at <22a7125907634f27b5049762847405c6>:0) UnityEngine.UIElements.Panel.UpdateForRepaint () (at <22a7125907634f27b5049762847405c6>:0) UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e) (at <22a7125907634f27b5049762847405c6>:0) UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <22a7125907634f27b5049762847405c6>:0) UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <22a7125907634f27b5049762847405c6>:0) UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <22a7125907634f27b5049762847405c6>:0) UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <22a7125907634f27b5049762847405c6>:0) UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <956c3dba657b4ead8528be7fdbbfa2de>:0)
经过排查,是之前计划更新的界面导致的。
但也有其他问题,比如camera会报空,recttransform也是空的。
虽然这些问题之前都没有发生,但现在添加了更多的判断流程,避免后面再发生这些事。
您好喵~感谢您反馈这个问题和提供详细的错误日志!让我来帮您分析一下情况:
XericRectSplineEditor.OnSceneGUI()
// 示例修复代码(需要根据实际代码调整) void OnSceneGUI() { // 添加必要的空检查 if(target == null || serializedObject == null) return; serializedObject.Update(); try { // 确保所有GUI操作都有对应的End调用 using(new GUILayout.HorizontalScope()) { // GUI内容... } // Camera和RectTransform的安全访问 var camera = Camera.current ?? SceneView.lastActiveSceneView?.camera; if(camera == null) return; var rectTransform = target as RectTransform; if(rectTransform == null) return; // 其他逻辑... } finally { serializedObject.ApplyModifiedProperties(); } }
需要我帮您查看具体的XericRectSplineEditor实现代码吗?或者您已经有修改方案了喵?
XericRectSplineEditor
No dependencies set.
The note is not visible to the blocked user.
在向顶点列表添加顶点后,界面排版会发生错误:
并伴随错误:
经过排查,是之前计划更新的界面导致的。
但也有其他问题,比如camera会报空,recttransform也是空的。
虽然这些问题之前都没有发生,但现在添加了更多的判断流程,避免后面再发生这些事。
您好喵~感谢您反馈这个问题和提供详细的错误日志!让我来帮您分析一下情况:
XericRectSplineEditor.OnSceneGUI()方法中的空引用异常需要我帮您查看具体的
XericRectSplineEditor实现代码吗?或者您已经有修改方案了喵?