基于Unity3D的2d拾宝游戏(七)
2017-06-06 19:43
405 查看
讲解上一篇文章(http://blog.csdn.net/qq_29859497/article/details/72886710)中提及的UI控制实现(C#)
UI控制类(所有按钮点击时都将调用此类):
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UIController : MonoBehaviour { public Button begin; public Button introduce; public Button member; public Button back; public Image image; public Sprite introSprite; public Sprite memberSprite; //返回开始界面,返回首页按钮点击时调用 public void ReturnStartPage() { Application.LoadLevel(0); } //开始游戏,开始游戏及再玩一次按钮点击时调用 public void BeginGame() { Application.LoadLevel(1);//点击开始按钮,进入第一关 } //显示游戏介绍,游戏介绍按钮点击时调用 public void Introduce(bool show) { SetActiveState(show); image.GetComponent<Image>().sprite = introSprite; } //显示小组成员,小组成员按钮点击时调用 public void Member(bool show) { SetActiveState(show); image.GetComponent<Image>().sprite = memberSpr 4000 ite; } //显示开始界面,返回按钮点击时调用 public void Back(bool show) { SetActiveState(show); } //设置界面按钮活动状态 void SetActiveState(bool show) { begin.gameObject.SetActive(show); introduce.gameObject.SetActive(show); member.gameObject.SetActive(show); back.gameObject.SetActive(!show); image.gameObject.SetActive(!show); } }
待续。
附:相关代码编写伙伴BLOG:XiaoMing 和AudioMiao ,欢迎撩。
相关文章推荐
- 基于Unity3D的2d拾宝游戏(一)
- 基于Unity3D的2d拾宝游戏(三)
- 基于Unity3D的2d拾宝游戏(五)
- 基于Unity3D的2d拾宝游戏(六)
- 强大的游戏开发工具Unity3D推出2D开发工具,unity将混合3D与2D开发
- unity3d制作2d游戏的原理
- Unity3D游戏开发之使用Unity3D开发2D游戏(二)(2DTookit插件亲测)
- 使用Unity3D 5.3.4 模仿2D游戏 FlappyBird(四)
- 基于Stage3D的2D游戏加速框架:Starling介绍
- 使用Unity3D 5.3.4 模仿2D游戏 FlappyBird(二)
- 基于Unity3D的Android游戏添加google广告的方法——使用AdMob
- unity3d 2d游戏关于必备元素的解析
- 【Unity3D】学习笔记(第3记) 2D游戏开发基本技巧之场景切换(Javascript)
- Unity3D游戏开发之使用Unity3D开发2D游戏(二)(2DTookit插件亲测)
- 强大的2D游戏技能特效 【unity3d教程】
- (结对编程)基于unity3d游戏引擎的魔方游戏
- Unity3D在2D游戏中利用UGUI实现分辨率自适应的一种可行实践方案
- unity3d开发2d游戏中控制摄像机移动以及主角移动
- 一个基于Starling框架的Flash2D游戏
- 大家都知道,木头一直都没有在大的游戏公司待过,没见识也没经历过优秀的项目。最近想研究一些开源的Unity3D框架,开拓一下自己的思维。 优先入坑的是Entitas框架,本系列教程基于0.42.3版本。