在游戲程序中根據prefab 創建的物體 ,然后想要根據tag 獲取 但是一直無法獲取到是為什么,代碼如下
GameObject[] father = GameObject.FindGameObjectsWithTag("grid");
Debug.Log("測驗father是否有數值=" + father.Length);
foreach (var son in father)
{
Debug.Log("是否進入到存檔回圈");
Debug.Log(son.name);
}
物品創建代碼如下
public static void GreatNewItem(Item item) {
Debug.Log(item.itemName+"輸出Item");
//生成物體
Slot newItem = Instantiate(instance.slotPrefab, instance.slotGrid.transform.position, Quaternion.identity); //這里有問題啊instance.slotPrefab
newItem.gameObject.transform.SetParent(instance.slotGrid.transform);
newItem.slotItem = item;
newItem.slotImage.sprite = item.itemImage;
}
程式執行 father =0
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/14038.html
標籤:Unity3D
上一篇:急求助!!!!unity3d中,操作界面可以看到組件,但是點擊播放,進入播放后的scene或者gaming界面,看不到組件
下一篇:使用的是EasyTouch插件,懇求幫忙看看怎么修改代碼實作雙指縮放視角時,有最大視角和最小視角限制,而且限制縮放速度太快了
