You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vuforia多VuMark场景报错求助:需同时识别9个VuMark但仅能创建一个对象

解决Vuforia多VuMark同数据库运行空引用报错问题

当包含多个VuMark的Unity包在场景运行时触发空引用异常,将VuMark拆分到不同数据库可规避错误,但业务需求要求同时识别9个不同VuMark,且无法创建多个VuMark对象。报错栈信息如下:

Exception in callback: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
  at Vuforia.VuMarkTrackableSimulationPool.IterateThroughTrackables (System.Collections.Generic.Dictionary`2[TKey,TValue] trackables, System.Int32& index, Vuforia.TrackerData+VuMarkTargetResultData[]& resultDataArray) [0x00061] in <ef8d686d707a43ad9c18ca2400443c5d>:0 
  at Vuforia.VuMarkTrackableSimulationPool.CreateTrackableArray () [0x00035] in <ef8d686d707a43ad9c18ca2400443c5d>:0 
  at Vuforia.VuMarkTrackableSimulationPool.CreateNativeDataArrays (Vuforia.TrackerData+VuMarkTargetResultData[]& activeVumarkArray, Vuforia.TrackerData+VuMarkTargetData[]& newVumarkDataArray) [0x00000] in <ef8d686d707a43ad9c18ca2400443c5d>:0 
  at Vuforia.VuforiaRuntimeTrackingSimulator.CreateNewManageFrameState () [0x00007] in <ef8d686d707a43ad9c18ca2400443c5d>:0 
  at Vuforia.VuforiaManager.Update (Vuforia.VuforiaScreenOrientation counterRotation, System.Boolean& reapplyOldState) [0x0001d] in <ef8d686d707a43ad9c18ca2400443c5d>:0 
  at Vuforia.VuforiaARController.UpdateStatePrivate (System.Boolean forceUpdate, System.Boolean reapplyOldState) [0x00051] in <ef8d686d707a43ad9c18ca2400443c5d>:0 
  at Vuforia.VuforiaARController.UpdateState (System.Boolean forceUpdate, System.Boolean reapplyOldState) [0x0000c] in <ef8d686d707a43ad9c18ca2400443c5d>:0 
  at Vuforia.DigitalEyewearARController.Update () [0x00000] in <ef8d686d707a43ad9c18ca2400443c5d>:0 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <8f06425e63004caf99a79845675f751e>:0 
   --- End of inner exception stack trace ---
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00083] in <8f06425e63004caf99a79845675f751e>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <8f06425e63004caf99a79845675f751e>:0 
  at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x000e7] in <8f06425e63004caf99a79845675f751e>:0 
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00008] in <8f06425e63004caf99a79845675f751e>:0 
  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in <8f06425e63004caf99a79845675f751e>:0 
  at Vuforia.DelegateHelper.InvokeDelegate (System.Delegate action, System.Object[] args) [0x0000f] in <ef8d686d707a43ad9c18ca2400443c5d>:0 
UnityEngine.Debug:LogError (object)
Vuforia.DelegateHelper:InvokeDelegate (System.Delegate,object[])
Vuforia.DelegateHelper:InvokeWithExceptionHandling (System.Action)
Vuforia.VuforiaBehaviour:Update ()

解决方案

  • 校验VuMark数据库完整性:检查所有VuMark的识别图案、元数据等资源是否完整导入,无缺失或损坏。空引用大概率是数据库中某条VuMark数据未正确加载导致。
  • 调整Vuforia跟踪池容量:打开Vuforia Configuration面板,找到VuMark相关的跟踪池设置,将最大可跟踪VuMark数量调至10及以上(覆盖9个需求)。默认池容量可能不足以容纳多个同时识别的VuMark,遍历过程中出现空对象。
  • 添加空值判断补丁:针对报错的VuMarkTrackableSimulationPool.IterateThroughTrackables方法,在遍历trackables字典时加入空对象检查,跳过null实例再执行后续逻辑:
// 在IterateThroughTrackables方法中插入空检查逻辑
foreach (var trackableEntry in trackables)
{
    if (trackableEntry.Value == null)
        continue;
    // 原有处理代码
}
  • 动态切换VuMark(备选):若上述方法无效,可尝试在识别到单个VuMark后,动态切换数据库内的激活VuMark,但此方法会失去同时识别能力,仅作为最后备选方案。

内容的提问来源于stack exchange,提问作者IProroIK

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 13:00:01