In the editor all ui is showed up properly (image 1), but after built, some buttons aren’t showed up, but the rest of the UI showed up and function normally. I have tried delete and re insert the scene, but it doesn’t work.
i use this method to add more item (as button) to the scroll rect
public void itemAdd(int id)
{
GameObject newButton = Instantiate(theOriginalButton) as GameObject;
newButton.SetActive(true);
newButton.GetComponent<ButtonItemClick>().no = id;
newButton.GetComponent<ButtonItemClick>().noOnBag = count;
newButton.GetComponent<ButtonItemClick>().buttonName.text = TheManager.instance.GetItemManager().itemList[id].itemName;
newButton.transform.SetParent(theItemBox.transform, false);
bagItem.Add(newButton);
count++;
}
ItemManager script contain the list of items, stored as ItemType class
ItemManager Script
public class ItemManager : MonoBehaviour
{
public List<ItemType> itemList;
}
ItemType class
[System.Serializable]
public class ItemType
{
public string itemName;
public string itemDescription;
public string itemEffect;
public string equip;
public bool royalEquip = false;
public bool isEquip = false;
public bool isOn = false;
public bool isHand = false;
public bool isTwoHand = false;
public bool isArmor = false;
public int lowAttack;
public int highAttack;
public int lowDefense;
public int highDefense;
}
ItemList script, used to adding attributes to the item
ItemType itemToAdd;
public static int count;
void Start()
{
//Item no 0
itemToAdd = new ItemType();
TheManager.instance.GetItemManager().itemList.Add(itemToAdd);
TheManager.instance.GetItemManager().itemList[count].itemName = "Standard Sword";
TheManager.instance.GetItemManager().itemList[count].itemDescription = "Just your everyday sword, given by the king as " +
"your supply, and he expect you to succeed in your " +
"mission, what a douchebag." + "
" +
“-Type: 1-Handed Weapon” + "
" +
“-Attributes: 1 Low Attack” + "
";
TheManager.instance.GetItemManager().itemList[count].isEquip = true;
TheManager.instance.GetItemManager().itemList[count].isHand = true;
TheManager.instance.GetItemManager().itemList[count].lowAttack = 1;
count++;
//Item no 1
itemToAdd = new ItemType();
TheManager.instance.GetItemManager().itemList.Add(itemToAdd);
TheManager.instance.GetItemManager().itemList[count].itemName = "Standard Armor";
TheManager.instance.GetItemManager().itemList[count].itemDescription = "A very common armor, supplied by the king. " +
"This armor barely hold it's own against punch " +
"attack, let alone sword attack." + "
" +
“-Type: Armor” + "
" +
“-Attributes: 1 Low Defense” + "
";
TheManager.instance.GetItemManager().itemList[count].isEquip = true;
TheManager.instance.GetItemManager().itemList[count].isArmor = true;
TheManager.instance.GetItemManager().itemList[count].lowDefense = 1;
count++;
//The list goes on
}
}
What is wrong??