Forum rules - please read before posting.

UI Buttons for Character Switching

It's time for today's question!

I created Action Script Assets to switch between three characters, and verified that they work through in-scene Hot Spot testing. I then created three Unity UI buttons and a panel to surround them. The panel is higher in the hierarchy than the buttons, but they are all direct children of the Canvas. The entire canvas is a prefab.

I created a new Menu in the Editor called "Character Buttons" and tied the prefab Canvas and Character Button Panel to it. I then created three Buttons, one for each character, and tied them to the pre-fab UI element and the Action Script Asset. I also generate button text with each character's name in the properties, as I deleted the text addition to the UI buttons.

When I run my game, the buttons appear and are clickable, but no text appears on them and they do not run the Action Script. I have tried may different configurations, but so far nothing is working.

Comments

  • When Unity UI is used for a Button, you must still ensure it has a Text component on it, or on a child.  AC will override the contents of that Text box, but won't add the component itself - allowing you to change the style as you like.

    Again, if you have a problem with a Unity UI Menu, always try switching the Source back to Adventure Creator to confirm that it all functions as intended in that way.  From your description, it sounds like you've done everything correct (be sure to remove the UI from the scene, however), but it's not yet clear if the issue lies with the Menu Manager or with Unity UI.
  • Good to know on the Text component. I was confused by instructions in the Inventory Box tutorial, which was the closest text I could find to guide me on making this.

    Also, I discovered another problem that had been causing some issues: I had created two separate menus for on-screen UI -- one for the character buttons and one for my game timer. Even though I referenced the same Canvas pre-fab, it was instantiating the canvas twice. I have since remedied that problem and that seems to have solved other nagging issues.
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.