Question

I'm developing an AR app that's going to contain an activity with a Unity3d model. Creating such an activity is something I can do now but I've come across another problem.

To show a unity model in an activity, the latter has to extend the UnityPlayerActivity class. What if I want to load the 3D model as soon as my launch activity starts but show it in one of the following ones? My goal would be to have the user wait for the model to be loaded as the app starts (e.g. when I show them a splash screen) so that when they change activity to the one that contains the AR view the waiting time is minimal.

I know this is possible in iOS and would like to replicate that behaviour in android as well. Any ideas?

Was it helpful?

Solution

As I suspected - there aren't any answers to my question.

I'll answer my question myself with a workaround, then, and wait for someone else to come up or for the creators of Unity to provide us with the same functionality under Android as under iOS.

To achieve the desired effect, I decided to only have 1 activity and multiple fragments. The activity extends UnityPlayerActivity meaning that when it loads, that takes the time Unity needs to load. Then, when navigating throughout the app, I only swap fragments containing entire screens and make use of the UnityPlayer.pause() and UnityPlayer.resume() methods, as well as the setVisibility method to make it go away.

Hope that helps if anyone has any similar issues.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top