zoukankan      html  css  js  c++  java
  • 【转】NGUI创建UIRoot后报NullReferenceException的解决办法

    本文参考自 http://forum.china.unity3d.com/thread-1099-1-1.html

    使用NGUI版本3.7.5。

    在创建了一个UIRoot后,有时会报NullReferenceException的错误,如下图。虽然报错但是不影响运行。

    截取部分报错输出是

    [html] view plain copy
     
    1. NullReferenceException: Object reference not set to an instance of an object  
    2. UIPanel.get_worldCorners () (at Assets/NGUI/Scripts/UI/UIPanel.cs:623)  
    3. UIPanelInspector.OnSceneGUI () (at Assets/NGUI/Scripts/Editor/UIPanelInspector.cs:87)  
    4. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)  
    5. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.  
    6. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at  


    双击错误进入NGUI的UIPanel脚本,会定位到这段代码

    [csharp] view plain copy
     
    1. if (anchorOffset && mCam == null || mCam.transform.parent != cachedTransform)  

    将这段代码修改为下面的代码即可修复此错误

    [csharp] view plain copy
     
      1. if (anchorOffset && (mCam == null || mCam.transform.parent != cachedTransform))  
  • 相关阅读:
    js用8421码实现10进制转2进制
    什么?toggle(fn1, fn2)函数在1.9版本jq被移除? 来来来,自己撸一个
    js获取鼠标点击的对象,点击另一个按钮删除该对象
    html5小结
    iphone状态栏高度?
    制作手机相册 全屏滚动插件fullpage.js
    js 相关知识整理(一)
    css 居中问题
    进度条
    @Html.Raw()
  • 原文地址:https://www.cnblogs.com/mimime/p/6233976.html
Copyright © 2011-2022 走看看