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); }
public static CsvTable UIInfoToTable(this UIInfo info) { var table = new CsvTable(info.name); table.Columns = new List <string>(uiInfoHead); for (int i = 0; i < info.layers.Count; i++) { var layer = info.layers[i]; var raw = new string[table.Columns.Count]; raw[0] = layer.name; raw[1] = layer.path; raw[2] = layer.type; raw[3] = ParamAnalysisTool.RectToString(layer.rect); raw[4] = ParamAnalysisTool.FromDictionary(layer.resourceDic); raw[5] = ParamAnalysisTool.FromDictionarySub(layer.subResourceDic, layer.sub_images, layer.sub_texts, layer.sub_rawImages); table.Rows.Add(raw); } return(table); }
public static GameObject GenerateUI(string spriteFolderPath, Canvas canvas, Dictionary <string, Type> layerImportTypes, UIInfo uiInfo) { if (layerImportTypes == null) { return(null); } mechine = new AssemblerStateMechine(); mechine.spriteFolderPath = spriteFolderPath; mechine.uiSize = PreferHelper.uiSize; mechine.canvas = canvas; mechine.fontFolderPath = PreferHelper.fontFolderPath; mechine.textureFolderPath = PreferHelper.textureFolderPath; mechine.materialFolderPath = PreferHelper.materialFolderPath; mechine.RegistEmptyImprot(Activator.CreateInstance(emptyImporter) as ILayerImport); using (var enumerator = layerImportTypes.GetEnumerator()) { while (enumerator.MoveNext()) { var current = enumerator.Current; if (typeof(ILayerImport).IsAssignableFrom(current.Value)) { var instence = Activator.CreateInstance(current.Value) as ILayerImport; if (instence != null) { mechine.RegistLayerimport(current.Key, instence); } } } } if (mechine.canvas != null) { Screen.SetResolution(PreferHelper.uiSize.x, PreferHelper.uiSize.y, false); #if UNITY_EDITOR var ok = CheckGameViewSize(PreferHelper.uiSize); if (!ok) { var @continue = UnityEditor.EditorUtility.DisplayDialog("屏幕比例和配制不一致:" + PreferHelper.uiSize.ToString(), "继续生成会造成坐标不正确", "继续", "取消"); if (!@continue) { return(null); } } #endif return(mechine.GenerateUI(uiInfo)); } return(null); }