简单的游戏界面设计

先看效果 自己做那还是游戏啊 失败失败
简单的游戏界面设计_第1张图片

自己只有一点点图片 图片多可以自己去替换下面的文件夹中的图片
简单的游戏界面设计_第2张图片

主要的代码
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;
            }
        }
    }
}

你可能感兴趣的:(Unity3D,内置)