简单的游戏界面设计

先看效果 自己做那还是游戏啊 失败失败
这里写图片描述

自己只有一点点图片 图片多可以自己去替换下面的文件夹中的图片
这里写图片描述

主要的代码
using UnityEngine;
using System.Collections;
public class AA : MonoBehaviour {
    // Use this for initialization
    private Texture2D bg;
    private Texture2D title;
    private Object[] tex;
    private int x,y,nowFran,mFramCount;
    private float fps=5;
    private float time=0;
    void Start () {

        bg=(Texture2D)Resources.Load("bg/0");
        title=(Texture2D)Resources.Load("title/0");
        tex=Resources.LoadAll("tex");
        x=Screen.width;
        y=200;
    }

    // Update is called once per frame
    void OnGUI () {
        GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height),bg);
        GUI.DrawTexture(new Rect(Screen.width-title.width>>1,30,title.width,title.height),title);
        DrawAnimation(tex,new Rect(x,y,40,60));
        x--;
        if(x<-42){
            x=Screen.width;
        }
        GUI.Button(new Rect(330,300,100,30),"StartGame");
        GUI.Button(new Rect(330,340,100,30),"Load");
        GUI.Button(new Rect(330,380,100,30),"About");
        GUI.Button(new Rect(330,420,100,30),"Exit");
    }
    void DrawAnimation(Object[] tex,Rect rect){
        GUI.DrawTexture(rect,(Texture2D)tex[nowFran]);
        time+=Time.deltaTime;
        if(time>1/fps){
            nowFran++;
            time=0;
            if(nowFran>=tex.Length){
                nowFran=0;
            }
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值