Closed riccardokhm closed 1 year ago
Hi there, would you be able to share the code which is linked to your "Change View" button?
Yes, here's the code:
#region ' Fields '
[SerializeField] private List<GameObject> _backlightsGOs;
[SerializeField] private TextMeshProUGUI _label;
[SerializeField] private TMP_Dropdown _dropdown;
[SerializeField] private TMP_Text _text;
[SerializeField] private ModelTargetBehaviour _modelTarget;
[SerializeField] private Button _button;
private int _backlight;
private bool _optionsAdded = false;
#endregion
#region ' Methods '
void Start()
{
_backlight = ArController._dropdownChoice;
ActivateGO(_backlight);
_button.onClick.AddListener(ChangeGuideview);
}
public void ChangeGuideview()
{
if (_modelTarget.GetActiveGuideViewIndex() == _modelTarget.GetNumGuideViews() - 1)
{
_modelTarget.SetActiveGuideViewIndex(0);
_modelTarget.Reset();
return;
}
int i = _modelTarget.GetActiveGuideViewIndex() + 1;
bool guideviewActivated = _modelTarget.SetActiveGuideViewIndex(i);
_modelTarget.Reset();
}
Hi there, please note that it's not recommended to change settings through the inspector during Play Mode which might cause the issues you're experienced. Let me try to understand your use-case so I can provide some insights how to better utilize the API, are simply trying to switch the guide view to a different one? I think for that use-case you do not need to set the "override detection position" property.
Hi, thanks for your reply. I know it's not recommended but it was just a way to show you the bug which appears at runtime on my device. Yeah, my ultimate aim is to switch guideview (which I am already able to do), but i understood that override detection position control option could help stabilize the tracking, and thus the choice to activate it. I am trying to optimize tracking initialization by imposing the starting position of the camera in Unity Space by activating this option, is it correct?
Mmm, I believe that you might be using the feature not as intended which might cause the issues you are experiencing. First of all, the recommended way to switch between guide views, which I verified, is to use the following code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
public class GuideViewChanger : MonoBehaviour
{
public ModelTargetBehaviour mModelTarget;
public int guideViewIndexToActivate = 0;
public void SetGuideView()
{
mModelTarget.SetActiveGuideViewIndex(guideViewIndexToActivate);
}
}
The code above will be able to set the correct guide view, based on the guideViewIndexToActivate
integer property. In your code, I don't think you need to invoke .Reset()
after setting the guide view.
When the Override Detection Position
is set, you cannot change the guide view anymore as it will be overridden. I am unsure if you can override the position during runtime though. When the Override Detection Position
is set, you are able to change the guide view by changing the GameObject and attached camera. These changes however are only captured during Model Target Behaviour activation or switching to a different guide view.
In any case overriding the detection position, to my knowledge, does not help stabilize the tracking. The feature is helpful if you want to dynamically change the guide view position without having to re-export the target and create new guide views. For example, during development where you're experimenting with the best angles to detect the object.
Ok now it seems all clear to me! Thanks for your support!
Anytime!
Summarize the bug: On activating the "override detection position" option on a model target, I am not able to change runtime the guideview.
Observed problem On building the application with such functionality on, the guideview change does not seem responsive. On turning on the standard configuration, guideview works perfectly. To change guideview, I initially reset the model target and then change guideview with the provided function (ModelTarget.SetActiveGuideViewIndex (int index) ).
Expected result I would optimize tracking stability by using such features since the guideviews are highly instable with the geometry.
Reproducible steps Steps to reproduce the behavior:
Affected Vuforia Engine version: Vuforia Engine 10.15.4
Affected platform:
Affected device:
Workaround I am currently implementing such features only on a single guideview.