/** CreateWebRequestInstance */ private static UnityEngine.Networking.UnityWebRequest CreateWebRequestInstance(Fee.File.Path a_path, UnityEngine.WWWForm a_post_data, Fee.File.CustomCertificateHandler a_certificate_handler) { UnityEngine.Networking.UnityWebRequest t_webrequest = null; if (a_post_data != null) { t_webrequest = UnityEngine.Networking.UnityWebRequest.Post(a_path.GetPath(), a_post_data); } else { t_webrequest = UnityEngine.Networking.UnityWebRequest.Get(a_path.GetPath()); } if (a_certificate_handler != null) { a_certificate_handler.InitializeCheck(); t_webrequest.certificateHandler = a_certificate_handler; } else { t_webrequest.certificateHandler = new Fee.File.CustomCertificateHandler(Fee.File.File.GetInstance().GetCertificateString(a_path.GetPath())); } return(t_webrequest); }
/** CreateWebRequestInstance */ private static UnityEngine.Networking.UnityWebRequest CreateWebRequestInstance(Fee.File.Path a_path, System.Collections.Generic.List <UnityEngine.Networking.IMultipartFormSection> a_post_data, Fee.File.CustomCertificateHandler a_certificate_handler) { UnityEngine.Networking.UnityWebRequest t_webrequest = null; if (a_post_data != null) { t_webrequest = UnityEngine.Networking.UnityWebRequest.Post(a_path.GetPath(), a_post_data); } else { t_webrequest = UnityEngine.Networking.UnityWebRequest.Get(a_path.GetPath()); } if (a_certificate_handler != null) { t_webrequest.certificateHandler = a_certificate_handler; } else { string t_certificate_string = Fee.File.File.GetInstance().GetCertificateString(a_path.GetPath()); if (t_certificate_string != null) { t_webrequest.certificateHandler = new Fee.File.CustomCertificateHandler(t_certificate_string); } } return(t_webrequest); }
/** ロード。 */ public void Load(string a_name) { Item t_item = null; if(this.list.TryGetValue(a_name,out t_item) == true){ //読み込み済み。 if(t_item != null){ t_item.reference_count++; } } if(t_item == null){ int t_sound_id = 0; //読み込み。 #if(UNITY_ANDROID) try{ //1固定。 int t_priority = (int)LoadPriority.RESERVATION; if(this.java_soundpool != null){ Fee.File.Path t_path = Fee.File.Path.CreateLocalPath(a_name,Fee.File.Path.SEPARATOR); t_sound_id = this.java_soundpool.Call<int>("load",t_path.GetPath(),t_priority); } }catch(System.Exception t_exception){ Tool.DebugReThrow(t_exception); } #endif Tool.Log("SoundPool","Load : " + a_name); //追加。 this.list.Add(a_name,new Item(t_sound_id)); } }
/** WEBリクエスト作成。 */ public static UnityEngine.Networking.UnityWebRequest CreateWebRequest(Fee.File.Path a_uri_path, UnityEngine.Networking.CertificateHandler a_certificate) { UnityEngine.Networking.UnityWebRequest t_webrequest = null; try{ t_webrequest = UnityEngine.Networking.UnityWebRequest.Get(a_uri_path.GetPath()); if (a_certificate != null) { t_webrequest.certificateHandler = a_certificate; } UnityEngine.Networking.UnityWebRequestAsyncOperation t_async = t_webrequest.SendWebRequest(); while (t_async.isDone == false) { System.Threading.Thread.Sleep(100); } }catch (System.Exception t_exception) { Tool.EditorLogError(t_exception.Message); t_webrequest = null; } return(t_webrequest); }
/** URLを開く。 */ public void OpenUrl(Fee.File.Path a_path) { #if (UNITY_EDITOR) { UnityEngine.Application.OpenURL(a_path.GetPath()); } #elif (UNITY_WEBGL) { WebGL_OpenUrl.OpenUrl(this.root_monobehaviour, a_path.GetPath()); } #else { UnityEngine.Application.OpenURL(a_path.GetPath()); } #endif }
/** ビデオプレイヤ。作成。 */ private void CreateVideoPlayer(Fee.File.Path a_full_path) { this.videoplayer = Fee.Video.Video.GetInstance().GetRootGameObject().AddComponent <UnityEngine.Video.VideoPlayer>(); this.videoplayer.playOnAwake = false; //描画先。 this.videoplayer.renderMode = UnityEngine.Video.VideoRenderMode.RenderTexture; this.videoplayer.targetTexture = this.rendertexture; //音声。 this.videoplayer.audioOutputMode = UnityEngine.Video.VideoAudioOutputMode.Direct; //ループ。 this.videoplayer.isLooping = false; //最初のフレームが準備できるまで待つ。 this.videoplayer.waitForFirstFrame = true; //フレームスキップ。 this.videoplayer.skipOnDrop = true; //再生速度。 this.videoplayer.playbackSpeed = 1.0f; //パス。 this.videoplayer.source = UnityEngine.Video.VideoSource.Url; this.videoplayer.url = a_full_path.GetPath(); }
/** アセットバンドル。作成。 */ public static void BuildAssetBundles(Fee.File.Path a_path, UnityEditor.AssetBundleBuild[] a_list, UnityEditor.BuildAssetBundleOptions a_option, UnityEditor.BuildTarget a_buildtarget) { try{ UnityEditor.BuildPipeline.BuildAssetBundles("Assets/" + a_path.GetPath(), a_list, a_option, a_buildtarget); }catch (System.Exception t_exception) { Tool.EditorLogError(t_exception.Message); } }
/** シーンを開く。 */ public static void OpenScene(Fee.File.Path a_path) { try{ UnityEditor.SceneManagement.EditorSceneManager.OpenScene("Assets/" + a_path.GetPath(), UnityEditor.SceneManagement.OpenSceneMode.Single); }catch (System.Exception t_exception) { Tool.EditorLogError(t_exception.Message); } }
/** テキストファイル読み込み。 * * a_path : フルパス。 * */ public static string ReadTextFile(Fee.File.Path a_full_path) { string t_string = null; try{ using (System.IO.StreamReader t_stream = new System.IO.StreamReader(a_full_path.GetPath())){ t_string = t_stream.ReadToEnd(); t_stream.Close(); } UnityEngine.Debug.Log("ReadTextFile : " + a_full_path.GetPath()); }catch (System.Exception t_exception) { UnityEngine.Debug.LogError(t_exception.Message); } return(t_string); }
/** SaveMesh */ public static void SaveMesh(UnityEngine.Mesh a_mesh, Fee.File.Path a_assets_path) { try{ UnityEngine.Mesh t_new = UnityEngine.Object.Instantiate <UnityEngine.Mesh>(a_mesh); UnityEditor.AssetDatabase.CreateAsset(t_new, "Assets/" + a_assets_path.GetPath()); }catch (System.Exception t_exception) { Tool.EditorLogError(t_exception.Message); } }
/** テキストファイル書き込み。 * * a_path : フルパス。 * */ public static void WriteTextFile(Fee.File.Path a_full_path, string a_text, bool a_refresh_unity) { try{ using (System.IO.StreamWriter t_stream = new System.IO.StreamWriter(a_full_path.GetPath(), false, new System.Text.UTF8Encoding(false))){ t_stream.Write(a_text); t_stream.Flush(); t_stream.Close(); } UnityEngine.Debug.Log("WriteTextFile : " + a_full_path.GetPath()); if (a_refresh_unity == true) { UnityEditor.AssetDatabase.Refresh(); } }catch (System.Exception t_exception) { UnityEngine.Debug.LogError(t_exception.Message); } }
/** SaveAnimationClip */ public static void SaveAnimationClip(UnityEngine.AnimationClip a_animation_clip, Fee.File.Path a_assets_path) { try{ string t_path = "Assets/" + a_assets_path.GetPath(); UnityEngine.AnimationClip t_new = UnityEngine.Object.Instantiate <UnityEngine.AnimationClip>(a_animation_clip); UnityEditor.AssetDatabase.CreateAsset(t_new, t_path); }catch (System.Exception t_exception) { Tool.EditorLogError(t_exception.Message); } }
/** JSONファイル書き込み。 * * a_full_path : フルパス。 * */ public static void WriteJsonFile(Fee.File.Path a_full_path, Fee.JsonItem.JsonItem a_jsonitem, bool a_refresh) { try{ string t_json_string = a_jsonitem.ConvertToJsonString(); using (System.IO.StreamWriter t_steram = new System.IO.StreamWriter(a_full_path.GetPath(), false, new System.Text.UTF8Encoding(false))){ t_steram.Write(t_json_string); t_steram.Flush(); t_steram.Close(); } UnityEngine.Debug.Log("WriteJsonFile : " + a_full_path.GetPath()); if (a_refresh == true) { UnityEditor.AssetDatabase.Refresh(); } }catch (System.Exception t_exception) { UnityEngine.Debug.LogError(t_exception.Message); } }
/** ファイル存在チェック。 * * a_full_path : フルパス。 * */ public static bool IsExistFile(Fee.File.Path a_full_path) { bool t_ret = false; try{ t_ret = System.IO.File.Exists(a_full_path.GetPath()); }catch (System.Exception t_exception) { UnityEngine.Debug.LogError(t_exception.Message); t_ret = false; } return(t_ret); }
/** アセットをロード。 * * a_assets_path : アセットフォルダからの相対パス。 * */ public static T LoadAsset <T>(Fee.File.Path a_assets_path) where T : UnityEngine.Object { T t_object; try{ t_object = UnityEditor.AssetDatabase.LoadAssetAtPath <T>("Assets/" + a_assets_path.GetPath()); }catch (System.Exception t_exception) { UnityEngine.Debug.LogError(t_exception.Message); t_object = null; } return(t_object); }
/** バイナリファイル書き込み。 */ public static void WriteBinaryFile(Fee.File.Path a_assets_path, byte[] a_binary) { try{ using (System.IO.BinaryWriter t_stream = new System.IO.BinaryWriter(System.IO.File.Open(Fee.File.Path.CreateAssetsPath(a_assets_path, Fee.File.Path.SEPARATOR).GetPath(), System.IO.FileMode.Create))){ t_stream.Write(a_binary); t_stream.Flush(); t_stream.Close(); } Tool.EditorLog("WriteBinaryFile : " + a_assets_path.GetPath()); }catch (System.Exception t_exception) { Tool.EditorLogError(t_exception.Message); } }
/** テキストファイル書き込み。 */ public static void WriteTextFile(Fee.File.Path a_assets_path, string a_text) { try{ using (System.IO.StreamWriter t_stream = new System.IO.StreamWriter(Fee.File.Path.CreateAssetsPath(a_assets_path, Fee.File.Path.SEPARATOR).GetPath(), false, new System.Text.UTF8Encoding(false))){ t_stream.Write(a_text); t_stream.Flush(); t_stream.Close(); } Tool.EditorLog("WriteTextFile : " + a_assets_path.GetPath()); }catch (System.Exception t_exception) { Tool.EditorLogError(t_exception.Message); } }
/** JSONファイル書き込み。 */ public static void WriteJsonFile(Fee.File.Path a_assets_path, Fee.JsonItem.JsonItem a_jsonitem) { try{ string t_json_string = a_jsonitem.ConvertToJsonString(); using (System.IO.StreamWriter t_steram = new System.IO.StreamWriter(Fee.File.Path.CreateAssetsPath(a_assets_path, Fee.File.Path.SEPARATOR).GetPath(), false, new System.Text.UTF8Encoding(false))){ t_steram.Write(t_json_string); t_steram.Flush(); t_steram.Close(); } Tool.EditorLog("WriteJsonFile : " + a_assets_path.GetPath()); }catch (System.Exception t_exception) { Tool.EditorLogError(t_exception.Message); } }
/** テキストファイル読み込み。 */ public static string ReadTextFile(Fee.File.Path a_assets_path) { string t_string = null; try{ using (System.IO.StreamReader t_stream = new System.IO.StreamReader(Fee.File.Path.CreateAssetsPath(a_assets_path, Fee.File.Path.SEPARATOR).GetPath())){ t_string = t_stream.ReadToEnd(); t_stream.Close(); } Tool.EditorLog("ReadTextFile : " + a_assets_path.GetPath()); }catch (System.Exception t_exception) { Tool.EditorLogError(t_exception.Message); } return(t_string); }
/** バイナリファイル書き込み。 * * a_full_path : フルパス。 * */ public static void WriteBinaryFile(Fee.File.Path a_full_path, byte[] a_binary, bool a_refresh) { try{ using (System.IO.BinaryWriter t_stream = new System.IO.BinaryWriter(System.IO.File.Open(a_full_path.GetPath(), System.IO.FileMode.Create))){ t_stream.Write(a_binary); t_stream.Flush(); t_stream.Close(); } UnityEngine.Debug.Log("WriteBinaryFile : " + a_full_path.GetPath()); if (a_refresh == true) { UnityEditor.AssetDatabase.Refresh(); } }catch (System.Exception t_exception) { UnityEngine.Debug.LogError(t_exception.Message); } }
/** SavePrefab * * a_assets_path : アセットフォルダからの相対パス。 * */ public static void SavePrefab(UnityEngine.GameObject a_prefab, Fee.File.Path a_assets_path) { try{ string t_path = "Assets/" + a_assets_path.GetPath(); bool t_ret; UnityEditor.PrefabUtility.SaveAsPrefabAsset(a_prefab, t_path, out t_ret); if (t_ret == false) { UnityEngine.Debug.LogError("SavePrefab : error"); } else { UnityEngine.Debug.Log("SavePrefab : " + t_path); } UnityEditor.AssetDatabase.Refresh(); }catch (System.Exception t_exception) { UnityEngine.Debug.LogError(t_exception.Message); } }
/** 開く。 */ public static System.Data.DataSet Open(Fee.File.Path a_path) { System.Data.DataSet t_workbook = null; try{ using (System.IO.FileStream t_stream = System.IO.File.Open(a_path.GetPath(), System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite)){ if (t_stream != null) { using (ExcelDataReader.IExcelDataReader t_reader = ExcelDataReader.ExcelReaderFactory.CreateOpenXmlReader(t_stream)){ if (t_reader != null) { t_workbook = ExcelDataReader.ExcelDataReaderExtensions.AsDataSet(t_reader); } } } } }catch (System.Exception t_exception) { Tool.DebugReThrow(t_exception); } return(t_workbook); }
/** アセットをロード。 * * a_assets_path : アセットフォルダからの相対パス。 * */ public static UnityEngine.Object[] LoadAllAsset(Fee.File.Path a_assets_path) { UnityEngine.Object[] t_object_list = null; try{ t_object_list = UnityEditor.AssetDatabase.LoadAllAssetsAtPath("Assets/" + a_assets_path.GetPath()); }catch (System.Exception t_exception) { UnityEngine.Debug.LogError(t_exception.Message); t_object_list = null; } return(t_object_list); }
/** 追加。 */ public void Add(Fee.File.Path a_path, string a_separator) { this.Add(a_path.GetPath(), a_separator); }
/** CoroutineMain */ public System.Collections.IEnumerator CoroutineMain(Fee.File.OnFileCoroutine_CallBackInterface a_callback_interface, Fee.File.Path a_path, System.Collections.Generic.List <UnityEngine.Networking.IMultipartFormSection> a_post_data, Fee.File.CustomCertificateHandler a_certificate_handler) { //result this.result = null; //ロード。 byte[] t_result_binary = null; System.Collections.Generic.Dictionary <string, string> t_result_responseheader = null; long t_result_responsecode = 0; { using (UnityEngine.Networking.UnityWebRequest t_webrequest = CreateWebRequestInstance(a_path, a_post_data, a_certificate_handler)){ //通信。 { UnityEngine.Networking.UnityWebRequestAsyncOperation t_webrequest_async = null; if (t_webrequest != null) { t_webrequest_async = t_webrequest.SendWebRequest(); if (t_webrequest_async == null) { //エラー。 this.result = new ResultType(null, "Unknown Error : LoadUrlTextFile : " + a_path.GetPath(), t_webrequest.GetResponseHeaders(), t_webrequest.responseCode); yield break; } } else { //エラー。 this.result = new ResultType(null, "Unknown Error : LoadUrlTextFile : " + a_path.GetPath(), t_webrequest.GetResponseHeaders(), t_webrequest.responseCode); yield break; } do { //エラーチェック。 if (t_webrequest.result == UnityEngine.Networking.UnityWebRequest.Result.InProgress) { //実行中。 } else if (t_webrequest.result == UnityEngine.Networking.UnityWebRequest.Result.Success) { //正常終了。 yield return(t_webrequest_async); break; } else { //エラー。 if (t_webrequest.error != null) { this.result = new ResultType(null, "Connect Error : LoadUrlTextFile : " + a_path.GetPath() + " : " + t_webrequest.error, t_webrequest.GetResponseHeaders(), t_webrequest.responseCode); } else { this.result = new ResultType(null, "Connect Error : LoadUrlTextFile : " + a_path.GetPath(), t_webrequest.GetResponseHeaders(), t_webrequest.responseCode); } yield break; } //キャンセルチェック。 { if (a_callback_interface != null) { float t_progress = (t_webrequest.uploadProgress + t_webrequest.downloadProgress) / 2; if (a_callback_interface.OnFileCoroutine(t_progress) == false) { t_webrequest.Abort(); } } } yield return(null); }while(true); } //コンバート。 try{ if (t_webrequest.downloadHandler == null) { //エラー。 this.result = new ResultType(null, "Convert Error : LoadUrlTextFile : " + a_path.GetPath(), t_webrequest.GetResponseHeaders(), t_webrequest.responseCode); yield break; } byte[] t_result = t_webrequest.downloadHandler.data; if (t_result == null) { //エラー。 this.result = new ResultType(null, "Convert Error : LoadUrlTextFile : " + a_path.GetPath(), t_webrequest.GetResponseHeaders(), t_webrequest.responseCode); yield break; } t_result_binary = t_result; }catch (System.Exception t_exception) { //エラー。 this.result = new ResultType(null, "Convert Error : LoadUrlTextFile : " + a_path.GetPath() + " : " + t_exception.Message, t_webrequest.GetResponseHeaders(), t_webrequest.responseCode); yield break; } //レスポンスヘッダー。 t_result_responseheader = t_webrequest.GetResponseHeaders(); t_result_responsecode = t_webrequest.responseCode; } } //コンバート。 string t_result_text = null; { string t_result = Fee.StringConvert.Utf8BinaryToString.Convert(t_result_binary, 0, t_result_binary.Length); if (t_result != null) { //成功。 t_result_text = t_result; } else { //エラー。 this.result = new ResultType(null, "Convert Error : LoadUrlTextFile : " + a_path.GetPath(), t_result_responseheader, t_result_responsecode); yield break; } } //成功。 this.result = new ResultType(t_result_text, null, t_result_responseheader, t_result_responsecode); yield break; }
/** CoroutineMain */ public System.Collections.IEnumerator CoroutineMain(Fee.File.OnFileCoroutine_CallBackInterface a_callback_interface, Fee.File.Path a_path) { //result this.result = null; //ロード。 byte[] t_result_binary = null; { //開始。 { do { try{ bool t_result = Fee.Platform.Platform.GetInstance().LoadAndroidContentFile_Start(a_path); if (t_result == true) { //成功。 break; } else { //キャンセルチェック。 if (a_callback_interface != null) { if (a_callback_interface.OnFileCoroutine(0.0f) == false) { //エラー。 this.result = new ResultType(null, "Cancel : LoadAndroidContentTextFile : " + a_path.GetPath()); yield break; } } } }catch (System.Exception t_exception) { //エラー。 this.result = new ResultType(null, "Unknown Error : LoadAndroidContentTextFile : " + a_path.GetPath() + " : " + t_exception.Message); yield break; } yield return(null); }while(true); } //読み込み中。 { do { try{ if (Fee.Platform.Platform.GetInstance().LoadAndroidContentFile_IsComplate() == true) { byte[] t_result = Fee.Platform.Platform.GetInstance().LoadAndroidContentFile_GetResult(); if (t_result == null) { //エラー。 this.result = new ResultType(null, "Load Error : LoadAndroidContentTextFile : " + a_path.GetPath()); yield break; } //成功。 t_result_binary = t_result; break; } else { //キャンセルチェック。 { if (a_callback_interface != null) { if (a_callback_interface.OnFileCoroutine(0.0f) == false) { Fee.Platform.Platform.GetInstance().LoadAndroidContentFile_Cancel(); } } } } }catch (System.Exception t_exception) { //エラー。 this.result = new ResultType(null, "Load Error : LoadAndroidContentTextFile : " + a_path.GetPath() + " : " + t_exception.Message); yield break; } yield return(null); }while(true); //終了。 Fee.Platform.Platform.GetInstance().LoadAndroidContentFile_End(); } } //コンバート。 string t_result_text = null; { try{ string t_result = Fee.StringConvert.Utf8BinaryToString.Convert(t_result_binary, 0, t_result_binary.Length); if (t_result == null) { //エラー。 this.result = new ResultType(null, "Convert Error : LoadAndroidContentTextFile : " + a_path.GetPath()); yield break; } t_result_text = t_result; }catch (System.Exception t_exception) { //エラー。 this.result = new ResultType(null, "Convert Error : LoadAndroidContentTextFile : " + a_path.GetPath() + " : " + t_exception.Message); yield break; } } //成功。 this.result = new ResultType(t_result_text, null); yield break; }
/** FileMain */ private static void FileMain(Fee.File.Path a_assets_path) { string t_full_path = Fee.File.Path.CreateAssetsPath(a_assets_path, Fee.File.Path.SEPARATOR).GetPath(); string t_text = Fee.EditorTool.AssetTool.ReadTextFile(a_assets_path); if (t_text != null) { string[] t_list_text = t_text.Split(new char[] { '\n' }); for (int ii = 0; ii < t_list_text.Length; ii++) { string t_temp = t_list_text[ii]; //最後についている「\r」を削除。 { if (t_temp.Length > 0) { t_temp = System.Text.RegularExpressions.Regex.Replace(t_temp, "^(.*)\r$", "$1"); } } //「//」タイプのコメントを削除。 { if (t_temp.Length > 0) { System.Text.RegularExpressions.Regex t_regex = new System.Text.RegularExpressions.Regex("^(?<capture>.*)\\/\\/.*$"); System.Text.RegularExpressions.Match t_match = t_regex.Match(t_temp); if (t_match.Success == true) { string[] t_group_list = new string[] { "0", "capture" }; for (int jj = 0; jj < t_group_list.Length; jj++) { string t_group_name = t_group_list[jj]; System.Text.RegularExpressions.Group t_group = t_match.Groups[t_group_name]; if (t_group.Success == true) { switch (t_group_name) { case "0": { } break; case "capture": { if (t_temp != t_group.Value) { t_temp = t_group.Value; } } break; default: { #if (UNITY_EDITOR) Tool.EditorLogError(a_assets_path.GetPath() + ":" + ii.ToString() + ":" + t_group_name + ":" + t_group.Value + ":" + t_list_text[ii]); #endif } break; } } } } } } //「#if」「#elif」使用箇所検索。 { System.Text.RegularExpressions.Regex t_regex = new System.Text.RegularExpressions.Regex("^\\s*\\#\\s*(?<deftype>if|elif)\\s*(?<capture>.*)\\s*$"); System.Text.RegularExpressions.Match t_match = t_regex.Match(t_temp); if (t_match.Success == true) { string[] t_group_list = new string[] { "0", "deftype", "capture" }; for (int jj = 0; jj < t_group_list.Length; jj++) { string t_group_name = t_group_list[jj]; System.Text.RegularExpressions.Group t_group = t_match.Groups[t_group_name]; if (t_group.Success == true) { switch (t_group_name) { case "0": { } break; case "deftype": { } break; case "capture": { string[] t_list_define = t_group.Value.Split(new char[] { '(', ')', '|', '&', '!', ' ' }); for (int kk = 0; kk < t_list_define.Length; kk++) { if (t_list_define[kk].Length > 0) { DefineMain(t_temp, t_list_define[kk]); } } } break; default: { #if (UNITY_EDITOR) Tool.EditorLogError(a_assets_path.GetPath() + ":" + ii.ToString() + ":" + t_group_name + ":" + t_group.Value + ":" + t_list_text[ii]); #endif } break; } } } } } } } }
/** CreateAssetsPath * * a_relative_path : 相対パス。 * */ public static Path CreateAssetsPath(Fee.File.Path a_relative_path, string a_separator) { return(CreateAssetsPath(a_relative_path.GetPath(), a_separator)); }
/** 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; }
/** 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; }