Forum rules - please read before posting.

Connecting menus to Unity UI prefabs - just need a double check I'm doing it right

edited March 2020 in Technical Q&A

Unity Ver: 2019.2.4f1
AC Ver: 1.70.4

Hey there,

Despite using AC for a year, I'm only now starting to look at the UI side of things.

So far I've been using pure AC menus, but now I want to connect these into some Unity UI Prefabs. I've done this for the player subtitles however I want to check that I'm doing things correctly as I'm getting a result after playing the game which I don't know if it's a problem.

This is what I've done step by step:

1) Created a Unity UI Prefab

This is very simple; it's a canvas with a panel, and a text child.

2) Linked the menu to use the prefab

So I've gone ahead and changed the menu to 'Unity UI Prefab' and then dragged the prefab asset into 'linked Canvas prefab'

3) Link menu elements

I've opened up the prefab directly (I haven't put the prefab into the scene - is that wrong?) and dragged the panel and text bits to fll in the RectTranform & Linked Text fields.

4) Review

Things look good! Everything appears set and when I play the game it appears it is now using the UI prefab. Awesome.

5) Uh oh. Problem?

After playing the game, the menu elements appear to lose links to the prefab bits which were just set.

Is that a problem or expected? Am I doing something wrong?

Comments

  • I think you'll find that's expected (although, disconcerting). The important factor is that there is a Constant Id

    You'll find the same thing occurs in in ActionLists too, where fields disappear, but as long as there's a ConstantId then AC is able to link to the relevant data

    Like you, I took some while before I ventured into swopping out AC's menus for Unity based ones, but it all seemed quite painless in the end, and I can confirm that my own Menus looks very much the same as yours (i.e. with ConstantIds, but things like "Linked Text" set as "None")

    (I wouldn't take my word for it though. I'm notoriously flaky on... stuff. Chris will hopefully confirm though)

  • @HarryOminous Thank you for your reply. I figured the ConstantID was likely the most important bit but always worth double checking!

  • Yes, it's the Constant ID value that's used to connect it all together.

    You can also place the prefab in the scene and assign references from there - but as AC will automatically generate Constant ID components on them, you'll have to be sure to apply such changes back to the original prefab before removing it from the scene.

    The 3D Tutorial covers the creation of Unity UI-based Menus here.

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.