Beispiel #1
0
    /// <summary>
    /// 非同期ダウンロードメソッド
    /// </summary>
    /// <param name="url"></param>
    /// <returns></returns>
    public IEnumerator SetImageIE(MsgThumbnailData ThumbnailData, bool FlgFirst)
    {
        //データダウンロード
        using (WWW www = new WWW(CreateUrl(ThumbnailData)))
        {
            // 画像ダウンロード完了を待機
            yield return(www);

            //タイトル設定
            this.textTitle.text = ThumbnailData.thumbnailUrl;

            //画像ダウンロードエラーチェック
            if (!string.IsNullOrEmpty(www.error))
            {
                Debug.Log(www.error);
                yield break;
            }

            try
            {
                int width  = www.texture.width;
                int height = www.texture.height;

                //テクスチャ生成
                ThumbnailData.CreateTex(www.texture);

                //最初のデータならウインドウ表示
                if (FlgFirst)
                {
                    SetFirstPicture();
                }

                //WEBのテクスチャ解放
                Destroy(www.texture);
            }
            catch (Exception ex)
            {
                Debug.Log(ex);
            }
        }
    }
        /// <summary>
        /// 非同期ダウンロードメソッド
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public IEnumerator SetImageIE(MsgThumbnailData ThumbnailData, bool FlgFirst)
        {
            //タイトル設定
            this.textTitle.text = ThumbnailData.thumbnailUrl;

            //最新ニュースデータ取得
            var Async = LiplisCache.Instance.ImagePath.GetWebTexutre(CreateUrl(ThumbnailData));

            //非同期実行
            yield return(StartCoroutine(Async));

            //データ取得
            Texture2D texture = (Texture2D)Async.Current;

            //ボタンのテキスト変更
            if (texture != null)
            {
                try
                {
                    int width  = texture.width;
                    int height = texture.height;

                    //テクスチャ生成
                    ThumbnailData.CreateTex(texture);

                    //最初のデータならウインドウ表示
                    if (FlgFirst)
                    {
                        SetFirstPicture();
                    }
                }
                catch
                {
                }
            }
            else
            {
            }

            ////データダウンロード
            //using (WWW www = new WWW(CreateUrl(ThumbnailData)))
            //{
            //    // 画像ダウンロード完了を待機
            //    yield return www;

            //    //タイトル設定
            //    this.textTitle.text = ThumbnailData.thumbnailUrl;

            //    //画像ダウンロードエラーチェック
            //    if (!string.IsNullOrEmpty(www.error))
            //    {
            //        Debug.Log(www.error);
            //        yield break;
            //    }

            //    try
            //    {
            //        int width = www.texture.width;
            //        int height = www.texture.height;

            //        //テクスチャ生成
            //        ThumbnailData.CreateTex(www.texture);

            //        //最初のデータならウインドウ表示
            //        if (FlgFirst)
            //        {
            //            SetFirstPicture();
            //        }

            //        //WEBのテクスチャ解放
            //        Destroy(www.texture);
            //    }
            //    catch (Exception ex)
            //    {
            //        Debug.Log(ex);
            //    }
            //}
        }