/** コンバート */ public static bool ConvertFromJsonSheet(Fee.JsonItem.JsonItem a_jsonitem, Fee.JsonSheet.ConvertParam a_convertparam) { if (a_jsonitem == null) { Tool.Assert(false); return(false); } if (a_jsonitem.IsAssociativeArray() == false) { Tool.Assert(false); return(false); } //コンバードシート。確認。 if (a_jsonitem.IsExistItem(Config.SHEETNAME_CONVERT, Fee.JsonItem.ValueType.IndexArray) == false) { Tool.Assert(false); return(false); } //コンバートシート。取得。 Fee.JsonItem.JsonItem t_jsonitem_convertsheet = a_jsonitem.GetItem(Config.SHEETNAME_CONVERT); if (t_jsonitem_convertsheet == null) { Tool.Assert(false); return(false); } //コンバートシート。取得。 System.Collections.Generic.List <ConvertListItem> t_list_convert = Fee.JsonItem.Convert.JsonItemToObject <System.Collections.Generic.List <ConvertListItem> >(t_jsonitem_convertsheet); if (t_list_convert == null) { return(false); } //処理。 for (int ii = 0; ii < t_list_convert.Count; ii++) { Fee.JsonItem.JsonItem[] t_jsonitem_list = new Fee.JsonItem.JsonItem[4] { null, null, null, null }; if (string.IsNullOrEmpty(t_list_convert[ii].convert_sheet_0) == false) { if (a_jsonitem.IsExistItem(t_list_convert[ii].convert_sheet_0, Fee.JsonItem.ValueType.IndexArray) == true) { t_jsonitem_list[0] = a_jsonitem.GetItem(t_list_convert[ii].convert_sheet_0); } else { Tool.Assert(false); } } if (string.IsNullOrEmpty(t_list_convert[ii].convert_sheet_1) == false) { if (a_jsonitem.IsExistItem(t_list_convert[ii].convert_sheet_1, Fee.JsonItem.ValueType.IndexArray) == true) { t_jsonitem_list[1] = a_jsonitem.GetItem(t_list_convert[ii].convert_sheet_1); } else { Tool.Assert(false); } } if (string.IsNullOrEmpty(t_list_convert[ii].convert_sheet_2) == false) { if (a_jsonitem.IsExistItem(t_list_convert[ii].convert_sheet_2, Fee.JsonItem.ValueType.IndexArray) == true) { t_jsonitem_list[2] = a_jsonitem.GetItem(t_list_convert[ii].convert_sheet_2); } else { Tool.Assert(false); } } if (string.IsNullOrEmpty(t_list_convert[ii].convert_sheet_3) == false) { if (a_jsonitem.IsExistItem(t_list_convert[ii].convert_sheet_3, Fee.JsonItem.ValueType.IndexArray) == true) { t_jsonitem_list[3] = a_jsonitem.GetItem(t_list_convert[ii].convert_sheet_3); } else { Tool.Assert(false); } } switch (t_list_convert[ii].convert_command) { case ConvertSheet_Enum.COMMAND: { //ENUM。 ConvertSheet_Enum.Convert(t_list_convert[ii].convert_param, new Fee.File.Path(t_list_convert[ii].convert_output), t_jsonitem_list, a_convertparam); } break; case ConvertSheet_Json.COMMAND: { //JSON。 ConvertSheet_Json.Convert(t_list_convert[ii].convert_param, new Fee.File.Path(t_list_convert[ii].convert_output), t_jsonitem_list, a_convertparam); } break; case ConvertSheet_Prefab.COMMAND: { //プレハブ。 ConvertSheet_Prefab.Convert(t_list_convert[ii].convert_param, new File.Path(t_list_convert[ii].convert_output), t_jsonitem_list, a_convertparam); } break; case ConvertSheet_Data.COMMAND: { //データ。 ConvertSheet_Data.Convert(t_list_convert[ii].convert_param, new Fee.File.Path(t_list_convert[ii].convert_output), t_jsonitem_list, a_convertparam); } break; case ConvertSheet_AudioPrefab.COMMAND: { //オーディオプレハブ。 ConvertSheet_AudioPrefab.Convert(t_list_convert[ii].convert_param, new Fee.File.Path(t_list_convert[ii].convert_output), t_jsonitem_list, a_convertparam); } break; case ConvertSheet_MaterialPrefab.COMMAND: { //マテリアルプレハブ。 ConvertSheet_MaterialPrefab.Convert(t_list_convert[ii].convert_param, new File.Path(t_list_convert[ii].convert_output), t_jsonitem_list, a_convertparam); } break; case ConvertSheet_VideoPrefab.COMMAND: { //ビデオプレハブ。 ConvertSheet_VideoPrefab.Convert(t_list_convert[ii].convert_param, new File.Path(t_list_convert[ii].convert_output), t_jsonitem_list, a_convertparam); } break; case ConvertSheet_TexturePrefab.COMMAND: { //テクスチャプレハブ。 ConvertSheet_TexturePrefab.Convert(t_list_convert[ii].convert_param, new File.Path(t_list_convert[ii].convert_output), t_jsonitem_list, a_convertparam); } break; case ConvertSheet_FontPrefab.COMMAND: { //フォントプレハブ。 ConvertSheet_FontPrefab.Convert(t_list_convert[ii].convert_param, new File.Path(t_list_convert[ii].convert_output), t_jsonitem_list, a_convertparam); } break; case ConvertSheet_TextAssetPrefab.COMMAND: { //テキストアセットプレハブ。 ConvertSheet_TextAssetPrefab.Convert(t_list_convert[ii].convert_param, new File.Path(t_list_convert[ii].convert_output), t_jsonitem_list, a_convertparam); } break; case ConvertSheet_RAControllerPrefab.COMMAND: { //ランタイムアニメータコントローラプレハブ。 ConvertSheet_RAControllerPrefab.Convert(t_list_convert[ii].convert_param, new File.Path(t_list_convert[ii].convert_output), t_jsonitem_list, a_convertparam); } break; case ConvertSheet_AnimatorController.COMMAND: { //アニメータコントローラ。 ConvertSheet_AnimatorController.Convert(t_list_convert[ii].convert_param, new File.Path(t_list_convert[ii].convert_output), t_jsonitem_list, a_convertparam); } break; default: { Tool.LogError("ConvertFromJsonSheet", t_list_convert[ii].convert_command); } break; } } Fee.EditorTool.AssetTool.Refresh(); return(true); }
/** コンバート。 */ public static void Convert(string a_convert_param, Fee.File.Path a_assets_path, Fee.JsonItem.JsonItem[] a_sheet, Fee.JsonSheet.ConvertParam a_convertparam) { try{ if (a_sheet != null) { System.Collections.Generic.List <string> t_tag_list = new System.Collections.Generic.List <string>(); System.Collections.Generic.List <Fee.File.Path> t_path_list = new System.Collections.Generic.List <Fee.File.Path>(); System.Collections.Generic.List <float> t_volume_list = new System.Collections.Generic.List <float>(); for (int ii = 0; ii < a_sheet.Length; ii++) { if (a_sheet[ii] != null) { System.Collections.Generic.List <ListItem> t_sheet = Fee.JsonItem.Convert.JsonItemToObject <System.Collections.Generic.List <ListItem> >(a_sheet[ii]); if (t_sheet != null) { for (int jj = 0; jj < t_sheet.Count; jj++) { if (ConvertSheet_RAControllerPrefab.COMMAND_ITEM == t_sheet[jj].racontrollerprefab_command) { //<item> t_tag_list.Add(t_sheet[jj].racontrollerprefab_tag); t_path_list.Add(new File.Path(t_sheet[jj].racontrollerprefab_assetspath)); } else { //無関係。複合シート。 } } } else { Tool.Assert(false); } } } //保存。 { Fee.Instantiate.RuntimeAnimatorControllerList_Tool.ResourceItem[] t_resource_list = new Instantiate.RuntimeAnimatorControllerList_Tool.ResourceItem[t_tag_list.Count]; for (int ii = 0; ii < t_tag_list.Count; ii++) { t_resource_list[ii] = new Instantiate.RuntimeAnimatorControllerList_Tool.ResourceItem(t_tag_list[ii], t_path_list[ii]); } UnityEngine.GameObject t_prefab = new UnityEngine.GameObject("prefab_temp"); Fee.Instantiate.RuntimeAnimatorControllerList_Tool.Add(t_prefab, t_resource_list); Fee.EditorTool.AssetTool.SavePrefab(t_prefab, a_assets_path); UnityEngine.GameObject.DestroyImmediate(t_prefab); } } else { Tool.Assert(false); } }catch (System.Exception t_exception) { Tool.DebugReThrow(t_exception); } }
/** コンバート。 */ public static void Convert(string a_convert_param, Fee.File.Path a_assets_path, Fee.JsonItem.JsonItem[] a_sheet, Fee.JsonSheet.ConvertParam a_convertparam) { try{ if (a_sheet != null) { string t_text = ConvertSheet_Enum.TEMPLATE_MAIN; bool t_exist_namespace = false; bool t_exist_enumname = false; for (int ii = 0; ii < a_sheet.Length; ii++) { if (a_sheet[ii] != null) { System.Collections.Generic.List <ListItem> t_sheet = Fee.JsonItem.Convert.JsonItemToObject <System.Collections.Generic.List <ListItem> >(a_sheet[ii]); if (t_sheet != null) { for (int jj = 0; jj < t_sheet.Count; jj++) { if (ConvertSheet_Enum.COMMAND_NAMESPACE == t_sheet[jj].enum_command) { //<namespace> t_text = t_text.Replace(ConvertSheet_Enum.KEYWORD_NAMESPACE, t_sheet[jj].enum_name); t_exist_namespace = true; } else if (ConvertSheet_Enum.COMMAND_ENUMNAME == t_sheet[jj].enum_command) { //<enumname> t_text = t_text.Replace(ConvertSheet_Enum.KEYWORD_ENUMNAME, t_sheet[jj].enum_name); t_text = t_text.Replace(ConvertSheet_Enum.KEYWORD_ENUMCOMMENT, t_sheet[jj].enum_comment); t_exist_enumname = true; } else if (ConvertSheet_Enum.COMMAND_ITEM == t_sheet[jj].enum_command) { //<item> string t_text_item = ConvertSheet_Enum.TEMPLATE_ITEM; { t_text_item = t_text_item.Replace(ConvertSheet_Enum.KEYWORD_ITEMCOMMENT, t_sheet[jj].enum_comment); t_text_item = t_text_item.Replace(ConvertSheet_Enum.KEYWORD_ITEMNAME, t_sheet[jj].enum_name); } t_text = t_text.Replace(ConvertSheet_Enum.KEYWORD_ITEMROOT, t_text_item + ConvertSheet_Enum.KEYWORD_ITEMROOT); } else { //無関係。複合シート。 } } } else { Tool.Assert(false); } } } //<<itemroot>>の置換。 t_text = t_text.Replace(ConvertSheet_Enum.KEYWORD_ITEMROOT, ""); //ネームスペースの指定がない。 if (t_exist_namespace == false) { Tool.Assert(false); t_text = t_text.Replace(ConvertSheet_Enum.KEYWORD_NAMESPACE, "NameSpace"); } //ENUM名の指定がない。 if (t_exist_enumname == false) { Tool.Assert(false); t_text = t_text.Replace(ConvertSheet_Enum.KEYWORD_ENUMNAME, "EnumName"); t_text = t_text.Replace(ConvertSheet_Enum.KEYWORD_ENUMCOMMENT, "NoComment"); } Fee.EditorTool.AssetTool.WriteTextFile(a_assets_path, t_text); } else { Tool.Assert(false); } }catch (System.Exception t_exception) { Tool.DebugReThrow(t_exception); } }
/** コンバート。 */ public static void Convert(string a_convert_param, Fee.File.Path a_assets_path, Fee.JsonItem.JsonItem[] a_sheet, Fee.JsonSheet.ConvertParam a_convertparam) { try{ Fee.JsonItem.JsonItem t_jsonitem = new Fee.JsonItem.JsonItem(new Fee.JsonItem.Value_IndexArray()); if (a_sheet != null) { for (int ii = 0; ii < a_sheet.Length; ii++) { if (a_sheet[ii] != null) { int jj_max = a_sheet[ii].GetListMax(); for (int jj = 0; jj < jj_max; jj++) { Fee.JsonItem.JsonItem t_list_item = a_sheet[ii].GetItem(jj); if (t_list_item != null) { t_jsonitem.AddItem(t_list_item, false); } else { Tool.Assert(false); } } } } } else { Tool.Assert(false); } Fee.EditorTool.AssetTool.WriteTextFile(a_assets_path, t_jsonitem.ConvertToJsonString()); }catch (System.Exception t_exception) { Tool.DebugReThrow(t_exception); } }
/** コンバート。アセットバンドル作成。 * * a_param : パラメータ。 * a_assets_path : アセットフォルダからの相対パス。 * a_sheet : JSONシート。 * */ private static void Convert_CreateAssetBundle(string a_param, Fee.File.Path a_assets_path, Fee.JsonItem.JsonItem[] a_sheet, Fee.JsonSheet.ConvertParam a_convertparam) { try{ if (a_sheet != null) { //アセットバンドルリスト作成 /* * { * "se.assetbundle" : { * { * "SE" : * "Editor/Test12/se" * }, * { * "UI_BUTTON" : * "Common/Texture/ui_button" * }, * { * "IMAGE" : * "Common/Texture/image.jpg" * }, * * ... * }, * "xx.assetbundle" : { * * }, * ... * } */ System.Collections.Generic.Dictionary <string, System.Collections.Generic.Dictionary <string, ListItem> > t_assetbundlelist = new System.Collections.Generic.Dictionary <string, System.Collections.Generic.Dictionary <string, ListItem> >(); { for (int ii = 0; ii < a_sheet.Length; ii++) { if (a_sheet[ii] != null) { System.Collections.Generic.List <ListItem> t_sheet = Fee.JsonItem.Convert.JsonItemToObject <System.Collections.Generic.List <ListItem> >(a_sheet[ii]); if (t_sheet != null) { for (int jj = 0; jj < t_sheet.Count; jj++) { if (string.IsNullOrEmpty(t_sheet[jj].data_assetbundle_name) == false) { switch (t_sheet[jj].data_command) { case ConvertSheet_Data.COMMAND_RESOURCES_PREFAB: case ConvertSheet_Data.COMMAND_RESOURCES_TEXTURE: case ConvertSheet_Data.COMMAND_RESOURCES_TEXT: { System.Collections.Generic.Dictionary <string, ListItem> t_item_list = null; if (t_assetbundlelist.TryGetValue(t_sheet[jj].data_assetbundle_name, out t_item_list) == false) { t_item_list = new System.Collections.Generic.Dictionary <string, ListItem>(); t_assetbundlelist.Add(t_sheet[jj].data_assetbundle_name, t_item_list); } t_item_list.Add(t_sheet[jj].data_id, t_sheet[jj]); } break; default: { Tool.Assert(false); } break; } } else { //アセットバンドルなし。 } } } else { Tool.Assert(false); } } } } switch (a_param) { case ConvertSheet_Data.PARAM_DUMMY: { //ダミー。 if (a_convertparam.create_dummy_assetbundle == false) { break; } foreach (System.Collections.Generic.KeyValuePair <string, System.Collections.Generic.Dictionary <string, ListItem> > t_pair in t_assetbundlelist) { Fee.AssetBundleList.DummryAssetBundle t_dummy_assetbundle = new AssetBundleList.DummryAssetBundle(); //asset_list t_dummy_assetbundle.asset_list = new System.Collections.Generic.Dictionary <string, string>(); //key_list System.Collections.Generic.List <string> t_key_list = new System.Collections.Generic.List <string>(t_pair.Value.Keys); for (int ii = 0; ii < t_key_list.Count; ii++) { //asset_name string t_asset_name = t_key_list[ii]; ListItem t_listitem; if (t_pair.Value.TryGetValue(t_asset_name, out t_listitem) == true) { t_dummy_assetbundle.asset_list.Add(t_asset_name, t_listitem.data_path); } else { Tool.Assert(false); } } //ディレクトリ。作成。 Fee.EditorTool.AssetTool.CreateDirectory(a_assets_path); //JSON。作成。 Fee.File.Path t_path = new File.Path(a_assets_path.GetPath() + t_pair.Key + ".json"); string t_jsonstring = Fee.JsonItem.Convert.ObjectToJsonString <Fee.AssetBundleList.DummryAssetBundle>(t_dummy_assetbundle); Fee.EditorTool.AssetTool.WriteTextFile(t_path, t_jsonstring); } } break; case ConvertSheet_Data.PARAM_STANDALONEWINDOWS: case ConvertSheet_Data.PARAM_ANDROID: case ConvertSheet_Data.PARAM_WEBGL: case ConvertSheet_Data.PARAM_IOS: { //アセットバンドル。 if (a_convertparam.create_assetbundle == false) { break; } //t_assetbundle_build UnityEditor.AssetBundleBuild[] t_assetbundle_build = new UnityEditor.AssetBundleBuild[t_assetbundlelist.Count]; { int t_count = 0; foreach (System.Collections.Generic.KeyValuePair <string, System.Collections.Generic.Dictionary <string, ListItem> > t_pair in t_assetbundlelist) { //パック名。 t_assetbundle_build[t_count].assetBundleName = t_pair.Key; //assetBundleVariant t_assetbundle_build[t_count].assetBundleVariant = null; //key_list System.Collections.Generic.List <string> t_key_list = new System.Collections.Generic.List <string>(t_pair.Value.Keys); t_assetbundle_build[t_count].assetNames = new string[t_key_list.Count]; #if (UNITY_5) //未対応。 #else t_assetbundle_build[t_count].addressableNames = new string[t_key_list.Count]; #endif for (int ii = 0; ii < t_key_list.Count; ii++) { ListItem t_listitem; if (t_pair.Value.TryGetValue(t_key_list[ii], out t_listitem) == true) { string t_asset_path = null; { try{ UnityEngine.Object t_object = UnityEngine.Resources.Load(t_listitem.data_path); if (t_object != null) { t_asset_path = UnityEditor.AssetDatabase.GetAssetPath(t_object); } else { Tool.Assert(false); } }catch (System.Exception t_exception) { Tool.DebugReThrow(t_exception); } } //assetNames t_assetbundle_build[t_count].assetNames[ii] = t_asset_path; //addressableNames #if (UNITY_5) //未対応。 #else t_assetbundle_build[t_count].addressableNames[ii] = t_key_list[ii]; #endif } else { Tool.Assert(false); } } t_count++; } } //BuildAssetBundleOptions UnityEditor.BuildAssetBundleOptions t_option = UnityEditor.BuildAssetBundleOptions.ForceRebuildAssetBundle; //BuildTarget UnityEditor.BuildTarget t_buildtarget = UnityEditor.BuildTarget.StandaloneWindows; switch (a_param) { case ConvertSheet_Data.PARAM_STANDALONEWINDOWS: { t_buildtarget = UnityEditor.BuildTarget.StandaloneWindows; } break; case ConvertSheet_Data.PARAM_ANDROID: { t_buildtarget = UnityEditor.BuildTarget.Android; } break; case ConvertSheet_Data.PARAM_WEBGL: { t_buildtarget = UnityEditor.BuildTarget.WebGL; } break; case ConvertSheet_Data.PARAM_IOS: { t_buildtarget = UnityEditor.BuildTarget.iOS; } break; default: { Tool.Assert(false); } break; } //ディレクトリ。作成。 Fee.EditorTool.AssetTool.CreateDirectory(a_assets_path); //アセットバンドル作成。 Fee.EditorTool.AssetTool.BuildAssetBundles(a_assets_path, t_assetbundle_build, t_option, t_buildtarget); } break; default: { Tool.Assert(false); } break; } } else { Tool.Assert(false); } }catch (System.Exception t_exception) { Tool.DebugReThrow(t_exception); } }
/** コンバート。 */ public static void Convert(string a_convert_param, Fee.File.Path a_assets_path, Fee.JsonItem.JsonItem[] a_sheet, Fee.JsonSheet.ConvertParam a_convertparam) { try{ if (a_sheet != null) { if ((a_convert_param == ConvertSheet_Data.PARAM_DEBUG) || (a_convert_param == ConvertSheet_Data.PARAM_RELEASE)) { ConvertSheet_Data.Convert_WriteJson(a_convert_param, a_assets_path, a_sheet); } else { ConvertSheet_Data.Convert_CreateAssetBundle(a_convert_param, a_assets_path, a_sheet, a_convertparam); } } else { Tool.Assert(false); } }catch (System.Exception t_exception) { Tool.DebugReThrow(t_exception); } }
/** コンバート。 */ public static void Convert(string a_convert_param, Fee.File.Path a_assets_path, Fee.JsonItem.JsonItem[] a_sheet, Fee.JsonSheet.ConvertParam a_convertparam) { try{ if (a_sheet != null) { System.Collections.Generic.List <string> t_state_list = new System.Collections.Generic.List <string>(); System.Collections.Generic.List <Fee.File.Path> t_path_list = new System.Collections.Generic.List <Fee.File.Path>(); for (int ii = 0; ii < a_sheet.Length; ii++) { if (a_sheet[ii] != null) { System.Collections.Generic.List <ListItem> t_sheet = Fee.JsonItem.Convert.JsonItemToObject <System.Collections.Generic.List <ListItem> >(a_sheet[ii]); if (t_sheet != null) { for (int jj = 0; jj < t_sheet.Count; jj++) { if (ConvertSheet_AnimatorController.COMMAND_ITEM == t_sheet[jj].animatorcontroller_command) { //<item> t_state_list.Add(t_sheet[jj].animatorcontroller_state); t_path_list.Add(new File.Path(t_sheet[jj].animatorcontroller_assetspath)); } else { //無関係。複合シート。 } } } else { Tool.Assert(false); } } } //保存。 { UnityEditor.Animations.AnimatorController t_controller = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath("Assets/" + a_assets_path.GetPath()); for (int ii = 0; ii < t_state_list.Count; ii++) { UnityEditor.Animations.AnimatorState t_state = t_controller.layers[0].stateMachine.AddState(t_state_list[ii]); t_state.motion = Fee.EditorTool.AssetTool.LoadAsset <UnityEngine.AnimationClip>(t_path_list[ii]); } UnityEditor.AssetDatabase.SaveAssets(); } } else { Tool.Assert(false); } }catch (System.Exception t_exception) { Tool.DebugReThrow(t_exception); } }