本文介绍了如何继续检查游戏对象是否会在层次结构中统一实例化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想继续检查游戏对象是否会被实例化.我所拥有的只是游戏对象名称,比如模型".如果模型在层次结构中处于活动状态,我想做一些事情.问题是最初游戏对象不可用.稍后只会实例化它.如何检查具有名称的游戏对象是否存在于将是克隆的层次结构中.
I want to keep checking whether a game object will be instantiated.All I have is the gameobject name say 'Model'.If model is active in hierarchy I want to do something.The problem is initially the gameobject is not available.Later only it will be instantiated.How to check whether the gameobject with name is present in hierarchy which will be a clone.
if(gameobject.name=="Model(Clone)"){//做点什么}
这将返回一个空值,因为它最初没有被实例化.一段时间后它会被实例化.
This will return a null value since it was not instantiated initially.After some time it will be instantiated.
推荐答案
游戏对象模型;
if (Model != null && Model.name == "Model(Clone)"){//return false
//Do Something
}
Gameobject Model = Instantiate (somePrefab);
if
需要放在 void update()
里面,或者像 invoke()
这样的循环东西会不断检查条件.if
needs to be placed inside void update()
, or looping thing like invoke()
which will constantly checking the condition.if (Model != null && Model.name == "Model(Clone)"){//return true
//Do Something
}
这篇关于如何继续检查游戏对象是否会在层次结构中统一实例化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!