private static void GenerateUI(string configPath, string spriteFolderPath, Canvas canvas)
        {
            CsvTable table = null;

            pos_readdoc : if (File.Exists(configPath))
            {
                try
                {
                    table = CsvHelper.ReadCSV(configPath, System.Text.Encoding.GetEncoding("GB2312"));
                }
                catch (Exception e)
                {
                    var reopen = EditorUtility.DisplayDialog("提示", e.Message, "重试", "取消");
                    if (reopen)
                    {
                        goto pos_readdoc;
                    }
                }

                if (table != null)
                {
                    var canLoad = table.IsUIInfoTable(false);
                    if (canLoad)
                    {
                        var isTitleMatch = table.IsUIInfoTable(true);
                        if (!isTitleMatch)
                        {
                            var forceLoad = Notice("文档标题不匹配:" + string.Join(",", UIInfo_TableExtend.uiInfoHead) + "\n继续请按确认!", true);
                            if (!forceLoad)
                            {
                                return;
                            }
                        }

                        var uiInfo = table.LoadUIInfo();
                        if (uiInfo != null)
                        {
                            if (emptyImporter != null)
                            {
                                Assembler.emptyImporter = emptyImporter;
                            }
                            Assembler.GenerateUI(spriteFolderPath, canvas, layerImportTypes, uiInfo);
                        }
                    }
                    else
                    {
                        Notice("配制文档不可用,请核对后重试!");
                    }
                }
            }
        }
Пример #2
0
        public static UIInfo LoadUIInfo(this CsvTable table)
        {
            if (table.IsUIInfoTable(false))
            {
                var uiInfo = new UIInfo(table.name);

                if (table.Rows != null && table.Columns != null)
                {
                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        var layerInfo = new LayerInfo();
                        layerInfo.name = table[0, i];
                        layerInfo.path = table[1, i];
                        layerInfo.type = table[2, i];
                        layerInfo.rect = ParamAnalysisTool.StringToRect(table[3, i]);
                        var resourceDic = ParamAnalysisTool.ToDictionary(table[4, i]);
                        if (resourceDic != null)
                        {
                            ChargeDic(layerInfo.resourceDic, resourceDic);
                        }


                        if (table.Columns.Count > 5)
                        {
                            List <ResourceDic> sub_images;
                            List <ResourceDic> sub_texts;
                            List <ResourceDic> sub_rawImages;
                            var subResourceDic = ParamAnalysisTool.ToDictionary_Sub(table[5, i], out sub_images, out sub_texts, out sub_rawImages);
                            if (subResourceDic != null)
                            {
                                ChargeDic(layerInfo.subResourceDic, subResourceDic);
                            }
                            ChargeList(layerInfo.sub_images, sub_images);
                            ChargeList(layerInfo.sub_texts, sub_texts);
                            ChargeList(layerInfo.sub_rawImages, sub_rawImages);
                        }

                        uiInfo.layers.Add(layerInfo);
                    }
                }

                return(uiInfo);
            }
            return(null);
        }