Beispiel #1
0
        /** コンバート
         */
        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);
        }
Beispiel #2
0
        /** コンバート
         */
        public static bool ConvertFromJsonSheet(Fee.JsonItem.JsonItem a_jsonitem)
        {
            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 <ConvertSheet_ListItem> t_list_convert = Fee.JsonItem.Convert.JsonItemToObject <System.Collections.Generic.List <ConvertSheet_ListItem> >(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 Convert_JsonSheet.COMMAND:
                {
                    //JSONシート。
                    Convert_JsonSheet.Convert(t_list_convert[ii].convert_param, new Fee.File.Path(t_list_convert[ii].convert_output), t_jsonitem_list);
                } break;

                case Convert_EnumSheet.COMMAND:
                {
                    //ENUMシート。
                    Convert_EnumSheet.Convert(t_list_convert[ii].convert_param, new Fee.File.Path(t_list_convert[ii].convert_output), t_jsonitem_list);
                } break;

                case Convert_AudioSheet.COMMAND:
                {
                    //オーディオシート。
                    Convert_AudioSheet.Convert(t_list_convert[ii].convert_param, new Fee.File.Path(t_list_convert[ii].convert_output), t_jsonitem_list);
                } break;

                case Convert_DataSheet.COMMAND:
                {
                    //データシート。
                    Convert_DataSheet.Convert(t_list_convert[ii].convert_param, new Fee.File.Path(t_list_convert[ii].convert_output), t_jsonitem_list);
                } break;

                case Convert_TextureSheet.COMMAND:
                {
                    //テクスチャーシート。
                    Convert_TextureSheet.Convert(t_list_convert[ii].convert_param, new File.Path(t_list_convert[ii].convert_output), t_jsonitem_list);
                } break;

                case Convert_FontSheet.COMMAND:
                {
                    //フォントシート。
                    Convert_FontSheet.Convert(t_list_convert[ii].convert_param, new File.Path(t_list_convert[ii].convert_output), t_jsonitem_list);
                } break;

                case Convert_TextAssetSheet.COMMAND:
                {
                    //テキストアセットシート。
                    Convert_TextAssetSheet.Convert(t_list_convert[ii].convert_param, new File.Path(t_list_convert[ii].convert_output), t_jsonitem_list);
                } break;

                case Convert_Videoheet.COMMAND:
                {
                    //ムービーシート。
                    Convert_Videoheet.Convert(t_list_convert[ii].convert_param, new File.Path(t_list_convert[ii].convert_output), t_jsonitem_list);
                } break;

                case Convert_PrefabSheet.COMMAND:
                {
                    //プレハブシート。
                    Convert_PrefabSheet.Convert(t_list_convert[ii].convert_param, new File.Path(t_list_convert[ii].convert_output), t_jsonitem_list);
                } break;

                default:
                {
                    Tool.Assert(false);
                } break;
                }
            }

            return(true);
        }
