- Home /
Interface not showing up until tab out?
I did post this to the UI section but it pertains heavily to the code I use so I am not sure which is the correct place, please let me know.
So I have been struggling with getting my inventory system to show up properly. I spawn them into the correct places I DO use the transform.SetParent() function and panels are still invisible until I either disable and enable the GO or click another window and then the unity editor.
Here is the code that spawns all the slots [code=CSharp]public void BuildInv(string InventoryString){ //List slots = new List (); InventoryRawString = InventoryString;
float slotwidth = this.gameObject.GetComponent<RectTransform>().sizeDelta.x / xRows;
float slotheight = this.gameObject.GetComponent<RectTransform>().sizeDelta.y / yRows;
for (int countery = 1; countery <= yRows; countery++) {
for (int counterx = 1; counterx <= xRows; counterx++) {
GameObject slot = (GameObject) Instantiate(SlotPrefab);
slot.transform.SetParent(transform, false);
LayoutRebuilder.MarkLayoutForRebuild (slot.transform as RectTransform);
slot.GetComponent<RectTransform>().anchoredPosition = new Vector2 (0,0);
}
}
transform.parent.gameObject.SetActive(false);
transform.parent.gameObject.SetActive(true);
//LoadInventory();
}[/code]
Here you can see the interface buttons hidden?? http://i.imgur.com/cQnzqLk.png
And when I select another program and the click the unity editor http://i.imgur.com/ZnSeMOD.png