export-table-pulgin-csharp 1.0.57 → 1.0.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"ExportCSPlugin.d.ts","sourceRoot":"","sources":["../src/ExportCSPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAA0B,MAAM,kBAAkB,CAAA;AAI1H,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAkTpE;AAED,qBAAa,YAAa,SAAQ,UAAU;IAC3C,IAAI,SAAW;IACf,IAAI,EAAE,MAAM,EAAE,CAAS;IAEvB,WAAW,CAAC,KAAK,EAAE,iBAAiB;CAOpC"}
1
+ {"version":3,"file":"ExportCSPlugin.d.ts","sourceRoot":"","sources":["../src/ExportCSPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAA0B,MAAM,kBAAkB,CAAA;AAM1H,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAqTpE;AAED,qBAAa,YAAa,SAAQ,UAAU;IAC3C,IAAI,SAAW;IACf,IAAI,EAAE,MAAM,EAAE,CAAS;IAEvB,WAAW,CAAC,KAAK,EAAE,iBAAiB;CAOpC"}
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.ExportPlugin = exports.export_stuff = void 0;
27
27
  const export_table_lib_1 = require("export-table-lib");
28
28
  const fs = __importStar(require("fs-extra"));
29
+ var isSkipExportDefaults = process.argv.findIndex(v => v == "--SkipDefaults") >= 0;
29
30
  function export_stuff(paras) {
30
31
  let { datas, fields, inject, name, objects, packagename, tables, xxtea, } = paras;
31
32
  let firstLetterUpper = function (str) {
@@ -189,11 +190,14 @@ using System.Collections.Generic;
189
190
  using System.Linq;
190
191
 
191
192
  namespace MEEC.ExportedConfigs{
193
+ [System.Serializable]
192
194
  public partial class ${RowClass} {
193
195
 
194
196
  public static List<${RowClass}> Configs = new List<${RowClass}>()
195
197
  {
198
+ ${(0, export_table_lib_1.iff)(!isSkipExportDefaults, () => `
196
199
  ${(0, export_table_lib_1.foreach)(datas, data => ` new ${RowClass}(${(0, export_table_lib_1.st)(() => fields.map((f, index) => genValue(data[index], f)).join(", "))}),`)}
200
+ `)}
197
201
  };
198
202
 
199
203
  public ${RowClass}() { }
@@ -1 +1 @@
1
- {"version":3,"file":"ExportUnityCSJsonPlugin.d.ts","sourceRoot":"","sources":["../src/ExportUnityCSJsonPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAAE,iBAAiB,EAAe,MAAM,kBAAkB,CAAA;AAMlI,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA6CnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA2CzE;AAED,qBAAa,iBAAkB,SAAQ,UAAU;IAChD,IAAI,SAAU;IACd,IAAI,EAAE,MAAM,EAAE,CAAY;IAE1B,WAAW,CAAC,KAAK,EAAE,iBAAiB;IAmBpC,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;CAsB3C"}
1
+ {"version":3,"file":"ExportUnityCSJsonPlugin.d.ts","sourceRoot":"","sources":["../src/ExportUnityCSJsonPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAAE,iBAAiB,EAAe,MAAM,kBAAkB,CAAA;AAMlI,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA+CnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA0CzE;AAED,qBAAa,iBAAkB,SAAQ,UAAU;IAChD,IAAI,SAAU;IACd,IAAI,EAAE,MAAM,EAAE,CAAY;IAE1B,WAAW,CAAC,KAAK,EAAE,iBAAiB;IAmBpC,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;CAsB3C"}
@@ -46,24 +46,25 @@ function exportUJson(paras) {
46
46
  });
47
47
  return newObj;
48
48
  }));
49
- // !!!必须开头没有空格
50
- let temp = `%YAML 1.1
51
- %TAG !u! tag:unity3d.com,2011:
52
- --- !u!114 &11400000
53
- MonoBehaviour:
54
- m_ObjectHideFlags: 0
55
- m_CorrespondingSourceObject: {fileID: 0}
56
- m_PrefabInstance: {fileID: 0}
57
- m_PrefabAsset: {fileID: 0}
58
- m_GameObject: {fileID: 0}
59
- m_Enabled: 1
60
- m_EditorHideFlags: 0
61
- m_Script: {fileID: 11500000, guid: 496f60086c072a8479a6e0b948efb5e8, type: 3}
62
- m_Name: ${fullName}
63
- m_EditorClassIdentifier:
64
- JsonText: ${JSON.stringify(jsonString)}
65
- `;
66
- return temp;
49
+ return jsonString;
50
+ // // !!!必须开头没有空格
51
+ // let temp = `%YAML 1.1
52
+ // %TAG !u! tag:unity3d.com,2011:
53
+ // --- !u!114 &11400000
54
+ // MonoBehaviour:
55
+ // m_ObjectHideFlags: 0
56
+ // m_CorrespondingSourceObject: {fileID: 0}
57
+ // m_PrefabInstance: {fileID: 0}
58
+ // m_PrefabAsset: {fileID: 0}
59
+ // m_GameObject: {fileID: 0}
60
+ // m_Enabled: 1
61
+ // m_EditorHideFlags: 0
62
+ // m_Script: {fileID: 11500000, guid: 496f60086c072a8479a6e0b948efb5e8, type: 3}
63
+ // m_Name: ${fullName}
64
+ // m_EditorClassIdentifier:
65
+ // JsonText: ${JSON.stringify(jsonString)}
66
+ // `
67
+ // return temp
67
68
  }
68
69
  exports.exportUJson = exportUJson;
69
70
  function exportUJsonLoader(paras) {
@@ -72,7 +73,6 @@ function exportUJsonLoader(paras) {
72
73
  var fullName = `${table.workbookName}-${name}`;
73
74
  // !!!必须开头没有空格
74
75
  let temp = `
75
- using lang.json;
76
76
  using UnityEngine.AddressableAssets;
77
77
  using System.Threading.Tasks;
78
78
  using UnityEngine;
@@ -83,11 +83,11 @@ namespace MEEC.ExportedConfigs
83
83
  {
84
84
  public static async Task Load()
85
85
  {
86
- var loadUrl="Assets/Bundles/GameConfigs/Auto/${fullName}.asset";
87
- var configJson = await Addressables.LoadAssetAsync<ExcelConfigJson>(loadUrl).Task;
86
+ var loadUrl="Assets/Bundles/GameConfigs/Auto/${fullName}.json";
87
+ var configJson = await Addressables.LoadAssetAsync<TextAsset>(loadUrl).Task;
88
88
  if (configJson != null)
89
89
  {
90
- var jsonObjs = JSON.parse<${RowClass}[]>(configJson.JsonText);
90
+ var jsonObjs = JsonUtility.FromJson<${RowClass}[]>(configJson.text);
91
91
  var configs = ${RowClass}.Configs;
92
92
  configs.Clear();
93
93
  configs.AddRange(jsonObjs);
@@ -121,7 +121,7 @@ class ExportUJsonPlugin extends export_table_lib_1.PluginBase {
121
121
  {
122
122
  let content2 = exportUJson(paras);
123
123
  if (content2 != null) {
124
- let savePath = new export_table_lib_1.OutFilePath(paras.outPath, fullName, ".asset").fullPath;
124
+ let savePath = new export_table_lib_1.OutFilePath(paras.outPath, fullName, ".json").fullPath;
125
125
  fs.outputFileSync(savePath, content2, "utf-8");
126
126
  }
127
127
  return content2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "export-table-pulgin-csharp",
3
- "version": "1.0.57",
3
+ "version": "1.0.60",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -3,6 +3,8 @@ import { cmm, HandleSheetParams, Field, foreach, IPlugin, st, PluginBase, Handle
3
3
  import * as fs from "fs-extra"
4
4
  import { json } from "stream/consumers";
5
5
 
6
+ var isSkipExportDefaults = process.argv.findIndex(v => v == "--SkipDefaults") >= 0
7
+
6
8
  export function export_stuff(paras: HandleSheetParams): string | null {
7
9
  let {
8
10
  datas,
@@ -151,13 +153,16 @@ using System.Collections.Generic;
151
153
  using System.Linq;
152
154
 
153
155
  namespace MEEC.ExportedConfigs{
156
+ [System.Serializable]
154
157
  public partial class ${RowClass} {
155
158
 
156
159
  public static List<${RowClass}> Configs = new List<${RowClass}>()
157
160
  {
161
+ ${iff(!isSkipExportDefaults, () => `
158
162
  ${foreach(datas, data =>
159
- ` new ${RowClass}(${st(() => fields.map((f, index) => genValue(data[index], f)).join(", "))}),`
160
- )}
163
+ ` new ${RowClass}(${st(() => fields.map((f, index) => genValue(data[index], f)).join(", "))}),`
164
+ )}
165
+ `)}
161
166
  };
162
167
 
163
168
  public ${RowClass}() { }
@@ -31,24 +31,26 @@ export function exportUJson(paras: HandleSheetParams): string | null {
31
31
  return newObj
32
32
  }));
33
33
 
34
- // !!!必须开头没有空格
35
- let temp = `%YAML 1.1
36
- %TAG !u! tag:unity3d.com,2011:
37
- --- !u!114 &11400000
38
- MonoBehaviour:
39
- m_ObjectHideFlags: 0
40
- m_CorrespondingSourceObject: {fileID: 0}
41
- m_PrefabInstance: {fileID: 0}
42
- m_PrefabAsset: {fileID: 0}
43
- m_GameObject: {fileID: 0}
44
- m_Enabled: 1
45
- m_EditorHideFlags: 0
46
- m_Script: {fileID: 11500000, guid: 496f60086c072a8479a6e0b948efb5e8, type: 3}
47
- m_Name: ${fullName}
48
- m_EditorClassIdentifier:
49
- JsonText: ${JSON.stringify(jsonString)}
50
- `
51
- return temp
34
+ return jsonString;
35
+
36
+ // // !!!必须开头没有空格
37
+ // let temp = `%YAML 1.1
38
+ // %TAG !u! tag:unity3d.com,2011:
39
+ // --- !u!114 &11400000
40
+ // MonoBehaviour:
41
+ // m_ObjectHideFlags: 0
42
+ // m_CorrespondingSourceObject: {fileID: 0}
43
+ // m_PrefabInstance: {fileID: 0}
44
+ // m_PrefabAsset: {fileID: 0}
45
+ // m_GameObject: {fileID: 0}
46
+ // m_Enabled: 1
47
+ // m_EditorHideFlags: 0
48
+ // m_Script: {fileID: 11500000, guid: 496f60086c072a8479a6e0b948efb5e8, type: 3}
49
+ // m_Name: ${fullName}
50
+ // m_EditorClassIdentifier:
51
+ // JsonText: ${JSON.stringify(jsonString)}
52
+ // `
53
+ // return temp
52
54
 
53
55
  }
54
56
 
@@ -65,7 +67,6 @@ export function exportUJsonLoader(paras: HandleSheetParams): string | null {
65
67
  var fullName = `${table.workbookName}-${name}`
66
68
  // !!!必须开头没有空格
67
69
  let temp = `
68
- using lang.json;
69
70
  using UnityEngine.AddressableAssets;
70
71
  using System.Threading.Tasks;
71
72
  using UnityEngine;
@@ -76,11 +77,11 @@ namespace MEEC.ExportedConfigs
76
77
  {
77
78
  public static async Task Load()
78
79
  {
79
- var loadUrl="Assets/Bundles/GameConfigs/Auto/${fullName}.asset";
80
- var configJson = await Addressables.LoadAssetAsync<ExcelConfigJson>(loadUrl).Task;
80
+ var loadUrl="Assets/Bundles/GameConfigs/Auto/${fullName}.json";
81
+ var configJson = await Addressables.LoadAssetAsync<TextAsset>(loadUrl).Task;
81
82
  if (configJson != null)
82
83
  {
83
- var jsonObjs = JSON.parse<${RowClass}[]>(configJson.JsonText);
84
+ var jsonObjs = JsonUtility.FromJson<${RowClass}[]>(configJson.text);
84
85
  var configs = ${RowClass}.Configs;
85
86
  configs.Clear();
86
87
  configs.AddRange(jsonObjs);
@@ -113,7 +114,7 @@ export class ExportUJsonPlugin extends PluginBase {
113
114
  {
114
115
  let content2 = exportUJson(paras)
115
116
  if (content2 != null) {
116
- let savePath = new OutFilePath(paras.outPath, fullName, ".asset").fullPath
117
+ let savePath = new OutFilePath(paras.outPath, fullName, ".json").fullPath
117
118
  fs.outputFileSync(savePath, content2, "utf-8")
118
119
  }
119
120
  return content2