//Put a new item in the UI void UpdateGUI(IItem item, GameObject prefab, Transform parent) { //Instantiate the gui item GameObject go = ObjectPool.Instantiate(prefab, prefab.transform.position, prefab.transform.rotation, parent); //Fix the scale error RectTransform rect = go.GetComponent <RectTransform>(); rect.transform.localScale = Vector3.one; //Load the data in the UI ShopItemUI itemUI = go.GetComponent <ShopItemUI>(); itemUI.item = item; itemUI.UpdateUI(); }
public void ToUI() { int j, k; for (int i = 0; i < materials.Length; i++) { j = i % 3; k = i / 3; if (i >= Contenedores.Count) { GameObject go = Instantiate(UIPrefab, Vector3.zero, Quaternion.identity, UIContenedor.transform); RectTransform gort = go.GetComponent <RectTransform>(); gort.anchoredPosition = new Vector2(-355 + 355 * j, 400 - 355 * k); Contenedores.Add(go); } ShopItemUI mui = Contenedores[i].GetComponent <ShopItemUI>(); //mui.material = materials[i]; mui.UpdateUI(); } }