Question by
DuDuDuDu · Dec 20, 2020 at 04:16 PM ·
editorprefabinstantiate prefabresources.loadbuild and run
Instantiate works fine in Editor and does not work after building game
Here is the situation, In my project everything works fine. After I build the game for windows, the prefab does not instantiate. I don't know which part I missed.
This is how I load the prefab from Resources folder
private void Awake()
{
areaButtonPrefab = Resources.Load<GameObject>("Prefabs/AreaButton1");
}
And this is how I instantiate prefab for each data in a List
public void SetAreaToUI()
{
foreach (var j in areaList)
{
cloneItem = Instantiate(areaButtonPrefab, originalRect.position, new Quaternion(0, 0, 0, 0), rect);
TMP_Text text = cloneItem.GetComponentInChildren<TMP_Text>();
AreaButtonData buttData = cloneItem.GetComponent<AreaButtonData>();
buttData.area = j;
text.text = j.areaName;
cloneItem.SetActive(true);
cloneItems.Add(cloneItem);
}
}
Comment
Your answer
Follow this Question
Related Questions
Acces position of previously instantied prefab 0 Answers
Why couldn't I use the “Resources.Load” result directly? 1 Answer
Prefabs and public variables 1 Answer
Editor script: Variable created on gameObject in editor set to missing on runtime 0 Answers
Prefabs not instantiating after build 0 Answers