Assets/Vuforia/Scripts/DefaultInitializationErrorHandler.cs(98,23)错误 以及 使用Vuforia 发布AR播放视频

在使用Vuforia 8版本发布AR应用时遇到`VuforiaUnity`引用错误,通过将Build System设置为Internal可解决。接着介绍了详细步骤来创建并配置AR播放视频功能,包括在Unity中设置Vuforia、导入资源、创建ARCamera和Image Target,以及添加Video Player和调整设置。最后提到可能的对焦问题及解决方案。

在使用Vuforia发布AR APK的时候出现错误:

Assets/Vuforia/Scripts/DefaultInitializationErrorHandler.cs(98,23): error CS0246: The type or namespace name `VuforiaUnity' could not be found. Are you missing an assembly reference?

解决方案:

在Seting 设置处 Build System 默认是:Gradle 发布时出现以上错误

修改为:Internal 错误消失 成功发布apk

 

接下来说说怎么使用Vuforia发布AR播放视频的问题,在网上找了很长的时间材料,由于SDK的版本不同,博主发布的日期又早有晚

我现在使用的是Vuforia SDK的版本是8的时候 

从开头开始说起,

第一步: 开头就有一个坑,先把坑填了如图

导入SDK以后就是没有Resources文件夹也就没有VuforiaConfiguration怎么设置呢?先在Playing Seting 里面设置

NullReferenceException: Object reference not set to an instance of an object FairyGUI.GObject.LocalToGlobal (UnityEngine.Vector2 pt) (at Assets/HotUpdate/FairyGUI/Scripts/UI/GObject.cs:1508) GiftAwardDialog.ShowTips (System.Object[] param) (at Assets/HotUpdate/Scripts/UI/Component/GiftAwardDialog.cs:154) GiftAwardDialog.OpenParam (System.Object[] param) (at Assets/HotUpdate/Scripts/UI/Component/GiftAwardDialog.cs:56) BaseEuiView.Open (System.Object[] param) (at Assets/HotUpdate/Scripts/UI/BaseEuiView.cs:170) ViewManager.Open[T] (System.Object[] param) (at Assets/HotUpdate/Scripts/UI/ViewManager.cs:86) DailyQuestsView+<>c__DisplayClass46_0.<CheckInItemRender>b__1 (FairyGUI.EventContext e) (at Assets/HotUpdate/Scripts/DailyQuests/DailyQuestsView.cs:353) FairyGUI.EventBridge.CallInternal (FairyGUI.EventContext context) (at Assets/HotUpdate/FairyGUI/Scripts/Event/EventBridge.cs:149) FairyGUI.EventDispatcher.BubbleEvent (System.String strType, System.Object data, System.Collections.Generic.List`1[T] addChain) (at Assets/HotUpdate/FairyGUI/Scripts/Event/EventDispatcher.cs:317) FairyGUI.EventDispatcher.BubbleEvent (System.String strType, System.Object data) (at Assets/HotUpdate/FairyGUI/Scripts/Event/EventDispatcher.cs:360) FairyGUI.Stage.HandleMouseEvents () (at Assets/HotUpdate/FairyGUI/Scripts/Core/Stage.cs:1209) FairyGUI.Stage.HandleEvents () (at Assets/HotUpdate/FairyGUI/Scripts/Core/Stage.cs:1027) FairyGUI.Stage.InternalUpdate () (at Assets/HotUpdate/FairyGUI/Scripts/Core/Stage.cs:802) FairyGUI.StageEngine.LateUpdate () (at Assets/HotUpdate/FairyGUI/Scripts/Core/StageEngine.cs:22) 这是什么意思
最新发布
09-04
在Unity和FGUI开发中,`NullReferenceException: Object reference not set to an instance of an object` 错误信息意味着代码试图访问一个尚未被初始化的对象引用。简单来说,就是代码里使用了一个值为 `null` 的对象,而对 `null` 对象进行操作就会引发这个异常。 以下是几种可能出现该错误的常见场景及示例代码: ### 未正确加载FGUI包 如果没有正确加载FGUI包,尝试从该包创建对象时就会得到 `null`。 ```csharp using FairyGUI; using UnityEngine; public class FGUILoadError : MonoBehaviour { void Start() { // 未正确加载包 // UIPackage.AddPackage("FGUI/FightPackage"); GComponent component = UIPackage.CreateObject("FightPackage", "SomeComponent").asCom; // 这里会引发NullReferenceException,因为component为null component.SetXY(100, 100); } } ``` ### 未正确获取组件 在FGUI中,如果试图获取一个不存在的组件,就可能得到 `null` 引用。 ```csharp using FairyGUI; using UnityEngine; public class FGUIComponentNotFound : MonoBehaviour { void Start() { UIPackage.AddPackage("FGUI/FightPackage"); GComponent parent = UIPackage.CreateObject("FightPackage", "ParentComponent").asCom; // 假设不存在名为"NonExistentChild"的组件 GComponent child = parent.GetChild("NonExistentChild").asCom; // 这里会引发NullReferenceException,因为child为null child.SetXY(100, 100); } } ``` ### 引用被意外置为null 在代码执行过程中,对象引用可能被意外设置为 `null`,后续操作就会引发异常。 ```csharp using FairyGUI; using UnityEngine; public class FGUIReferenceNulled : MonoBehaviour { private GComponent someComponent; void Start() { UIPackage.AddPackage("FGUI/FightPackage"); someComponent = UIPackage.CreateObject("FightPackage", "SomeComponent").asCom; // 意外将引用置为null someComponent = null; // 这里会引发NullReferenceException,因为someComponent为null someComponent.SetXY(100, 100); } } ``` ### 解决方案 为了避免 `NullReferenceException`,在使用对象之前,需要确保对象已经被正确初始化,并且在获取对象引用后,进行空值检查。例如: ```csharp using FairyGUI; using UnityEngine; public class FGUISafeAccess : MonoBehaviour { void Start() { UIPackage.AddPackage("FGUI/FightPackage"); GComponent component = UIPackage.CreateObject("FightPackage", "SomeComponent").asCom; if (component != null) { component.SetXY(100, 100); } } } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值