/** CoroutineMain
         */
        public System.Collections.IEnumerator CoroutineMain(Fee.File.OnFileCoroutine_CallBackInterface a_callback_interface, Fee.File.Path a_path, byte[] a_binary)
        {
            //result
            this.result = null;

            //taskprogress_
            this.taskprogress = 0.0f;

            //チェック。
            if (a_binary == null)
            {
                //エラー。
                this.result = new ResultType(false, "Param Error : SaveLocalBinaryFile : " + a_path.GetPath());
                yield break;
            }

            //セーブ。
            bool t_result_saveend = false;

            {
                //キャンセルトークン。
                Fee.TaskW.CancelToken t_cancel_token = new Fee.TaskW.CancelToken();

                //タスク起動。
                using (Fee.TaskW.Task <Task_SaveLocalBinaryFile.ResultType> t_task = Task_SaveLocalBinaryFile.Run(this, a_path, a_binary, 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_SaveLocalBinaryFile.ResultType t_result = t_task.GetResult();

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

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

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

                    //成功。
                    t_result_saveend = t_result.saveend;
                }
            }

            this.result = new ResultType(t_result_saveend, null);
            yield break;
        }
Beispiel #2
0
        /** CoroutineMain
         */
        public System.Collections.IEnumerator CoroutineMain(Fee.File.OnFileCoroutine_CallBackInterface a_callback_interface, Fee.File.Path a_path, UnityEngine.Texture2D a_texture)
        {
            //result
            this.result = null;

            //taskprogress_
            this.taskprogress = 0.0f;

            //チェック。
            if (a_texture == null)
            {
                //エラー。
                this.result = new ResultType(false, "Convert Error : SaveLocalTextureFile : " + a_path.GetPath());
                yield break;
            }

            //コンバート。
            byte[] t_result_binary = null;
            {
                try{
                    byte[] t_result = UnityEngine.ImageConversion.EncodeToPNG(a_texture);

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

                    t_result_binary = t_result;
                }catch (System.Exception t_exception) {
                    //エラー。
                    this.result = new ResultType(false, "Convert Error : SaveLocalTextureFile : " + a_path.GetPath() + " : " + t_exception.Message);
                    yield break;
                }
            }

            //セーブ。
            bool t_result_saveend = false;

            {
                //キャンセルトークン。
                Fee.TaskW.CancelToken t_cancel_token = new Fee.TaskW.CancelToken();

                //タスク起動。
                using (Fee.TaskW.Task <Task_SaveLocalBinaryFile.ResultType> t_task = Task_SaveLocalBinaryFile.Run(this, a_path, t_result_binary, 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_SaveLocalBinaryFile.ResultType t_result = t_task.GetResult();

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

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

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

                    //成功。
                    t_result_saveend = t_result.saveend;
                }
            }

            this.result = new ResultType(t_result_saveend, null);
            yield break;
        }