示例#1
0
    static IEnumerator InvokeLoadbundle(WwwBundle bc, UnityAction <float> uaing, UnityAction <float> uaend, ThreadPriority threadPriority)
    {
        //注册回调事件
        WwwCallBack wle = new WwwCallBack();

        if (uaing != null)
        {
            wle.AddIngEvent(uaing);
        }
        if (uaend != null)
        {
            wle.AddEndEvent(uaend);
        }

        bc.LoadState = LoadState.LoadIng;

        bc.LoadStartTime = DateTime.Now;
        //开始下载资源
        WWW www = new WWW(bc.SourceUrl);

        www.threadPriority = threadPriority;

        while (!www.isDone)// || www.progress <= 1)
        {
            float o = www.progress;
            bc.Progress = www.progress;
            wle.ActiveIngEvent(false, o);
            yield return(null);
        }
        float o1 = www.progress;

        bc.Progress = www.progress;
        wle.ActiveIngEvent(true, o1);

        //加载错误
        bc.LoadError = www.error;
        if (www.error != null)
        {
            bc.LoadState = LoadState.LoadFail;
            Debug.Log("Load Error:" + bc.SourceUrl + ":" + www.error);

            //MessageBox.ShowInEditor(www.error);
        }
        else
        {
            bc.Size = www.size;

            bc.Bundle = www.assetBundle;

            bc.LoadState = LoadState.LoadComplete;
        }

        bc.LoadEndTime = DateTime.Now;
        wle.ActiveEndEvent(true);
    }
示例#2
0
 /// <summary>
 /// 加载模型或场景文件
 /// </summary>
 /// <param name="bc">模型或场景文件内容</param>
 /// <param name="mb">MonoBehaviour</param>
 /// <param name="uaing">加载中回调</param>
 /// <param name="uaend">加载结束回调</param>
 /// <param name="threadPriority">优先级别</param>
 public static void LoadBundle(WwwBundle bc, MonoBehaviour mb, UnityAction <float> uaing, UnityAction <float> uaend, ThreadPriority threadPriority)
 {
     mb.StartCoroutine(InvokeLoadbundle(bc, uaing, uaend, threadPriority));
 }
示例#3
0
 /// <summary>
 /// 加载模型或场景文件
 /// </summary>
 /// <param name="bc">模型或场景文件内容</param>
 /// <param name="uaing">加载中回调</param>
 /// <param name="uaend">加载结束回调</param>
 public static void LoadBundle(WwwBundle bc, UnityAction <float> uaing, UnityAction <float> uaend)
 {
     LoadBundle(bc, MonoBehaviourAnysc.AnyscMonoBehaviour, uaing, uaend, ThreadPriority.Normal);
 }
示例#4
0
 /// <summary>
 /// 加载模型或场景文件
 /// </summary>
 /// <param name="bc">模型或场景文件内容</param>
 /// <param name="uaing">加载中回调</param>
 /// <param name="uaend">加载结束回调</param>
 public static void LoadBundle(WwwBundle bc, UnityAction<float> uaing, UnityAction<float> uaend)
 {
     LoadBundle(bc, MonoBehaviourAnysc.AnyscMonoBehaviour, uaing, uaend, ThreadPriority.Normal);
 }
示例#5
0
    static IEnumerator InvokeLoadbundle(WwwBundle bc, UnityAction<float> uaing, UnityAction<float> uaend, ThreadPriority threadPriority)
    {
        //注册回调事件
        WwwCallBack wle = new WwwCallBack();
        if (uaing != null)
            wle.AddIngEvent(uaing);
        if (uaend != null)
            wle.AddEndEvent(uaend);

        bc.LoadState = LoadState.LoadIng;

        bc.LoadStartTime = DateTime.Now;
        //开始下载资源
        WWW www = new WWW(bc.SourceUrl);
        www.threadPriority = threadPriority;

        while (!www.isDone)// || www.progress <= 1)
        {
            float o = www.progress;
            bc.Progress = www.progress;
            wle.ActiveIngEvent(false, o);
            yield return null;
        }
        float o1 = www.progress;
        bc.Progress = www.progress;
        wle.ActiveIngEvent(true, o1);

        //加载错误
        bc.LoadError = www.error;
        if (www.error != null)
        {
            bc.LoadState = LoadState.LoadFail;
            Debug.Log("Load Error:" + bc.SourceUrl + ":" + www.error);

            //MessageBox.ShowInEditor(www.error);
        }
        else
        {
            bc.Size = www.size;

            bc.Bundle = www.assetBundle;

            bc.LoadState = LoadState.LoadComplete;
        }

        bc.LoadEndTime = DateTime.Now;
        wle.ActiveEndEvent(true);
    }
示例#6
0
 /// <summary>
 /// 加载模型或场景文件
 /// </summary>
 /// <param name="bc">模型或场景文件内容</param>
 /// <param name="mb">MonoBehaviour</param>
 /// <param name="uaing">加载中回调</param>
 /// <param name="uaend">加载结束回调</param>
 /// <param name="threadPriority">优先级别</param>
 public static void LoadBundle(WwwBundle bc, MonoBehaviour mb, UnityAction<float> uaing, UnityAction<float> uaend, ThreadPriority threadPriority)
 {
     mb.StartCoroutine(InvokeLoadbundle(bc, uaing, uaend, threadPriority));
 }