Search code examples
androidunity-game-enginehololensmrtk

CoreServices.SceneSystem.LoadContent not working on Android device


I created a Hololens app using MRTK and Vuforia, this app starts with a menu where the user can chose between 4 scenarios. Following the official documentation from Microsoft, I'm now trying to deploy this app on an Android device. For you information the app works perfectly fine on the Hololens and in the Unity Editor.

The problem
I can build the .apk, deploy it and launch the app on the Android device and click on buttons (I hear the sound) but it doesn't change the scene.

What I've tried
My buttons have a script attached which requires the name of the scene to load.
enter image description here

using System.Collections;
using System.Collections.Generic;
using Microsoft.MixedReality.Toolkit;
using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneLoader : MonoBehaviour
{
    /// Request that the MRTK SceneSystem load a scene of a given name.
    public void LoadScene(string sceneName) => CoreServices.SceneSystem.LoadContent(sceneName, LoadSceneMode.Single);
}

I use the same script with an hard coded sceneName to load the first scene (the menu) which is loaded and displayed on the Android device.

In the build settings I selected all the scenes and the minimum API level is set to level 30

enter image description here

What could cause this behaviour where the scenes aren't loaded except for the first one ?

[EDIT] I also tried to use SceneManager.LoadScene(id) but it's also not working on the Android device

This picture show the ARFoundation and ARCore version used
enter image description here


Solution

  • It seems like Android isn't detecting events triggered by OnClick so you must use OnPress while the Hololens supports both

    enter image description here