Hi! I'm developing a game based on Unity 5.6 + Google VR SDK 1.30 + AC 1.56b.
Because it's a VR project, I need to use world space render mode in all the Menu Canvas, also I'm using the "Unity UI In Scene" option for each menu.
The problem I have is when I'm trying to show any menu: in Unity editor works fine but when I deploy it to any Android device none of the menu shows up.
As an example, these are the steps to reproduce the issue:
1) Create a new project on Unity 5.6 using Google VR SDK 1.30 and AC 1.56b
2) Run the AC Game wizard.
3) Create a Player, with the VR Main Camera as a child.
4) Create a Canvas for the subtitles and properly configure it on the menu settings: using world space as render mode and "Unity UI in Scene" option.
5) Create a hotspot, with "play speech" as the use interaction.
So, when this example is running in the Unity Editor works fine, but when is running on any Android device, the subtitles never shows up.
Also, if I use the same canvas, and manually execute "SetActive (true)" and "SetActive (false)" works fine.
Are there any difference between Unity Editor and a real Android device that I should take in mind with AC?
Thanks!
Comments
Thank you for the clear steps. At first glance, I wonder if this is due to your parenting of the MainCameraVR prefab to your Player.
When on mobile devices, Unity has some very hard-to-spot differences when dealing with objects that survive scene changes, like the player. Is your Player instantiated at runtime, or is he present in the scene file?
Try unparenting the MainCameraVR - as a general rule, the MainCamera should be left alone whenever possible.
If that fails, we may have to make one or two debug logs that we can use to see where the issue lies. Menus are turned on in Menu.cs' TurnOn() function - but let's see if the parenting change has any effect first.
localCanvas = Serializer.returnComponent <Canvas> (canvasID, KickStarter.sceneSettings.gameObject);
If you're aware that Android is calling this twice, does that mean you have a stacktrace to share? I'll need to see where this second call is coming from. I shall look into it on my own device, but the more information you can share, the more thorough I can be.
Are you duplicating this Menu for each line in your Menu's properties box?
else if (menuSource == MenuSource.UnityUiInScene)
{ localCanvas = Serializer.returnComponent <Canvas> (canvasID, KickStarter.sceneSettings.gameObject);
}
else if (menuSource == MenuSource.UnityUiInScene)
{
if (canvas == null) {
localCanvas = Serializer.returnComponent <Canvas> (canvasID, KickStarter.sceneSettings.gameObject);
} else {
localCanvas = canvas;
}
}
This is indeed down to Unity 5.6. I shall look into a workaround.
#if UNITY_5_4_OR_NEWER
private void Awake ()
{
UnityEngine.SceneManagement.SceneManager.sceneLoaded += SceneLoaded;
}
private void OnDestroy ()
{
UnityEngine.SceneManagement.SceneManager.sceneLoaded -= SceneLoaded;
}
private void SceneLoaded (UnityEngine.SceneManagement.Scene _scene, UnityEngine.SceneManagement.LoadSceneMode _loadSceneMode)
{
if (Time.time > 0f)
{
_OnLevelWasLoaded ();
}
}
#else
private void OnLevelWasLoaded ()
{
_OnLevelWasLoaded ();
}
#endif
with the following:
#if UNITY_5_4_OR_NEWER
private bool loadedInitialScene = false;
private void Awake ()
{
UnityEngine.SceneManagement.SceneManager.sceneLoaded += SceneLoaded;
}
private void OnDestroy ()
{
UnityEngine.SceneManagement.SceneManager.sceneLoaded -= SceneLoaded;
}
private void SceneLoaded (UnityEngine.SceneManagement.Scene _scene, UnityEngine.SceneManagement.LoadSceneMode _loadSceneMode)
{
if (loadedInitialScene)
{
_OnLevelWasLoaded ();
}
loadedInitialScene = true;
}
#else
private void OnLevelWasLoaded ()
{
_OnLevelWasLoaded ();
}
#endif
Does that solve the issue?