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 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.