コード例 #1
0
ファイル: TableEditor.cs プロジェクト: hs2610366/Unit3d_Test
 /// <summary>
 /// 更新配置数据
 /// </summary>
 private void UpdateTableInfo(int index)
 {
     if (SheetsName == null || SheetsName.Count == 0)
     {
         return;
     }
     if (Workbook == null)
     {
         return;
     }
     SelectSheetName = SheetsName[index];
     ParamNames      = ExcelMgr.GetSheetTitle(Workbook, SelectSheetName);
     if (ConfigDic.ContainsKey(SelectKey))
     {
         if (!ConfigDic[SelectKey].Dic.ContainsKey(SelectSheetName))
         {
             TableInfo table = new TableInfo();
             table.Sheet = SelectSheetName;
             table.UpdateParams(ParamNames);
             ConfigDic[SelectKey].Dic.Add(SelectSheetName, table);
         }
     }
 }
コード例 #2
0
ファイル: InfoTool.cs プロジェクト: hs2610366/Unit3d_Test
        private static void Generating(string path, IWorkbook iwb, TableInfo ti)
        {
            ISheet sheet = iwb.GetSheet(ti.Sheet);

            if (sheet == null)
            {
                return;
            }
            List <string> names = ExcelMgr.GetSheetTitle(iwb, ti.Sheet);

            if (names == null || names.Count == 0)
            {
                return;
            }
            int len = sheet.LastRowNum;

            if (len < 1)
            {
                MessageBox.Error(string.Format("{0}没有数据!!", path));
                return;
            }
            List <object> outputList = new List <object>();

            for (int i = 1; i <= len; i++)
            {
                IRow row = sheet.GetRow(i);
                if (row == null)
                {
                    continue;
                }
                Dictionary <string, ParamInfo> param = ti.Params;
                if (param == null)
                {
                    continue;
                }
                object obj = InstantiationScript(ti.ScriptPath);
                if (obj == null)
                {
                    continue;
                }
                Type t = obj.GetType();
                foreach (KeyValuePair <string, ParamInfo> pd in param)
                {
                    if (!pd.Value.IsOutput)
                    {
                        continue;
                    }
                    if (pd.Value.Index == 0)
                    {
                        continue;
                    }
                    string proName = ti.PropertyNames[pd.Value.Index];
                    Type   proType = ti.PropertyDic[proName];
                    if (proType == null)
                    {
                        continue;
                    }
                    string       value = row.GetCell(pd.Value.CellIndex).ToString();
                    PropertyInfo pro   = t.GetProperty(proName);
                    if (pro != null)
                    {
                        pro.SetValue(obj, TypeConversion(value, proType), null);
                    }
                }
                outputList.Add(obj);
            }
            if (outputList.Count == 0)
            {
                Debug.LogError("GetByteByDic Fail!!, dic is null");
                return;
            }
            string outputPath = string.Format("{0}{1}", PathTool.DataPath, PathTool.Temp);

            if (string.IsNullOrEmpty(outputPath))
            {
                Debug.LogError("Get Assets Path Fail!!, InfoTool.PathConfig[EditorPrefsKey.AssetsPath] is null");
                return;
            }
            Config.OutputConfig <object>(outputPath, ti.OutputName, outputList, SuffixTool.TableInfo.ToLower());
        }