Home > other >  Unity during the execution of a program to create the object cannot be identified to is why
Unity during the execution of a program to create the object cannot be identified to is why

Time:09-27

According to the prefab to create objects in the process of game, and then want to tag access but has been unable to get to the why, the following code
GameObject [] father=GameObject. FindGameObjectsWithTag (" grid ");
The Debug Log (" test if father has a numerical value="+ father. Length);
The foreach (var son father) in
{
Whether the Debug Log (" into the archive circulation ");
The Debug Log (son. Name);

}



Item creation code below
Public static void GreatNewItem Item (Item) {
The Debug Log (item. ItemName + "output item");
//generated entity
Slot newItem=Instantiate (instance. SlotPrefab, instance. SlotGrid. The transform. The position, Quaternion. Identity);//there's a problem instance. SlotPrefab
NewItem. GameObject. Transform. SetParent (instance. SlotGrid. Transform);
NewItem. SlotItem=item;
NewItem. SlotImage. Sprite=item. ItemImage;

}

Program execution father=0
  • Related