为什么在实例化新的GameObjects时不向其添加标签? [英] Why when Instantiate new GameObjects it's not adding tag to them?

查看:63
本文介绍了为什么在实例化新的GameObjects时不向其添加标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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";
        }
    }
}

克隆正在工作.

但是它没有将标签添加到每个GameObject中. 以及如何将所有克隆作为子对象放在另一个GameObject下?

But it's not adding the tag to each GameObject. And how can i put all the clones as childs under another GameObject ?

推荐答案

是否已经测试了声明的标记?如果您在Unity脚本参考中查找它,将会发现:

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"

这篇关于为什么在实例化新的GameObjects时不向其添加标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