Forum rules - please read before posting.

In-Scene Unity UI Menu Canvas/rect transform not being found by Serializer.

edited January 2017 in Technical Q&A
I'm making my UI completely in-scene using custom Unity UI.  Menus/Canvases are childed to the player character, and appear in 3D space when activated.

However, the Serializer isn't finding them in the Menu.LoadUnityUI() function.

Or, more precisely, the Serializer does find them once at the beginning, when the call stack is:
AC.PlayerMenus:OnStart() > AC.PlayerMenus:RebuildMenus(MenuManager)  > PlayerMenus.AC.Menu:LoadUnityUI()

But after that, the SaveSystem runs SceneLoaded()>OnLevelWasLoaded(), and consequently  ResetSceneObjects() > PlayerMenus.AfterLoad() >Menu.LoadUnityUI(). 

This time, the Serializer can no longer find UI canvas or rect transform via searching for the constant ID, even though the Constant ID component is still present on the canvas.

I'm assuming there's something happening during that whole response to scenes finishing loading that is fudging things up, but I haven't gotten too deep into (and am a bit frightened to) the SaveSystem.

Thanks for any help!

Comments

  • It could be because Unity places the Player in a separate "hidden" scene in your Hierarchy, as it's set to DontDestroyOnLoad.

    For what reason as you parenting the UIs to your Player?  Try instead to keep them separate, and use a script to copy them to the player's transform each frame.
  • Thanks for the prompt response :)  Hmmm - the only thing popping up in DontDestroyOnLoad is the persistent engine
    I'll keep fiddling with it.  I was kind of just hoping there was a quick and simple answer XD
    If I don't figure it out, I might have to try that scripting.

    As for the parenting UI to the player - my game is entirely in first person - when the player opens a menu, their character pulls out a tablet using the player character's arms and animation rig.  So it made sense to have the UI canvases childed to the rig/tablet as well.
  • edited January 2017
    Quick update of a few more tests I've run - just opened up a clean import of AC in a new, clean project.  First person.  Made a UI canvas in world space.  In AC, set its appear type to "On Input Key" and set it up to toggle with the Esc key.

    No luck, same issue.  Tried both Unity UI in Scene and Unity UI Prefab for the AC menu settings.
  • A Unity UI linked to AC, and rendered in World Space, must be linked via Unity Ui In Scene option.

    Be sure that you are using the very latest release, v1.55c.  Parenting your UIs to the Player should be fine, provided that the Player itself is part of the scene file, and not instantiated at runtime by AC.

    When the UI is not appearing but should be, pause the game and view it in the Hierarchy to see what's going on.  Is it disabled, or positioned in the wrong place?

    The first step when debugging Menus should be to switch the Menu's Source field to Adventure Creator, make sure it's previewing correctly in the Game Window, and then test it.  This is to determine if the issue lies with AC, or Unity UI.
  • ... Just realized my copy is indeed the one release behind.  Updated, and now it works :)  Sorry about that, and thanks for the help.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.