private UIInfo LoadCsvAndCreateUIInfo()
        {
            var spriteFolderPath = PreferHelper.defultSpriteFolder;

            if (string.IsNullOrEmpty(spriteFolderPath))
            {
                DialogHelper.ShowDialog("错误提示", "图片加载路径不能为空", "确认");
            }
            else
            {
                var      configPath = GetConfigFilePath();
                CsvTable table      = null;
pos_readdoc:
                if (File.Exists(configPath))
                {
                    try
                    {
                        table = CsvHelper.ReadCSV(configPath, System.Text.Encoding.GetEncoding("GB2312"));
                    }
                    catch (Exception e)
                    {
                        var reopen = DialogHelper.ShowDialog("提示", 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 = DialogHelper.ShowDialog("文档标题不匹配", string.Join(",", UIInfo_TableExtend.uiInfoHead) + "\n继续请按确认!", "确认", "取消");
                                if (!forceLoad)
                                {
                                    return(null);
                                }
                            }

                            return(table.LoadUIInfo());
                        }
                        else
                        {
                            DialogHelper.ShowDialog("配制文档不可用", "请核对后重试!", "确认");
                        }
                    }
                }
            }
            return(null);
        }
示例#2
0
    public void TableToUIInfoTest()
    {
        var configPath = EditorUtility.OpenFilePanel("选择配制规则文件(csv)", PreferHelper.configFolderPath, "csv");

        table = CsvHelper.ReadCSV(configPath, encoding);

        if (table.IsUIInfoTable(true))
        {
            var uiInfo = table.LoadUIInfo();
            Debug.Log(uiInfo.name);
        }
        else
        {
            EditorUtility.DisplayDialog("错误提示", "表为或标题不匹配", "ok");
        }
    }