Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Help with making Text boxes pop up

Discussion in '2D' started by chrisb_01, Mar 27, 2020.

  1. chrisb_01

    chrisb_01

    Joined:
    Mar 21, 2020
    Posts:
    5
    Hello, so im rather new to unity and i was wondering how to make a temporary textbox (one that someone can click "ok" or something) after two objects touch. I have given a simple example of what im trying to say(picture 1). When i drag dog onto teeth(picture 2), itll say something like " a dog has teeth", and if i drag dog onto hair, itll print "a dog has hair". And then for alligator it would say "has no hair" but if alligator was dragged onto teeth, it would say "alligator has teeth" and etc. So pretty much im just trying to have a different textbox for each circle on the right for each animal. Hopefully this quick example helps explain what im looking for help on. Thanks! :) picture 1.png picture 2.png
     
  2. Primoz56

    Primoz56

    Joined:
    May 9, 2018
    Posts:
    369
    Create your popup in the scene (canvas, ui images etc), have it inactive by default and upon wanting to popup, set it to active using MyObject.SetActive(true);
     
    chrisb_01 likes this.
  3. chrisb_01

    chrisb_01

    Joined:
    Mar 21, 2020
    Posts:
    5
    Hey, thank you so much for your reply. I was just wondering how i could manage to have the text close after I am done reading it. Thanks again for the help!
     
  4. Primoz56

    Primoz56

    Joined:
    May 9, 2018
    Posts:
    369
    same as how you use SetActive(true), just use SetActive(false) to hide it. you will likely want to create a transparent full screen background object (use CanvasGroup component to make transparent, or one of many other ways) and attach the button property with the SetActive(false) event attached.