예제 #1
0
    void OnGUI_Example_Ready()
    {
        //启动成功
        GUI.Label(new Rect(0f, 0f, Screen.width, 20f), "AssetBundlePacker launch succeed, Version is " + AssetBundleManager.Instance.strVersion);
        //下载地址
        GUI.Label(new Rect(0f, 20f, 100f, 20f), "下载地址:");
        URL = GUI.TextField(new Rect(100f, 20f, Screen.width - 100f, 20f), URL);

        //启动
        if (downloader_ == null)
        {
            if (GUI.Button(new Rect(0f, 40f, Screen.width, 30f), "下载资源包(" + PACKAGE_NAME + ")"))
            {
                LaunchDownloader();
            }
        }
        else
        {
            //当前更新阶段
            GUI.Label(new Rect(0, 40f, Screen.width, 20f), STATE_DESCRIBE_TABLE[(int)downloader_.CurrentState]);
            //当前阶段进度
            GUI.HorizontalScrollbar(new Rect(0f, 60f, Screen.width, 30f)
                                    , 0f, downloader_.CurrentStateCompleteValue
                                    , 0f, downloader_.CurrentStateTotalValue);

            if (!downloader_.IsDone && !downloader_.IsFailed)
            {
                if (GUI.Button(new Rect(0, 80f, Screen.width, 20f), "中断下载"))
                {
                    Debug.Log("Abort Download");
                    downloader_.AbortDownload();
                    Destroy(downloader_);
                }
            }
            else if (downloader_.IsDone)
            {
                if (downloader_.IsFailed)
                {
                    if (GUI.Button(new Rect(0, 80f, Screen.width, 20f), "下载失败,重新开始"))
                    {
                        Destroy(downloader_);
                    }
                }
                else
                {
                    GUI.Label(new Rect(0, 80f, Screen.width, 20f), "下载成功");
                }
            }
        }
    }