Search Unity

Resolved AR Face Tracking keeping old objects on button click

Discussion in 'AR' started by antoniskamzel, Jun 9, 2021.

  1. antoniskamzel

    antoniskamzel

    Joined:
    Feb 18, 2020
    Posts:
    25
    I have an app for loading glasses. When I press a button it loads a model on the face and when I press another button it loads another one. I've tried two ways of doing it:
    1) Tried switching the models on the
    ARFaceManager.faceprefab
    when i click a button something like
    Code (CSharp):
    1. arObject = (GameObject)bundle.LoadAsset(rootAssetPath) as GameObject; //bundle is a downloaded assetbundle from www request
    2.                 ARFaceManager fm = ARSession.GetComponent<ARFaceManager>();
    3.                 fm.facePrefab = arObject;
    but the issue is that I need to hide my face in order for the new model to show, otherwise it won't

    2) Tried destroying the whole
    ARFaceManager
    component and Add it on button click with the proper model when needed. Here the problem is that on every new button click the old model stays on the screen and it doesn't go away like in the photo.

    **I should note that the prefab of the glasses contains a facePrefab that is invisible through a shader, so I could hide the unwanted parts.

    What could be wrong here? I hope u understand the issues. Thanks!!
     

    Attached Files:

  2. antoniskamzel

    antoniskamzel

    Joined:
    Feb 18, 2020
    Posts:
    25
    SOLVED: I coded it to disable and reenable the script itself and it seems to be working with the first (1) question code