- 最后登录
- 2014-5-7
- 注册时间
- 2013-7-12
- 阅读权限
- 90
- 积分
- 11615
- 纳金币
- 454
- 精华
- 31
|
好久没出教程了…最近有点小忙…今天把之前在别的论坛上发的教程贴上来…
本来想这一课出一个游戏的,但是个人觉得还是先不放到课程上了,然后这一课简单的介绍下 GUI自定义组建设置
先执行下面的操作project -->create -->GUI Skin看下图
然后我们点击现在有的MyGUISkin会看到,如下图
再看下图
我里我是介绍了下我现在在做的游戏里面的一个登录按钮
下面看代码,代码中介绍了一些大型游戏的登录界面的构成
- using UnityEngine;
- using System.Collections;
- public class Login : MonoBehaviour
- {
- //游戏登录界面
- private const int LOGIN = 0;
- //游戏注册界面
- private const int REGISTER =1;
- //推出游戏
- private const int EXIT = 2;
- //游戏状态设置
- private int GameStatus;
- //GUISkin
- public GUISkin myGUISkin;
- //获取登录的用户名和密码
- private string loginNmae;
- private string loginPassword;
- //输入的登录用户名和密码
- public string _loginNmae = "";
- public string _loginPassword = "";
- public int login_x = 270;
- public int login_y = 250;
- public int exit_x = 380;
- public int exit_y = 250;
- public int name_x = 270;
- public int name_y = 150;
- public int password_x = 270;
- public int password_y = 200;
- public int x_name = 200;
- public int y_name = 150;
- public int x_password = 200;
- public int y_password = 200;
- public Texture textureBG;
- public MovieTexture movieTexture;
- private void Start ()
- {
- //初始化游戏为登录状态
- GameStatus = LOGIN;
- }
- private void OnGUI()
- {
- GUI.skin = myGUISkin;
- GUI.DrawTexture(new Rect(0,0,850,420),textureBG);
- GUI.Button(new Rect(login_x,login_y,100,30),"","Login");
- GUI.Button(new Rect(exit_x,exit_y,100,30),"","Exit");
- _loginNmae = GUI.TextField(new Rect(name_x,name_y,210,30),_loginNmae,"NmaeInput");
- _loginPassword = GUI.TextField(new Rect(password_x,password_y,210,30),_loginPassword,"PassWordInput");
- GUI.Label(new Rect(x_name,y_name,60,30),"","Nmae");
- GUI.Label(new Rect(x_password,y_password,60,30),"","passWord");
- }
- private void Update ()
- {
- }
- }
复制代码
然后照以上操作大家试试,运行游戏会看到
2012-9-5 21:32:40 上传
下载附件 (32.84 KB)
这样的效果。
|
|