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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Timurov · Nov 08, 2012 at 01:12 PM · c#guibuttonlist

How to repeat the same list of buttons?

Hey guys! While doing combo box using buttons I just caught myself on idea, is it possible to make something like: "wanna more? ok. press and get it :)" for instance I have combo boxes with a fruits, vegetables, berries. So, I selected fruit, vegetable, berry and I want to repeat the same combo boxes with a list of fruits, vegetables, berries. Probably I may need something like "Add new fruit, vegetable, berry". So my question is: Is it possible to do "Add new fruit, vegetable, berry", if so please give some feedback :D Regards, Tim

Here is a code an example code:

 using UnityEngine;
 using System.Collections;
 
 public class hibye: MonoBehaviour 
 {
 
     public string slectedItem = "None";
     private bool editing = false;
     
      public string slectedItem2 = "None";
     private bool editing2 = false;
     
     public string slectedItem3 = "None";
     private bool editing3 = false;
     
     private void OnGUI()
     {    
         if ( GUILayout.Button(slectedItem))
         {
             editing = true;
         }
 
         if (editing)
         {
             string[] sig = {"Banana","Apple","Orange"};
     
             for (int x = 0; x < sig.Length ; x++)
             {
                 if (GUILayout.Button(sig[x]))
                 {
                     slectedItem = sig[x];
                     editing = false;
                     
                 }
             }
         }
            if ( GUILayout.Button(slectedItem2))
         {
             editing2 = true;
         }
 
         if (editing2)
         {
             string[] sig = {"Cabbage","Potato","Paprika"};
     
             for (int x = 0; x < sig.Length ; x++)
             {
                 if (GUILayout.Button(sig[x]))
                 {
                     slectedItem2 = sig[x];
                     editing2 = false;
                     
                 }
             }
         }
            if ( GUILayout.Button(slectedItem3))
         {
             editing3 = true;
         }
 
         if (editing3)
         {
             string[] sig = {"Baneberry","Blackberry","Grape"};
     
             for (int x = 0; x < sig.Length ; x++)
             {
                 if (GUILayout.Button(sig[x]))
                 {
                     slectedItem3 = sig[x];
                     editing3 = false;
                     
                 }
             }
         }
 
     }
     
 }

I want to make the code shortest and add another GUILayout.Button which allows me to make choice of existing items one more time without changing existing chosen items.

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 astorga · Nov 08, 2012 at 01:30 PM 1
Share

Share some code so we can use as a start point :)

avatar image Timurov · Nov 08, 2012 at 01:56 PM 0
Share

ok done :D

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by astorga · Nov 08, 2012 at 02:08 PM

Ok, if I understood, you want to make this group with only a function call, right?

If so, take a look at this link, might help: http://docs.unity3d.com/Documentation/Components/gui-Extending.html

Comment
Add comment · Show 2 · Share
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 Timurov · Nov 08, 2012 at 02:35 PM 0
Share

yeah, I want to make the code shortest and add another GUILayout.Button which allows me to make choice of existing items one more time without changing existing chosen items.

avatar image Timurov · Nov 09, 2012 at 08:01 AM 0
Share

Don't you have any idea or some link to make this real, please?

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

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to make a or array of GUI.Button's? 1 Answer

How Do You Use GUIText to Move Through Multiple Texts? 1 Answer

How to select an Game Object from an Item List 0 Answers

How to trigger button press on a button in an editor window by pressing the return key ? 0 Answers

How to make a box appear after pressing a button? 1 Answer


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