"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Error ModelTargetBehaviour.ModelTarget on iOS

Hi,

I created the app that using model target and i managed to create a button to change the current guide view. The app works perfectly while i am working on PC and tested on Android.

But when i open the project on Mac and tested on Iphone, the apps has a bug. I checked it and found out the ModelTargetBehaviour.ModelTarget reference is null. In editor, database and model target in ModelTargetBehaviour gameobject is set correctly even in Play Mode, it is not Empty.

 

This is my script to access the model target.

private ModelTargetBehaviour _modelTargetBehaviour;

private void Start()
{
 _modelTargetBehaviour= GetComponent<ModelTargetBehaviour>();
}

public void GuideView(int toggleId)
{
 if (_modelTargetBehaviour!= null)
 {
  ModelTarget modelTarget = _modelTargetBehaviour.ModelTarget;
  modelTarget.SetActiveGuideViewIndex(toggleId); //here is the error but only on iOS, modelTarget is null reference
 }
}

Hi,

Its quite strange that it fails on iOS and works in PlayMode and Android.

In our Core Sample apps we demo how Model Targets and also cycle throught the guideview with following code:

adimasnriin

Tue, 01/05/2021 - 03:51

In reply to by mcotora

Thank you for the reply.

I tried the core sample but it has same error when i click CycleGuideView button.

The error in this line,
int activeView = modelTarget.GetActiveGuideViewIndex();

Hi,

Ok, could you add your Model Target database to the Core sample app and let me know if you can cycle through the guideviews?

Thank you.

Vuforia Engine Support

adimasnriin

Wed, 01/06/2021 - 06:25

In reply to by mcotora

Hi,

Apparently the error only occurs when it is first installed in iOS device. I don't know why.

mcotora

Thu, 01/07/2021 - 10:29

In reply to by adimasnriin

Hi,

Could you please confirm the Vuforia Engine and Unity version?

Thank you.

Vuforia Engine Support

adimasnriin

Wed, 01/13/2021 - 01:47

In reply to by mcotora

Hi, 
I used Vuforia 6.9.3 and Unity 2019.4.7
I found this error occurs because my ModelTarget script used before the apps asks for camera permission at the first instalation. I resolve this by added new scene to request permission before enter AR scene.