Пример #1
0
        public void GenData(IDataReadable reader, string outputPath = null)
        {
            IDataReadable exReader = reader;

            List <Dictionary <string, string> > rows = exReader.GetRows();

            JsonData data        = new JsonData();
            string   arrayString = JsonMapper.ToJson(rows);

            Debug.Log(arrayString);

            JsonData jsonArray = JsonMapper.ToObject(arrayString);

            data[reader.currentDataTypeName] = jsonArray;


            if (outputPath == null)
            {
                outputPath = PathConfig.GetLocalGameDataPath(PathConfig.DataType.Json)
                             + Path.GetFileNameWithoutExtension(reader.currentDataTypeName) + Data.GameDatas.Json.JsonData.m_fileExtention;
            }
            if (!Directory.Exists(Path.GetDirectoryName(outputPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
            }

            data.Save(outputPath);

            AssetDatabase.Refresh();
        }
Пример #2
0
        public void GenData(IDataReadable reader, string outputPath = null)
        {
            IDataReadable exReader = reader;

            XDocument xDoc = new XDocument();
            XElement  root = new XElement("Root");

            xDoc.Add(root);

            List <Dictionary <string, string> > rows = exReader.GetRows();

            for (int i = 0; i < rows.Count; i++)
            {
                XElement item = new XElement("item");
                root.Add(item);
                foreach (KeyValuePair <string, string> pair in rows[i])
                {
                    item.Add(new XElement(pair.Key, pair.Value));
                }
            }

            if (outputPath == null)
            {
                outputPath = PathConfig.GetLocalGameDataPath(PathConfig.DataType.Xml)
                             + Path.GetFileNameWithoutExtension(reader.currentDataTypeName) + XmlData.m_fileExtention;
            }
            if (!Directory.Exists(Path.GetDirectoryName(outputPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
            }

            xDoc.Save(outputPath);
            AssetDatabase.Refresh();
        }
Пример #3
0
        public void GenData(IDataReadable reader, string outputPath = null)
        {
            IDataReadable exReader = reader;

            List <Dictionary <string, string> > rows = exReader.GetRows();

            foreach (var dict in rows)
            {
                var keyList = new List <string>(dict.Keys);
                foreach (var key in keyList)
                {
                    dict[key] = DataUtil.HandleExportXmlValue(dict[key], reader.attributeDict[key]);
                }
            }


            JsonData data        = new JsonData();
            string   arrayString = JsonMapper.ToJson(rows);

            Debug.Log(arrayString);

            JsonData jsonArray = JsonMapper.ToObject(arrayString);

            data[reader.currentDataTypeName] = jsonArray;


            if (outputPath == null)
            {
                outputPath = PathConfig.GetLocalGameDataPath(PathConfig.DataType.Json)
                             + Path.GetFileNameWithoutExtension(reader.currentDataTypeName) + Data.GameDatas.Json.JsonData.m_fileExtention;
            }
            if (!Directory.Exists(Path.GetDirectoryName(outputPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
            }

            data.Save(outputPath);

            AssetDatabase.Refresh();
            var ai = AssetImporter.GetAtPath(PathEx.ConvertAbstractToAssetPath(outputPath));

            ai.assetBundleName = PathConfig.DataBundleName;
            AssetDatabase.Refresh();
        }
Пример #4
0
        public void GenData(IDataReadable reader, string outputPath = null)
        {
            IDataReadable exReader = reader;

            XDocument xDoc = new XDocument();
            XElement  root = new XElement("Root");

            xDoc.Add(root);

            List <Dictionary <string, string> > rows = exReader.GetRows();

            for (int i = 0; i < rows.Count; i++)
            {
                XElement item = new XElement("item");
                root.Add(item);
                foreach (KeyValuePair <string, string> pair in rows[i])
                {
                    var finalStr = DataUtil.HandleExportXmlValue(pair.Value, reader.attributeDict[pair.Key]);
                    item.Add(new XElement(pair.Key, finalStr));
                }
            }

            if (outputPath == null)
            {
                outputPath = PathConfig.GetLocalGameDataPath(PathConfig.DataType.Xml)
                             + Path.GetFileNameWithoutExtension(reader.currentDataTypeName) + XmlData.m_fileExtention;
            }
            if (!Directory.Exists(Path.GetDirectoryName(outputPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
            }

            //xDoc.Save(outputPath);
            File.WriteAllText(outputPath, xDoc.ToString());
            AssetDatabase.Refresh();
            var ai = AssetImporter.GetAtPath(PathEx.ConvertAbstractToAssetPath(outputPath));

            ai.assetBundleName = PathConfig.DataBundleName;
            AssetDatabase.Refresh();
        }