Exemplo n.º 1
0
        private void ExportDatablocks(Type datablockType, string saveLocation)
        {
            IEnumerable <Datablock> baseDatablocks = DatablockManager.Instance.GetDatablocks(datablockType).Where(d => d.Parent == null);

            datablockFields = Datablock.GetFields(datablockType);

            var sb = new StringBuilder();
            var sw = new StringWriter(sb);

            writer = new JsonTextWriter(sw);

            writer.WriteStartArray();

            // Process the datablocks from the base to their children
            foreach (var baseDatablock in baseDatablocks)
            {
                ProcessChildren(baseDatablock);
            }

            writer.WriteEndArray();

            File.WriteAllText(saveLocation, sb.ToString());

            Debug.Log("Datablocks exported to " + saveLocation);

            writer.Close();
        }
Exemplo n.º 2
0
        private void ExportDatablocks(Type datablockType, string saveLocation)
        {
            outputStringBuilder = new StringBuilder();
            var headers = new List <string>()
            {
                "Name", "Parent"
            };

            IEnumerable <Datablock> baseDatablocks = DatablockManager.Instance.GetDatablocks(datablockType).Where(d => d.Parent == null);

            datablockFields = Datablock.GetFields(datablockType);

            foreach (FieldInfo memberInfo in datablockFields)
            {
                headers.Add(memberInfo.Name);
            }


            // Add the headers
            outputStringBuilder.Append(String.Join(fieldDelimiter, headers.ToArray()) + "\r\n");

            // Process the datablocks from the base to their children
            foreach (var baseDatablock in baseDatablocks)
            {
                ProcessChildren(baseDatablock);
            }


            // Write the file
            File.WriteAllText(saveLocation, outputStringBuilder.ToString());

            Debug.Log("Datablocks exported to " + saveLocation);
        }
Exemplo n.º 3
0
        public virtual void OnEnable()
        {
            datablock = (Datablock)target;

            renameAssetTempName = datablock.name;

            members = Datablock.GetFields(datablock.GetType());
            DatablockManager.EnsureInitilized();
        }
        private void ExportDatablocks(Type datablockType)
        {
            var worksheet = (WorksheetEntry)spreadsheet.Worksheets.Entries[0];
            IEnumerable <Datablock> datablocks = DatablockManager.Instance.GetDatablocks(datablockType);

            datablockFields = Datablock.GetFields(datablockType);
            List <string> headers = datablockFields.Select(f => f.Name).ToList();

            headers.Insert(0, "Parent");
            headers.Insert(0, "Name");

            // Set the worksheet to a single row for our headers
            worksheet.Cols = (uint)headers.Count;
            worksheet.Rows = (exportData ? (uint)datablocks.Count() : 0) + 1;
            worksheet.Update();

            if (exportData)
            {
                // Fetch the cell feed of the worksheet.
                var cellQuery = new CellQuery(worksheet.CellFeedLink);
                cellQuery.ReturnEmpty = ReturnEmptyCells.yes;
                cellFeed = sheetsAPI.Service.Query(cellQuery);

                batchRequest = new CellFeed(cellQuery.Uri, sheetsAPI.Service);

                currentCellIndex = 0;
                // Set headers
                for (int index = 0; index < headers.Count; index++)
                {
                    string cellValue = headers[index];

                    SetNextCellValue(cellValue);
                }

                currentCellIndex = headers.Count;

                IEnumerable <Datablock> baseDatablocks = datablocks.Where(d => d.Parent == null);

                // Process the datablocks from the base to their children
                foreach (Datablock baseDatablock in baseDatablocks)
                {
                    ProcessChildren(baseDatablock);
                }

                sheetsAPI.Service.Batch(batchRequest, new Uri(cellFeed.Batch));
            }

            Debug.Log("Datablocks saved to " + spreadsheet.Title.Text);
        }