Search Unity

How to create a UI object when a gameobject is clicked?

Discussion in 'Immediate Mode GUI (IMGUI)' started by ambitiousmustard, Mar 9, 2017.

  1. ambitiousmustard

    ambitiousmustard

    Joined:
    Feb 9, 2017
    Posts:
    1
    Hey guys!

    How do you write a script so that when an object is clicked or selected, it instantiates a UI window or panel that can then be closed/destroyed when the player is done with it? I know how to set an object's active state to true or false, but I need each of these objects to have their own unique UI when generated.

    This is for a city-builder I'm writing based off of the old Sierra games like Caesar III and Pharaoh, so I'm trying to replicate the system for when a building is right-clicked and it pauses the game and opens a window with its description and stats. When the player right-clicks again anywhere on the screen, the window closes as the game starts up again. Although I can generate the initial window, I can't figure out how to get it to close.
     
  2. Izzy2000

    Izzy2000

    Joined:
    Dec 18, 2013
    Posts:
    49