how to create texture for each dynamically generating gui button
how to give texture for each button
using UnityEngine;
using System.Collections;
public class fr : MonoBehaviour {
public string []items;
public string selecteditems="";
private bool editng=false;
public Rect box;
void OnGUI()
{
if(GUI.Button(box,selecteditems))
{
Debug.Log("test");
editng=true;
}
if(editng)
{
for(int x=0;x<items.Length;x++)
{
if(GUI.Button(new Rect(box.x,(box.height*x)+box.y +box.height,box.width,box.height),items[x]))
{
selecteditems=items[x];
editng=false;
Debug.Log("answer:"+selecteditems);
if(items[x]==items[0])
{
Debug.Log("u selected item[0]");
}
if(items[x]==items[1])
{
Debug.Log("u selected item[1]");
}
if(items[x]==items[2])
{
Debug.Log("u selected item[2]");
}
if(items[x]==items[3])
{
Debug.Log("u selected item[3]");
}
if(items[x]==items[4])
{
Debug.Log("u selected item[4]");
}
}
}
}
}
}
check out the image for output of this code