unity GetComponent使用
unityGetComponent使用GetComponent得到单独一个对象或属性可用于获取:模型对象,对象的属性,对象悬挂脚本//获取模型对象脚本名(ScriptName) 接收对象(Model) = GetComponent<脚本名(ScriptName)>();//通过模型绑定的脚本来获取模型对象, 注意:如果多个模型上绑定同一个脚本,只会获取到最后绑定脚本的模型对象//获取对
·
unity GetComponent使用
GetComponent得到单独一个对象或属性
可用于获取:模型对象,对象的属性,对象悬挂脚本
//获取模型对象
脚本名(ScriptName) 接收对象(Model) = GetComponent<脚本名(ScriptName)>();//通过模型绑定的脚本来获取模型对象, 注意:如果多个模型上绑定同一个脚本,只会获取到最后绑定脚本的模型对象
//获取对象的属性
GameObject NewGame;//创建一个对象并为对象赋值
Button button= NewGame.GetComponent<Button>();//得到NewGame绑定的button属性
//对象悬挂脚本
GameObject NewGame;//创建一个对象并为对象赋值
脚本名(ScriptName) 接收对象(Model) = NewGame.GetComponent<脚本名(ScriptName)>();//得到NewGame绑定的脚本
更多推荐
所有评论(0)