我在這里創建了一個Instantiate function using a click button to create a GameObject from the parent object Layout Grid,它作業正常
但是有一個問題,當我單擊按鈕時,它最初位于頂部,但是當我單擊 3 次以上時previous GameObject,位于底部而不是頂部且不按順序,這就是我的問題,我希望previous GameObject它位于頂部和底部當我訂購時click the button
public GameObject exampleParent, exampleChild;
public void gItem(int i)
{
Instantiate(exampleChild, exampleParent.transform);
exampleChild.transform.SetAsFirstSibling();
exampleChild.gameObject.transform.Find("Text").GetComponent<TMP_Text>().text = Items[i].gameObject.GetComponent<AddItemC>().textPopup;
}
這是我遇到的問題的視頻GameObject應該是top和sorted的那一刻起I click the button,但previous GameObject都在bottom:

uj5u.com熱心網友回復:
我已經改成這個了,它的作業原理
public void gItem(int i)
{
GameObject obs = Instantiate(exampleChild, exampleParent.transform) as GameObject;
obs.transform.Find("Text").GetComponent<TMP_Text>().text = Items[i].gameObject.GetComponent<AddItemC>().textPopup;().AddItemToPlayer();
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/403257.html
標籤:
上一篇:為什么Destroy(GameObject)對GameObjects元組串列的第二個專案不起作用?
下一篇:根據對比度調整顏色
