[Unity&NGUI]背包系统崩溃的解决办法
2017-01-11 00:00
375 查看
由于NGUI的OnDragDropRelease()的物体不随着鼠标移动,因此
使用过UICamera.hoveredObject改变NGUI的OnDragDropRelease()的物体随鼠标坐标移动
什么鼠标精灵的物体为空null,没有实例化
背包系统就崩溃了
NullReferenceException: Object reference not set to an instance of an object
UIDragDropItem.OnDragDropStart () (at Assets/NGUI/Scripts/Interaction/UIDragDropItem.cs:279)
UIDragDropItem.StartDragging () (at Assets/NGUI/Scripts/Interaction/UIDragDropItem.cs:213)
UIDragDropItem.OnDragStart () (at Assets/NGUI/Scripts/Interaction/UIDragDropItem.cs:162)
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
NullReferenceException: Object reference not set to an instance of an object
UIDragDropItem.OnDragDropMove (Vector2 delta) (at Assets/NGUI/Scripts/Interaction/UIDragDropItem.cs:311)
UIDragDropItem.OnDrag (Vector2 delta) (at Assets/NGUI/Scripts/Interaction/UIDragDropItem.cs:233)
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
UICamera:Notify(GameObject, String, Object) (at Assets/NGUI/Scripts/UI/UICamera.cs:1765)
NullReferenceException: Object reference not set to an instance of an object
UIDragDropItem.OnDragDropRelease (UnityEngine.GameObject surface) (at Assets/NGUI/Scripts/Interaction/UIDragDropItem.cs:346)
KnapsackItem.OnDragDropRelease (UnityEngine.GameObject surface) (at Assets/Scripts/New/UIScripts/BackPack/KnapsackItem.cs:49)
UIDragDropItem.StopDragging (UnityEngine.GameObject go) (at Assets/NGUI/Scripts/Interaction/UIDragDropItem.cs:256)
UIDragDropItem.OnDragEnd () (at Assets/NGUI/Scripts/Interaction/UIDragDropItem.cs:244)
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
试过:
1.把打包好的完整的工程导入新建工程,运行场景,失败
2.把新建场景,使用原来的对象,失败
3.新建场景,把UI Drage Drop Item单独的载入,成功
4.重新把脚本更新试试
UNITY工程打包,有可能丢失文件
最好每天把工程备份
在原始工程中,原始场景中
新建物体添加碰撞器,UIDragDropItem
无法拖拽新建物体
新建场景
新建物体添加碰撞器,UIDragDropItem
无法拖拽新建物体
原始工程中,原始场景
对背包的格子,添加碰撞器,UIDragDropItem
无法拖拽物体
新建工程,重新导入NGUI,原始的工程文件
在原始工程文件的,场景中,物体是可以被UIDragDropItem组件拖拽
新建工程,重新导入NGUI,原始的工程文件
在原始工程文件的,场景中,关闭其他的脚本,新建一个脚本复制KnapsackItem : UIDragDropItem
的protected override void OnDragDropRelease(GameObject surface)
进行调试,是正常的,可以被拖拽
说明OnDragDropRelease()函数,NGUI的原始工程是正常的
先是复制了下面红色方块的 protected override void OnDragDropRelease(GameObject surface)是正常的
再把上面的复制,发现也是正常的
然后发现都是正常的
得出结论:使用UICamera.hoveredObject做过物体UI跟随鼠标移动的测试,显示为空,虽然逻辑是正确的,但是这个为空null,导致了没有实例化,会引发一系列Unity内部的逻辑崩溃。
及时备份,才是王道。
如果觉得备份太麻烦了,可以 放弃使用 NGUI。(这通常是 UNITY组件 崩溃 的常用方法)
使用UGUI(Unity自带的GUI)组件来 组件 背包系统。
[Unity]Unity组件崩溃的通用的几种解决办法
使用过UICamera.hoveredObject改变NGUI的OnDragDropRelease()的物体随鼠标坐标移动
什么鼠标精灵的物体为空null,没有实例化
背包系统就崩溃了
NullReferenceException: Object reference not set to an instance of an object
UIDragDropItem.OnDragDropStart () (at Assets/NGUI/Scripts/Interaction/UIDragDropItem.cs:279)
UIDragDropItem.StartDragging () (at Assets/NGUI/Scripts/Interaction/UIDragDropItem.cs:213)
UIDragDropItem.OnDragStart () (at Assets/NGUI/Scripts/Interaction/UIDragDropItem.cs:162)
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
NullReferenceException: Object reference not set to an instance of an object
UIDragDropItem.OnDragDropMove (Vector2 delta) (at Assets/NGUI/Scripts/Interaction/UIDragDropItem.cs:311)
UIDragDropItem.OnDrag (Vector2 delta) (at Assets/NGUI/Scripts/Interaction/UIDragDropItem.cs:233)
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
UICamera:Notify(GameObject, String, Object) (at Assets/NGUI/Scripts/UI/UICamera.cs:1765)
NullReferenceException: Object reference not set to an instance of an object
UIDragDropItem.OnDragDropRelease (UnityEngine.GameObject surface) (at Assets/NGUI/Scripts/Interaction/UIDragDropItem.cs:346)
KnapsackItem.OnDragDropRelease (UnityEngine.GameObject surface) (at Assets/Scripts/New/UIScripts/BackPack/KnapsackItem.cs:49)
UIDragDropItem.StopDragging (UnityEngine.GameObject go) (at Assets/NGUI/Scripts/Interaction/UIDragDropItem.cs:256)
UIDragDropItem.OnDragEnd () (at Assets/NGUI/Scripts/Interaction/UIDragDropItem.cs:244)
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
OnDragDropRelease 不能正常拖拽(拿不到对象)或者鼠标穿透无法拦截
上面的这篇文章没有帮助试过:
1.把打包好的完整的工程导入新建工程,运行场景,失败
2.把新建场景,使用原来的对象,失败
3.新建场景,把UI Drage Drop Item单独的载入,成功
4.重新把脚本更新试试
UNITY工程打包,有可能丢失文件
最好每天把工程备份
在原始工程中,原始场景中
新建物体添加碰撞器,UIDragDropItem
无法拖拽新建物体
新建场景
新建物体添加碰撞器,UIDragDropItem
无法拖拽新建物体
原始工程中,原始场景
对背包的格子,添加碰撞器,UIDragDropItem
无法拖拽物体
新建工程,重新导入NGUI,原始的工程文件
在原始工程文件的,场景中,物体是可以被UIDragDropItem组件拖拽
新建工程,重新导入NGUI,原始的工程文件
在原始工程文件的,场景中,关闭其他的脚本,新建一个脚本复制KnapsackItem : UIDragDropItem
的protected override void OnDragDropRelease(GameObject surface)
进行调试,是正常的,可以被拖拽
说明OnDragDropRelease()函数,NGUI的原始工程是正常的
先是复制了下面红色方块的 protected override void OnDragDropRelease(GameObject surface)是正常的
再把上面的复制,发现也是正常的
然后发现都是正常的
得出结论:使用UICamera.hoveredObject做过物体UI跟随鼠标移动的测试,显示为空,虽然逻辑是正确的,但是这个为空null,导致了没有实例化,会引发一系列Unity内部的逻辑崩溃。
及时备份,才是王道。
如果觉得备份太麻烦了,可以 放弃使用 NGUI。(这通常是 UNITY组件 崩溃 的常用方法)
使用UGUI(Unity自带的GUI)组件来 组件 背包系统。
[Unity]Unity组件崩溃的通用的几种解决办法
相关文章推荐
- macbook装机注意事项&&双系统崩溃解决办法
- 【Unity&NGUI】背包系统显示隐藏问题
- [Unity&重装系统]重装系统导致Unity 缺失MSVCR100.dll问题解决办法
- 【Unity&NGUI】我的背包系统相关文章总览
- 【Unity&NGUI】背包系统物品的累加
- Hadoop在Windows系统的Eclipse下运行Cannot run program "chmod": CreateProcess error=2解决办法
- Unity关于 "Move" can only be called on an active agent that has been placed on a NavMesh.问题的解决办法
- 【Unity 3D 游戏引擎】NGUI 触摸UI和人物行走冲突的解决办法
- 使用JVM管理工具jvisualvm,系统提示"无法检测到本地java应用程序"的原因和解决办法
- 【Unity】NGUI背包系统——背包整理按钮的改进
- golang在32位系统下atomic.AddUint64导致程序崩溃及解决办法
- Win7-64位系统中VC++ 6.0打开文件崩溃解决办法
- 安装Apache时,系统找不到指定的文件 No installed service named "Apache2"的解决办法
- 3种不用重装的办法解决压缩Vista系统文件夹导致崩溃情况
- Unity插件NGUI实现背包系统
- 【Unity&DragonBones】DragonBones运行库导入Unity工程文件详细教程以及解决办法
- Linux系统下Flash Player崩溃的一个解决办法分享
- Linux 系统中安装网卡驱动时出现"设备eth0似乎不存在"解决办法
- 关于“系统错误&H80004015(-2147467243).此类别是作为跟调用程序不同的安全ID运行的”的解决办法
- 64位系统IE9打开有Flash的页面直接崩溃的解决办法