Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Beginner question...creating a "toolbox" window

Discussion in '2D' started by kwende, Jul 11, 2015.

  1. kwende

    kwende

    Joined:
    Jul 10, 2015
    Posts:
    2
    I'm making a very simple game to just get my head wrapped around Unity. It's a 2D game, sort of like the game "The Incredible Machine". I think I get almost every part of Unity I've studied up to the GUI part; for some reason it seems difficult for me to completely get the hang of.

    What I want to do is allow the user to hit a key and have a window pop-up that serves as a "toolbox". The user can then take an item from the window and "drag it" into the game. At this point I'd suffice if I could just open up a window and have a user click an item - whereby the window dissapears and the item is now placed into the game.

    The problem is, I'm unsure of the best way to do this. Most menu tutorials I see out there involve creating a Main Menu, whereby I create a whole new Scene .. that's not what I want to do. I have been playing with a Canvas and a Panel, but I'm unsure as to the best way to toggle its visibility based on a key stroke. So I'm wondering if I'm just using the wrong technique (I'm trying to turn off / on the IsActive status, but that requires the panel to be active at the onset of the game for GameObject.find() to work.

    There's got to be a best practices here that I'm just not getting.

    Thanks in advance.
     
  2. 1Piotrek1

    1Piotrek1

    Joined:
    Mar 14, 2014
    Posts:
    130
    Just make panel transform variable public, next drag and drop your panel to script inspector. You can also use event system.
     
  3. truecrisis

    truecrisis

    Joined:
    Feb 17, 2015
    Posts:
    8
    I have to do this too. I'm a noob and in no place to give suggestions, but one thing I don't like about toggling visibility is that it is still something the engine has to consider. Wouldn't instancing it and killing it be better?

    Also I think a "menu" might be the wrong term, I think these things are more considered a "modal" of sorts
     
  4. 1Piotrek1

    1Piotrek1

    Joined:
    Mar 14, 2014
    Posts:
    130
    Do you mean performance?
    Instantiate and destroy functions are creating and forgeting objects, and they are much slower than just hidding/separating them from scene by set active.