在unity3d标签找到不活跃游戏物体 [英] find inactive gameobject by tag in unity3d

查看:392
本文介绍了在unity3d标签找到不活跃游戏物体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个游戏对象,我希望激活给予了一定的条件。我给它一个唯一的标签,我尝试使用 GameObject.FindObjectWithTag(标签名)。据我所知,这种方法只能发现在现场积极gameobjects和不是不活跃的。

I have a gameobject which I wish to activate given a certain condition. I gave it a unique tag and I tried using GameObject.FindObjectWithTag("Tag name"). From what I can tell, this method will only find active gameobjects in the scene and not inactive ones.

有,我可以打电话,也将搜索无效gameobjects的方法? (最好按标签搜索)。

Is there a method that I can call that will also search inactive gameobjects? (Preferably searching by tag).

谢谢!

推荐答案

在然而一些研究似乎是有没有办法找到标签无效游戏物体

After some research it seems that there is no way to find an inactive gameobject by tag.

解决方案存在访问非活动gameobjects:

solutions exist however to access inactive gameobjects:

1 - 存储阵列中的非活动的游戏对象,如果您需要在事后重新激活它们(仅适用于游戏在运行时失活的物体)

1 - Store inactive game objects in an array if you need to reactivate them afterwards (only applies to game objects inactivated at runtime).

2 - 不要不关闭游戏对象,只需取消你想不活动的组成部分。如果你想使对象消失,停用渲染器。如果它是一个具体的脚本,停用该脚本等。

2 - Do not deactivate game object, simply deactivate the components you want inactive. If you wish to make the object disappear, deactivate the renderer. If it is a specific script, deactivate that script, etc.

这解决方案将允许您仍然找到它的标签名称的游戏对象。

This solution will allow you to still find a game object by its tag name.

这篇关于在unity3d标签找到不活跃游戏物体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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