Beispiel #1
0
    static IEnumerator InvokeLoadImage(WwwImage ic, UnityAction <float> uaing, UnityAction <float> uaend)
    {
        //注册回调事件
        WwwCallBack wle = new WwwCallBack();

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

        ic.LoadState = LoadState.LoadIng;

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

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

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

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

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


            if (ic.SourceUrl.Contains(".gif"))
            {
                ic.ImageContent = AnalysisPage.GetGifImage(www.bytes, 0);
            }
            else
            {
                ic.ImageContent = www.texture;
            }

            ic.LoadState = LoadState.LoadComplete;
        }

        ic.LoadEndTime = DateTime.Now;
        wle.ActiveEndEvent(true);
    }
Beispiel #2
0
 /// <summary>
 /// 加载图片
 /// </summary>
 /// <param name="ic">图片内容</param>
 /// <param name="uaing">加载中回调</param>
 /// <param name="uaend">加载结束回调</param>
 public static void LoadImage(WwwImage ic, UnityAction <float> uaing, UnityAction <float> uaend)
 {
     LoadImage(ic, MonoBehaviourAnysc.AnyscMonoBehaviour, uaing, uaend);
 }
Beispiel #3
0
 /// <summary>
 /// 加载图片
 /// </summary>
 /// <param name="ic">图片内容</param>
 /// <param name="mb">MonoBehaviour</param>
 /// <param name="uaing">加载中回调</param>
 /// <param name="uaend">加载结束回调</param>
 public static void LoadImage(WwwImage ic, MonoBehaviour mb, UnityAction <float> uaing, UnityAction <float> uaend)
 {
     mb.StartCoroutine(InvokeLoadImage(ic, uaing, uaend));
 }
Beispiel #4
0
    static IEnumerator InvokeLoadImage(WwwImage ic, UnityAction<float> uaing, UnityAction<float> uaend)
    {
        //注册回调事件
        WwwCallBack wle = new WwwCallBack();
        if (uaing != null)
            wle.AddIngEvent(uaing);
        if (uaend != null)
            wle.AddEndEvent(uaend);

        ic.LoadState = LoadState.LoadIng;

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

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

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

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

            if (ic.SourceUrl.Contains(".gif"))
            {
                ic.ImageContent = AnalysisPage.GetGifImage(www.bytes, 0);
            }
            else
            {
                ic.ImageContent = www.texture;
            }

            ic.LoadState = LoadState.LoadComplete;
        }

        ic.LoadEndTime = DateTime.Now;
        wle.ActiveEndEvent(true);
    }
Beispiel #5
0
 /// <summary>
 /// 加载图片
 /// </summary>
 /// <param name="ic">图片内容</param>
 /// <param name="uaing">加载中回调</param>
 /// <param name="uaend">加载结束回调</param>
 public static void LoadImage(WwwImage ic, UnityAction<float> uaing, UnityAction<float> uaend)
 {
     LoadImage(ic, MonoBehaviourAnysc.AnyscMonoBehaviour, uaing, uaend);
 }
Beispiel #6
0
 /// <summary>
 /// 加载图片
 /// </summary>
 /// <param name="ic">图片内容</param>
 /// <param name="mb">MonoBehaviour</param>
 /// <param name="uaing">加载中回调</param>
 /// <param name="uaend">加载结束回调</param>
 public static void LoadImage(WwwImage ic, MonoBehaviour mb, UnityAction<float> uaing, UnityAction<float> uaend)
 {
     mb.StartCoroutine(InvokeLoadImage(ic, uaing, uaend));
 }