Beispiel #3
0
        /** Convert
         */
        public static void Convert(ref System.Object a_to_ref_object, System.Type a_to_type, JsonItem a_from_jsonitem, JsonItemToObject_WorkPool a_workpool)
        {
            try{
                //IList
                {
                    System.Collections.IList t_to_list = a_to_ref_object as System.Collections.IList;
                    if (t_to_list != null)
                    {
                        //値型。取得。
                        System.Type t_list_value_type = Fee.ReflectionTool.Utility.GetListValueType(a_to_type);

                        if (t_to_list.IsFixedSize == true)
                        {
                            //[]

                            //ワークに追加。
                            for (int ii = a_from_jsonitem.GetListMax() - 1; ii >= 0; ii--)
                            {
                                JsonItem t_jsonitem_listitem = a_from_jsonitem.GetItem(ii);
                                a_workpool.AddFirst(JsonItemToObject_WorkPool.ModeSetList.Start, t_jsonitem_listitem, t_to_list, ii, t_list_value_type);
                            }
                        }
                        else
                        {
                            //Generic.List

                            //ワークに追加。
                            for (int ii = a_from_jsonitem.GetListMax() - 1; ii >= 0; ii--)
                            {
                                JsonItem t_jsonitem_listitem = a_from_jsonitem.GetItem(ii);
                                a_workpool.AddFirst(JsonItemToObject_WorkPool.ModeAddList.Start, t_jsonitem_listitem, t_to_list, t_list_value_type);
                            }
                        }

                        //成功。
                        return;
                    }
                }

                //IEnumerable
                {
                    System.Collections.IEnumerable t_to_enumerable = a_to_ref_object as System.Collections.IEnumerable;
                    if (t_to_enumerable != null)
                    {
                        System.Type t_generic_type = Fee.ReflectionTool.Utility.GetGenericTypeDefinition(a_to_type);

                        //値型。取得。
                        System.Type t_list_value_type = Fee.ReflectionTool.Utility.GetListValueType(a_to_type);

                        //メソッド取得。
                        System.Reflection.MethodInfo t_methodinfo = null;
                        if (t_generic_type == typeof(System.Collections.Generic.Stack <>))
                        {
                            //Generic.Stack

                            t_methodinfo = ConvertTool.GetMethod_Stack_Push(a_to_type, t_list_value_type);

                            if (t_methodinfo != null)
                            {
                                //ワークに追加。
                                for (int ii = 0; ii < a_from_jsonitem.GetListMax(); ii++)
                                {
                                    JsonItem t_jsonitem_listitem = a_from_jsonitem.GetItem(ii);
                                    a_workpool.AddFirst(JsonItemToObject_WorkPool.ModeIEnumerable.Start_Param1, t_jsonitem_listitem, t_to_enumerable, t_methodinfo, t_list_value_type);
                                }

                                //成功。
                                return;
                            }
                        }
                        else if (t_generic_type == typeof(System.Collections.Generic.LinkedList <>))
                        {
                            //Generic.LinkedList
                            t_methodinfo = ConvertTool.GetMethod_LinkedList_AddLast(a_to_type, t_list_value_type);
                        }
                        else if (t_generic_type == typeof(System.Collections.Generic.HashSet <>))
                        {
                            //Generic.HashSet
                            t_methodinfo = ConvertTool.GetMethod_HashSet_Add(a_to_type, t_list_value_type);
                        }
                        else if (t_generic_type == typeof(System.Collections.Generic.Queue <>))
                        {
                            //Generic.Queue
                            t_methodinfo = ConvertTool.GetMethod_Queue_Enqueue(a_to_type, t_list_value_type);
                        }
                        else if (t_generic_type == typeof(System.Collections.Generic.SortedSet <>))
                        {
                            //Generic.SortedSet
                            t_methodinfo = ConvertTool.GetMethod_SortedSet_Add(a_to_type, t_list_value_type);
                        }

                        if (t_methodinfo != null)
                        {
                            //ワークに追加。
                            for (int ii = a_from_jsonitem.GetListMax() - 1; ii >= 0; ii--)
                            {
                                JsonItem t_jsonitem_listitem = a_from_jsonitem.GetItem(ii);
                                a_workpool.AddFirst(JsonItemToObject_WorkPool.ModeIEnumerable.Start_Param1, t_jsonitem_listitem, t_to_enumerable, t_methodinfo, t_list_value_type);
                            }

                            //成功。
                            return;
                        }
                    }
                }

                //IDictionary
                {
                    System.Collections.IDictionary t_to_dictionary = a_to_ref_object as System.Collections.IDictionary;
                    if (t_to_dictionary != null)
                    {
                        //キー型。
                        System.Type t_list_key_type = Fee.ReflectionTool.Utility.GetDictionaryKeyType(a_to_type);

                        //値型。
                        System.Type t_list_value_type = Fee.ReflectionTool.Utility.GetListValueType(a_to_type);

                        //ワークに追加。
                        for (int ii = 0; ii < a_from_jsonitem.GetListMax(); ii++)
                        {
                            Fee.JsonItem.JsonItem t_listitem_jsonitem = a_from_jsonitem.GetItem(ii);

                            Fee.JsonItem.JsonItem t_key_jsonitem   = null;
                            Fee.JsonItem.JsonItem t_value_jsonitem = null;

                            if (t_listitem_jsonitem.IsAssociativeArray() == true)
                            {
                                if (t_listitem_jsonitem.IsExistItem("KEY"))
                                {
                                    t_key_jsonitem = t_listitem_jsonitem.GetItem("KEY");
                                }
                                if (t_listitem_jsonitem.IsExistItem("VALUE"))
                                {
                                    t_value_jsonitem = t_listitem_jsonitem.GetItem("VALUE");
                                }
                            }

                            a_workpool.AddFirst(JsonItemToObject_WorkPool.ModeAddAnyDictionary.Start, t_key_jsonitem, t_value_jsonitem, t_to_dictionary, t_list_key_type, t_list_value_type);
                        }

                        //成功。
                        return;
                    }
                }
            }catch (System.Exception t_exception) {
                Tool.DebugReThrow(t_exception);
            }

            //失敗。
            Tool.Assert(false);
        }