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

graphically adding buttons

Discussion in 'Immediate Mode GUI (IMGUI)' started by boolfone, Oct 2, 2014.

  1. boolfone

    boolfone

    Joined:
    Oct 2, 2014
    Posts:
    289
    Is there a way to graphically add buttons to a Unity game?

    Or must this be done programmatically?

    Thanks.
     
  2. aoe_labs

    aoe_labs

    Joined:
    Nov 4, 2013
    Posts:
    42
    You can add a button by
    • clicking create in the hierarchy > UI > button
    • clicking GameObject in the menubar > UI > button
    Note: this will create a UI canvas if one has not already been created, and the button will be a child of the canvas.
     
  3. Josh-Naylor

    Josh-Naylor

    Administrator

    Joined:
    Jul 1, 2014
    Posts:
    216
    Are you trying to do this in the 4.6 beta or an earlier version of Unity?
     
  4. boolfone

    boolfone

    Joined:
    Oct 2, 2014
    Posts:
    289
    I'm using 4.5.4f1.
     
  5. boolfone

    boolfone

    Joined:
    Oct 2, 2014
    Posts:
    289
    I'm not seeing the options you described. I'm attaching part of my screen:
    Untitled.png

    Am I missing the options for some reason?

    Thanks.
     
  6. aoe_labs

    aoe_labs

    Joined:
    Nov 4, 2013
    Posts:
    42
    Ah, looks like you're not on Unity 4.6 yet. You can download the beta here. Version 4.6 has a new UI system, part of which has the buttons (I believe) you're looking for.

    You'll also notice that the game objects you can create are categorized differently. Primitive 3D objects are under 3D, 2D under 2D, and the UI stuff under UI. You'll want to create a UI > button, and to reiterate, this will automatically create a canvas element. Here is a Unity tutorial on the new UI system. The video linked is the button tutorial
     
  7. Pyronide

    Pyronide

    Joined:
    Jun 7, 2014
    Posts:
    56
    If you have not downloaded 4.6 you can use textures. I use textures in my builds.

    Code (csharp):
    1. var button1 : Texture
    2.  
    3. GUI.Button(Rect(0,0,64,64), button1);
    This is how I am doing it and how large my textures are... the 0s are the position that the button will be in.

    Hope this helps.
     
    Last edited: Oct 15, 2014
  8. ZO5KmUG6R

    ZO5KmUG6R

    Joined:
    Jul 15, 2010
    Posts:
    490
    I have attached a script that lets you drag a button and it will tell you the coordinates of it. Only one button at a time though.

     

    Attached Files: