unity基础开发----页面加载动画代码

来源:互联网 发布:fashion tv直播软件 编辑:程序博客网 时间:2024/05/12 09:17
using UnityEngine;using System.Collections;/// <summary>/// Loading manager./// /// This Script handles the loading of the Main scene in background/// displaying a loading animation while the scene is being loaded/// </summary>public class LoadingManager : MonoBehaviour{    #region PRIVATE_MEMBER_VARIABLES    private Texture Spinner;    private bool mChangeLevel = true;    #endregion // PRIVATE_MEMBER_VARIABLES    #region UNITY_MONOBEHAVIOUR_METHODS    void Awake()    {        Resources.UnloadUnusedAssets();        System.GC.Collect();        Spinner = Resources.Load("GUI/spinner_XHigh") as Texture;    }    void Start()    {        //卸载        Resources.UnloadUnusedAssets();        System.GC.Collect();        Application.backgroundLoadingPriority = ThreadPriority.Low;        mChangeLevel = true;    }    void Update()    {        if (mChangeLevel)        {            LoadUserDefTargetsScene();            mChangeLevel = false;        }    }    void OnGUI()    {        Matrix4x4 oldMatrix = GUI.matrix;        float thisAngle = Time.frameCount * 4;        Rect thisRect = new Rect(Screen.width / 2.0f - Spinner.width / 2f, Screen.height / 2.0f - Spinner.height / 2f,                                 Spinner.width, Spinner.height);        //旋转        GUIUtility.RotateAroundPivot(thisAngle, thisRect.center);        GUI.DrawTexture(thisRect, Spinner);        //矩阵        GUI.matrix = oldMatrix;    }    #endregion UNITY_MONOBEHAVIOUR_METHODS    #region PRIVATE_METHODS    private void LoadUserDefTargetsScene()    {        Application.LoadLevelAsync("2-Penguin");    }    #endregion PRIVATE_METHODS}

0 0
原创粉丝点击