/** 実行。
  */
 public static Fee.TaskW.Task <ResultType> Run(Fee.File.OnFileTask_CallBackInterface a_callback_interface, Path a_path, Fee.TaskW.CancelToken a_cancel)
 {
     return(new Fee.TaskW.Task <ResultType>(() => {
         return Task_LoadLocalBinaryFile.TaskMain(a_callback_interface, a_path, a_cancel);
     }));
 }
Ejemplo n.º 2
0
        /** CoroutineMain
         */
        public System.Collections.IEnumerator CoroutineMain(Fee.File.OnFileCoroutine_CallBackInterface a_callback_interface, Fee.File.Path a_path)
        {
            //result
            this.result = null;

            //taskprogress_
            this.taskprogress = 0.0f;

            //ロード。
            byte[] t_result_binary = null;
            {
                //キャンセルトークン。
                Fee.TaskW.CancelToken t_cancel_token = new Fee.TaskW.CancelToken();

                //タスク起動。
                using (Fee.TaskW.Task <Task_LoadLocalBinaryFile.ResultType> t_task = Task_LoadLocalBinaryFile.Run(this, a_path, t_cancel_token)){
                    //終了待ち。
                    do
                    {
                        //キャンセルチェック。
                        {
                            if (a_callback_interface != null)
                            {
                                if (a_callback_interface.OnFileCoroutine(this.taskprogress) == false)
                                {
                                    t_cancel_token.Cancel();
                                }
                            }
                        }

                        yield return(null);
                    }while(t_task.IsEnd() == false);

                    //結果。
                    Task_LoadLocalBinaryFile.ResultType t_result = t_task.GetResult();

                    if (t_result.errorstring != null)
                    {
                        //エラー。
                        this.result = new ResultType(null, t_result.errorstring);
                        yield break;
                    }

                    if (t_task.IsSuccess() == false)
                    {
                        //エラー。
                        this.result = new ResultType(null, "Task Error : LoadLocalTextureFile : " + a_path.GetPath());
                        yield break;
                    }

                    if (t_result.binary == null)
                    {
                        //エラー。
                        this.result = new ResultType(null, "Unknown Error : LoadLocalTextureFile : " + a_path.GetPath());
                        yield break;
                    }

                    //成功。
                    t_result_binary = t_result.binary;
                }
            }

            //コンバート。
            UnityEngine.Texture2D t_result_texture = null;
            {
                t_result_texture = BinaryToTexture2D.Convert(t_result_binary);
                if (t_result_texture == null)
                {
                    //エラー。
                    this.result = new ResultType(null, "Convert Error : LoadLocalTextureFile : " + a_path.ToString());
                    yield break;
                }
            }

            //成功。
            this.result = new ResultType(t_result_texture, null);
            yield break;
        }