Switching and activating UI elements outside of UI with game objects.

Heya,

Been looking but cant find a solid solution or example to give me pointers on this.

Im looking to have an game object like a button, call an event on a UI element (speech bubble) when the button object is being pressed by the player.

Also looking into how i can switch the UI elements without having multiple UI canvases going on and off. IE for creating a speech bubble based conversation where the text changes.

Ive only managed to find an example of appearing text that uses the UI canvas on/off method. Seems very backwards if one wants to have multiple speech bubbles for example (would mean creating tons of canvases), some way to switch the content inside one canvas is what im looking for.

Unity has tutorials for UI events, but they are all for actions within the UI itself.

You can just enable/disable the game object that contains the UI (or instantiate, add to canvas and later destroy it)

You can use OnClick() event to call methods outside button - in this case you can enable or create speech bubble, that not a button children.

You can use one Canvas and many Windows or Bubbles inside it (set of game objects). Then you can use gameObject.SetActive true/false to enable active Window and disable all another. Or you can use Prefabs to create / remove Windows (or Bubbles) dynamically.

You can apply scripts which implement the Event interface handlers to enable 3D objects to work like any other UI object. So long as the object is visible through a canvas, World Space or Screenspace.

I even show an example of this with the RTS selector in the UI Extensions project (link in sig), just check the tutorial video for the RTS selectable component.

Thanks a bunch guys! These tips will help me move forward a great deal :slight_smile: