Dynamically change Prefab rendered when using image tracking in Unity ARFoundation

33 views Asked by At

(Newbie to Unity here) I have a UI button that when I press it and based on an if condition, I want to change the prefab that is being rendered on the detected marker. The function called when clicking the UI button is this:

public void SwitchScenes() {

    if (modeButtonImage.sprite == sensorSprite)
    {
        imageManager.trackedImagePrefab = actuatorPrefab;
    }
    else
    {
        imageManager.trackedImagePrefab = sensorPrefab;
    }

}

This code is attached to the AROrigin GameObject and it is not working for my purpose.

PS. I have check that the imageManager field and is correctly initialized and its type is ARTrackedImageManager. I also have checked that the if statements are executed correctly, and they do

0

There are 0 answers