玲珑杯Unity开发心得——进度条界面(异步加载游戏场景)

/////////////2015/08/04//////////////

////////////by xbw////////////////////

///////////环境 unity 4.6//////////


先上效果图

玲珑杯Unity开发心得——进度条界面(异步加载游戏场景)_第1张图片

还可以吧,先贴一下代码,

using UnityEngine;

using System.Collections;

public class Loading4 : MonoBehaviour
{

    public Texture2D load_write;    //进度条底纹

    public Texture2D load_yellow;   //进度条

    public float loading = 0f;        //进度条数字显示

    public Texture2D img;

    public GUISkin GUIskin;

    //在这里记录当前切换场景的名称

    // public static string loadName;



    void Update()
    {

        if (loading >= 100)
        {

            Application.LoadLevel("kupao");

        }

        else
        {

            loading += Time.deltaTime * 20;

        }

    }

    void OnGUI()
    {

        //加载背景图

        GUIStyle backGround = new GUIStyle();

        backGround.normal.background = img;

        GUI.Label(new Rect(0, 0, Screen.width, Screen.height), "", backGround);

        //进度条加载

        if (loading <= 100)
        {

            float blood_width = load_yellow.width * loading / 100;

            //进度条底纹

            GUI.DrawTexture(new Rect(Screen.width * 0.3f, Screen.height * 0.9f, load_write.width, load_write.height), load_write);

            //进度条

            GUI.DrawTexture(new Rect(Screen.width * 0.3f, Screen.height * 0.9f, blood_width, load_yellow.height), load_yellow);

            //Loading 字体

            GUIStyle go = new GUIStyle();

            go.fontSize = 30;

            go.normal.textColor =new Color(255, 255, 255);

            GUI.skin = GUIskin;
            GUI.Label(new Rect(Screen.width * 0.3f, Screen.height * 0.8f, 100, 100), "Loading.....", go);

            //加载数字的显示

            GUIStyle go1 = new GUIStyle();
            go1.fontSize = 30;

            //go1.normal.textColor = Color.blue;

            GUI.skin = GUIskin;
            GUI.Label(new Rect(Screen.width * 0.6f, Screen.height * 0.8f, 100, 100), (int)loading + "%", go);

        }

    }

}


这个素材我整理一下打个包吧,不详细介绍了,使用中发现问题留言给我就好了;;

链接:http://pan.baidu.com/s/1mgGLGrm 密码:7r5p





你可能感兴趣的:(玲珑杯Unity开发心得——进度条界面(异步加载游戏场景))