Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by CupOfThings · Aug 26, 2014 at 03:12 PM · guibuttongridmultiple

Unity GUI multiple grids?

Hello, I have 24 buttons in a grid that the player can select and use how they want, you are able to bring this grid up by pressing a button called "Items1". However I would like to have more buttons but not add them to this specific grid. Instead have another button saying "Items2" that when clicked brings up another grid of different buttons. I have already tried to do this and failed miserably, can someone help me out?

This is my script so far,

 var selGridInt : int = 0;
 var selStrings : String[] = ["Grid 1", "Grid 2", "Grid 3", "Grid 4"];
 var showInventory = false;
 
 public var prefabObject : GameObject;
 private var offset : Vector3;
 private var fwd : Vector3;
 private var clone : GameObject;
 var unit : float = 1.0f;
 var Sound : AudioClip;
 
 
 function Update () {
 
 fwd = transform.TransformDirection(Vector3.forward) * unit;
 offset = transform.position + fwd;
 if(Input.GetKeyDown(KeyCode.E)){
     
 audio.PlayOneShot(Sound);
 clone = Instantiate(prefabObject, offset, transform.rotation);
 }
 
 if(Input.GetKeyDown(KeyCode.I)){
 showInventory = !showInventory;
 
 }
 }
 
 var showItems1 = false;
 
 function OnGUI () {
 
 if(showInventory == true){
 GUI.Box (Rect (180,40,340,380), "Menu");
 
 if (GUI.Button (Rect (220,60,80,20), "Items1")) {
 showItems1 = !showItems1;
 }
 
 if (GUI.Button (Rect (400,60,100,20), "Quit Game")) {
 Application.LoadLevel(0);
 }
 
 
 if(showItems1 == true){
 selGridInt = GUI.SelectionGrid (Rect (200, 100, 300, 300), selGridInt, selStrings, 2);
 
 if((selGridInt == 0) && showInventory == true){
 prefabObject = (Resources.Load("square wall2"));
 }
 
 if((selGridInt == 1) && showInventory == true){
 prefabObject = (Resources.Load("wooden plank2"));
 }
 
 if((selGridInt == 2) && showInventory == true){
 prefabObject = (Resources.Load("rectangular wall"));
 }
 
 if((selGridInt == 3) && showInventory == true){
 prefabObject = (Resources.Load("ladder"));
 }
 
 if((selGridInt == 4) && showInventory == true){
 prefabObject = (Resources.Load("door"));
 }
 
 if((selGridInt == 5) && showInventory == true){
 prefabObject = (Resources.Load("floor"));
 }
 
 if((selGridInt == 6) && showInventory == true){
 prefabObject = (Resources.Load("window frame"));
 }
 
 if((selGridInt == 7) && showInventory == true){
 prefabObject = (Resources.Load("wall light"));
 }
 
 if((selGridInt == 8) && showInventory == true){
 prefabObject = (Resources.Load("fence"));
 }
 
 if((selGridInt == 9) && showInventory == true){
 prefabObject = (Resources.Load("glass wall"));
 }
 
 if((selGridInt == 10) && showInventory == true){
 prefabObject = (Resources.Load("column"));
 }
 
 if((selGridInt == 11) && showInventory == true){
 prefabObject = (Resources.Load("half wall up"));
 }
 
 if((selGridInt == 12) && showInventory == true){
 prefabObject = (Resources.Load("chair"));
 }
 
 if((selGridInt == 13) && showInventory == true){
 prefabObject = (Resources.Load("table"));
 }
 
 if((selGridInt == 14) && showInventory == true){
 prefabObject = (Resources.Load("half wall down"));
 }
 
 if((selGridInt == 15) && showInventory == true){
 prefabObject = (Resources.Load("platform"));
 }
 
 if((selGridInt == 16) && showInventory == true){
 prefabObject = (Resources.Load("cone"));
 }
 
 if((selGridInt == 17) && showInventory == true){
 prefabObject = (Resources.Load("glass floor roof"));
 }
 
 if((selGridInt == 18) && showInventory == true){
 prefabObject = (Resources.Load("???"));
 }
 
 if((selGridInt == 19) && showInventory == true){
 prefabObject = (Resources.Load("???"));
 }
 
 if((selGridInt == 20) && showInventory == true){
 prefabObject = (Resources.Load("???"));
 }
 
 if((selGridInt == 21) && showInventory == true){
 prefabObject = (Resources.Load("lamp"));
 }
 
 if((selGridInt == 22) && showInventory == true){
 prefabObject = (Resources.Load("plant"));
 }
 
 if((selGridInt == 23) && showInventory == true){
 prefabObject = (Resources.Load("big ass block"));
 }
 }
 }
 }
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image frogsbo · Aug 29, 2014 at 02:10 AM 0
Share

you want another keypress that brings up a different grid? i dont understand the gui functionality.

avatar image CupOfThings · Sep 05, 2014 at 06:02 PM 0
Share

Yeah, if a different button is pressed a different grid shows up which contains more objects.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Using GUI Button to activate script instances 1 Answer

controlling GUI.Button state 1 Answer

GUI grid of buttons issue. 1 Answer

C# Why Won't My GUI Layout Button Appear? 1 Answer

Turn off my GUI Box when I click a button. 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges