Unity 5.0 无法通过GUIText类型在脚本中调用画布中的Text文字
2015-07-25 10:00
543 查看
原调用方法
修改后的方法:
1:添加命名空间
using UnityEngine.UI;
2:修改参数类型
//UI文字
Text txt_ammo;
Text txt_hiscore;
Text txt_life;
Text txt_score;
3:修改调用方法
//获取设置的UI文字
txt_ammo=this.transform.FindChild("txt_ammo").GetComponent<Text>();
txt_hiscore=this.transform.FindChild("txt_hiscore").GetComponent<Text>();
txt_score=this.transform.FindChild("txt_score").GetComponent<Text>();
txt_life=this.transform.FindChild("txt_life").GetComponent<Text>();
修改后的方法:
1:添加命名空间
using UnityEngine.UI;
2:修改参数类型
//UI文字
Text txt_ammo;
Text txt_hiscore;
Text txt_life;
Text txt_score;
3:修改调用方法
//获取设置的UI文字
txt_ammo=this.transform.FindChild("txt_ammo").GetComponent<Text>();
txt_hiscore=this.transform.FindChild("txt_hiscore").GetComponent<Text>();
txt_score=this.transform.FindChild("txt_score").GetComponent<Text>();
txt_life=this.transform.FindChild("txt_life").GetComponent<Text>();
相关文章推荐
- Unity3d中的Awake()、OnEnable()、Start()等默认函数的执行顺序和生命周期
- Unity3d中的Awake()、OnEnable()、Start()等默认函数的执行顺序和生命周期
- Unity3d与设计模式(三)工厂模式
- unity-UIInput自定义限制输入字符
- unity内存优化和客户端表格读取方法内存比较
- 初学C语言,使用 Visual Studio2013Community
- Unity3d编辑器拓展
- 游戏引擎中三大及时光照渲染方法介绍(以unity3d为例)
- Unity中的优化技术
- 使用Unity3D的50个技巧
- Unity3D占用内存太大的解决方法
- Unity3D使用经验总结 缺点篇
- Unity之自动保存场景
- unity——使用角色控制器组件+射线移动
- Unity2D动态设置SpriteRender的Sprite(Multipe)
- Unity之机器人AI
- Uniyt : 场景LoadLevel时资源和对象的处理流程
- Unity在移动平台中,文件操作路径详解
- Unity5.0新特性------动画的StateMachineBehaviours
- Unity中使用C#脚本调用JS脚本的使用方法