Hi Everybody,
Could you please help me how to get the index value on prefab button runtime by clicking on prefab button.i need to get value on prefab by clicking to edit according to 03 Script data which is given bellow.
Thank you,
Deepal
![alt text][1]
public class MyShopsScript : MonoBehaviour
{
public GameObject shopid;
public GameObject shopname;
public GameObject ShopAddress;
public Button editButton;
public void SetMyShopNames( string id, string name, string address)
{
this.shopid.GetComponent().text = id;
this.shopname.GetComponent().text = name;
this.ShopAddress.GetComponent().text = address;
}
}
class GetMyShopName
{
public int ShopID { get; set; }
public string ShopName { get; set; }
public string ShopAddress { get; set; }
public GetMyShopName(int shopid, string shopname, string shopaddress)
{
this.ShopID = shopid;
this.ShopName = shopname;
this.ShopAddress = shopaddress;
}
}
public class SqlDataControl : MonoBehaviour
{
private List getMyShopNames = new List();
public void ShowMyShopNames()
{
GetMyShopsName();
foreach (GameObject shopListButton in GameObject.FindGameObjectsWithTag("ShopListButton") )
{
Destroy(shopListButton);
}
getMyShopNames.Clear();
for (int i = 0; i < getMyShopNames.Count; i++)
{
GameObject temObject = Instantiate(getMyShopNamesPrefab) as GameObject;
GetMyShopName temShopName = getMyShopNames[i];
temObject.GetComponent().SetMyShopNames(temShopName.ShopID.ToString(), temShopName.ShopName, temShopName.ShopAddress);
temObject.transform.SetParent(myShopParent);
temObject.GetComponent().localScale = new Vector3(1, 1, 1);
temObject.GetComponent().editButton.onClick.AddListener(() => OpenShopDataInputPanel());
}
}
public void OpenShopDataInputPanel()
{
commShowPanel.SetActive(false); // working
shopDataInputPanel.SetActive(true); //working
categariesID.GetComponent().text = " I need to get value at shopid.GetComponent().text wich is on prefab at 01 Script when i onClick.AddListener() on runtime " ;
categoriesNameInputField.text = " I need to get value at shopname.GetComponent().text wich is on prefab at 01 Script when i onClick.AddListener() on runtime " ;
categoriesNoteInputField.text = " I need to get value at ShopAddress.GetComponent().text wich is on prefab at 01 Script when i onClick.AddListener() on runtime ";
}
}
[1]: /storage/temp/163604-picture1.png
↧