问题
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour {
public float spinSpeed = 2.0f;
public int cloneTests;
public GameObject prefab;
private bool rotate = false;
private bool exited = false;
private void Start()
{
for (int i = 0; i < cloneTests; i++)
{
GameObject Test = Instantiate(prefab);
Test.tag = "Testing";
}
}
}
The cloning is working.
But it's not adding the tag to each GameObject. And how can i put all the clones as childs under another GameObject ?
回答1:
Is testing already a declared tag? If you look it up in the Unity Script Reference you will find:
"Tags must be declared in the tag manager before using them"
来源:https://stackoverflow.com/questions/43988243/why-when-instantiate-new-gameobjects-its-not-adding-tag-to-them