Im creating an item List by creating GameObjects under a panel and then using UIGrid to position them using this code.
public GameObject SliderItem; //This is a prefab with the slider item template
public GameObject Slider; //This is a draggable panel with an UIGrid component in it.
....void PopulateItemList(){
for (int c=0;c<GameManager.Instance.numberOfWeapons;c++) {
GameObject go=(GameObject) Instantiate(SliderItem);
WeaponItem wi=go.GetComponent<WeaponItem>();
wi.SetData(c);
go.transform.parent=Slider.transform;
go
.transform.localScale=new Vector3
(1,
1,
1); //Send data to Slider
}
Slider.SendMessage("Reposition");
}
Item setting data code;
public void SetData(int pid){
id=pid;
name=GameManager.Instance.GetWeaponName(id);
level=1;
price=GameManager.Instance.GetWeaponPrice(id);
itemLabel.text=name+" L"+level;
itemIcon.spriteName=GameManager.Instance.GetWeaponIcon(id);
}
It does create and position them currently, but they are not being shown in game, the panel is completely item in the game camera.
Sorry If this has been asked before I looked around