export-table-pulgin-csharp 1.1.82 → 1.1.84
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.
- package/dist/ExportUnityCSJsonPlugin.d.ts.map +1 -1
- package/dist/ExportUnityCSJsonPlugin.js +10 -6
- package/package.json +1 -1
- package/src/ExportUnityCSJsonPlugin.ts +15 -5
- package/dist/ExportUnityCSJsonPluginV1.d.ts +0 -8
- package/dist/ExportUnityCSJsonPluginV1.d.ts.map +0 -1
- package/dist/ExportUnityCSJsonPluginV1.js +0 -149
|
@@ -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,EAAqC,MAAM,kBAAkB,CAAA;AAMxJ,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA+CnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"ExportUnityCSJsonPlugin.d.ts","sourceRoot":"","sources":["../src/ExportUnityCSJsonPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAAE,iBAAiB,EAAqC,MAAM,kBAAkB,CAAA;AAMxJ,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA+CnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAuFzE;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;CAmC3C"}
|
|
@@ -67,7 +67,12 @@ function exportUJson(paras) {
|
|
|
67
67
|
}
|
|
68
68
|
exports.exportUJson = exportUJson;
|
|
69
69
|
function exportUJsonLoader(paras) {
|
|
70
|
-
let { datas, fields, name, objects, table, } = paras;
|
|
70
|
+
let { datas, fields, name, objects, table, exportNamespace, } = paras;
|
|
71
|
+
let jsonToolNamespaceIndex = process.argv.findIndex(v => v == "--JsonToolNamespace");
|
|
72
|
+
let jsonToolNamespace = "lang.json";
|
|
73
|
+
if (jsonToolNamespaceIndex >= 0 && process.argv.length > jsonToolNamespaceIndex + 1) {
|
|
74
|
+
jsonToolNamespace = process.argv[jsonToolNamespaceIndex + 1];
|
|
75
|
+
}
|
|
71
76
|
let RowClass = firstLetterUpper(name);
|
|
72
77
|
var fullName = `${table.workbookName}-${name}`;
|
|
73
78
|
// !!!必须开头没有空格
|
|
@@ -75,9 +80,9 @@ function exportUJsonLoader(paras) {
|
|
|
75
80
|
using UnityEngine.AddressableAssets;
|
|
76
81
|
using System.Threading.Tasks;
|
|
77
82
|
using UnityEngine;
|
|
78
|
-
using
|
|
83
|
+
using ${jsonToolNamespace};
|
|
79
84
|
|
|
80
|
-
namespace
|
|
85
|
+
namespace ${exportNamespace}
|
|
81
86
|
{
|
|
82
87
|
public partial class ${RowClass}
|
|
83
88
|
{
|
|
@@ -166,7 +171,7 @@ class ExportUJsonPlugin extends export_table_lib_1.PluginBase {
|
|
|
166
171
|
}
|
|
167
172
|
handleBatch(paras) {
|
|
168
173
|
var _a;
|
|
169
|
-
let moreOptions = paras
|
|
174
|
+
let { moreOptions, tables, exportNamespace, } = paras;
|
|
170
175
|
let isSkipIndexLoader = (_a = !!moreOptions.SkipIndexLoader) !== null && _a !== void 0 ? _a : false;
|
|
171
176
|
if (isSkipIndexLoader0) {
|
|
172
177
|
isSkipIndexLoader = true;
|
|
@@ -174,13 +179,12 @@ class ExportUJsonPlugin extends export_table_lib_1.PluginBase {
|
|
|
174
179
|
if (isSkipIndexLoader) {
|
|
175
180
|
return;
|
|
176
181
|
}
|
|
177
|
-
var tables = paras.tables;
|
|
178
182
|
var temp = `
|
|
179
183
|
using System;
|
|
180
184
|
using System.Collections.Generic;
|
|
181
185
|
using System.Threading.Tasks;
|
|
182
186
|
|
|
183
|
-
namespace
|
|
187
|
+
namespace ${exportNamespace}
|
|
184
188
|
{
|
|
185
189
|
public static class DefaultConfigLoader{
|
|
186
190
|
public static IEnumerable<Func<Task>> Load(){
|
package/package.json
CHANGED
|
@@ -61,8 +61,15 @@ export function exportUJsonLoader(paras: HandleSheetParams): string | null {
|
|
|
61
61
|
name,
|
|
62
62
|
objects,
|
|
63
63
|
table,
|
|
64
|
+
exportNamespace,
|
|
64
65
|
} = paras;
|
|
65
66
|
|
|
67
|
+
let jsonToolNamespaceIndex = process.argv.findIndex(v => v == "--JsonToolNamespace")
|
|
68
|
+
let jsonToolNamespace = "lang.json";
|
|
69
|
+
if(jsonToolNamespaceIndex>=0 && process.argv.length>jsonToolNamespaceIndex+1){
|
|
70
|
+
jsonToolNamespace = process.argv[jsonToolNamespaceIndex+1]
|
|
71
|
+
}
|
|
72
|
+
|
|
66
73
|
let RowClass = firstLetterUpper(name)
|
|
67
74
|
var fullName = `${table.workbookName}-${name}`
|
|
68
75
|
// !!!必须开头没有空格
|
|
@@ -70,9 +77,9 @@ export function exportUJsonLoader(paras: HandleSheetParams): string | null {
|
|
|
70
77
|
using UnityEngine.AddressableAssets;
|
|
71
78
|
using System.Threading.Tasks;
|
|
72
79
|
using UnityEngine;
|
|
73
|
-
using
|
|
80
|
+
using ${jsonToolNamespace};
|
|
74
81
|
|
|
75
|
-
namespace
|
|
82
|
+
namespace ${exportNamespace}
|
|
76
83
|
{
|
|
77
84
|
public partial class ${RowClass}
|
|
78
85
|
{
|
|
@@ -161,7 +168,11 @@ export class ExportUJsonPlugin extends PluginBase {
|
|
|
161
168
|
|
|
162
169
|
handleBatch(paras: HandleBatchParams): void {
|
|
163
170
|
|
|
164
|
-
let
|
|
171
|
+
let {
|
|
172
|
+
moreOptions,
|
|
173
|
+
tables,
|
|
174
|
+
exportNamespace,
|
|
175
|
+
} = paras
|
|
165
176
|
let isSkipIndexLoader = !!moreOptions.SkipIndexLoader ?? false
|
|
166
177
|
if (isSkipIndexLoader0) {
|
|
167
178
|
isSkipIndexLoader = true
|
|
@@ -170,13 +181,12 @@ export class ExportUJsonPlugin extends PluginBase {
|
|
|
170
181
|
return;
|
|
171
182
|
}
|
|
172
183
|
|
|
173
|
-
var tables = paras.tables;
|
|
174
184
|
var temp = `
|
|
175
185
|
using System;
|
|
176
186
|
using System.Collections.Generic;
|
|
177
187
|
using System.Threading.Tasks;
|
|
178
188
|
|
|
179
|
-
namespace
|
|
189
|
+
namespace ${exportNamespace}
|
|
180
190
|
{
|
|
181
191
|
public static class DefaultConfigLoader{
|
|
182
192
|
public static IEnumerable<Func<Task>> Load(){
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { HandleSheetParams, PluginBase, HandleBatchParams } from "export-table-lib";
|
|
2
|
-
export declare class ExportUJsonPluginV1 extends PluginBase {
|
|
3
|
-
name: string;
|
|
4
|
-
tags: string[];
|
|
5
|
-
handleSheet(paras: HandleSheetParams): string | null;
|
|
6
|
-
handleBatch(paras: HandleBatchParams): void;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=ExportUnityCSJsonPluginV1.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExportUnityCSJsonPluginV1.d.ts","sourceRoot":"","sources":["../src/ExportUnityCSJsonPluginV1.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAAE,iBAAiB,EAAqC,MAAM,kBAAkB,CAAA;AAgGxJ,qBAAa,mBAAoB,SAAQ,UAAU;IAClD,IAAI,SAAW;IACf,IAAI,EAAE,MAAM,EAAE,CAAa;IAE3B,WAAW,CAAC,KAAK,EAAE,iBAAiB;IAmBpC,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;CAsB3C"}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.ExportUJsonPluginV1 = void 0;
|
|
27
|
-
const export_table_lib_1 = require("export-table-lib");
|
|
28
|
-
const fs = __importStar(require("fs-extra"));
|
|
29
|
-
let firstLetterUpper = export_table_lib_1.makeFirstLetterUpper;
|
|
30
|
-
function exportUJson(paras) {
|
|
31
|
-
let { datas, fields, name, objects, table, } = paras;
|
|
32
|
-
let firstLetterLower = function (str) {
|
|
33
|
-
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
34
|
-
};
|
|
35
|
-
let convMemberName = function (str) {
|
|
36
|
-
return str.split("_").map(s => firstLetterUpper(s)).join("");
|
|
37
|
-
};
|
|
38
|
-
var fullName = `${table.workbookName}-${name}`;
|
|
39
|
-
let jsonString = JSON.stringify(objects.map(obj => {
|
|
40
|
-
var newObj = Object.create(null);
|
|
41
|
-
Object.keys(obj).forEach(key => {
|
|
42
|
-
var newKey = convMemberName(key);
|
|
43
|
-
newObj[newKey] = obj[key];
|
|
44
|
-
});
|
|
45
|
-
return newObj;
|
|
46
|
-
}));
|
|
47
|
-
// !!!必须开头没有空格
|
|
48
|
-
let temp = `%YAML 1.1
|
|
49
|
-
%TAG !u! tag:unity3d.com,2011:
|
|
50
|
-
--- !u!114 &11400000
|
|
51
|
-
MonoBehaviour:
|
|
52
|
-
m_ObjectHideFlags: 0
|
|
53
|
-
m_CorrespondingSourceObject: {fileID: 0}
|
|
54
|
-
m_PrefabInstance: {fileID: 0}
|
|
55
|
-
m_PrefabAsset: {fileID: 0}
|
|
56
|
-
m_GameObject: {fileID: 0}
|
|
57
|
-
m_Enabled: 1
|
|
58
|
-
m_EditorHideFlags: 0
|
|
59
|
-
m_Script: {fileID: 11500000, guid: 496f60086c072a8479a6e0b948efb5e8, type: 3}
|
|
60
|
-
m_Name: ${fullName}
|
|
61
|
-
m_EditorClassIdentifier:
|
|
62
|
-
JsonText: ${JSON.stringify(jsonString)}
|
|
63
|
-
`;
|
|
64
|
-
return temp;
|
|
65
|
-
}
|
|
66
|
-
function exportUJsonLoader(paras) {
|
|
67
|
-
let { datas, fields, name, objects, table, } = paras;
|
|
68
|
-
let RowClass = firstLetterUpper(name);
|
|
69
|
-
var fullName = `${table.workbookName}-${name}`;
|
|
70
|
-
// !!!必须开头没有空格
|
|
71
|
-
let temp = `
|
|
72
|
-
using lang.json;
|
|
73
|
-
using UnityEngine.AddressableAssets;
|
|
74
|
-
using System.Threading.Tasks;
|
|
75
|
-
using UnityEngine;
|
|
76
|
-
|
|
77
|
-
namespace MEEC.ExportedConfigs
|
|
78
|
-
{
|
|
79
|
-
public partial class ${RowClass}
|
|
80
|
-
{
|
|
81
|
-
public static async Task Load()
|
|
82
|
-
{
|
|
83
|
-
var loadUrl="Assets/Bundles/GameConfigs/Auto/${fullName}.asset";
|
|
84
|
-
var configJson = await Addressables.LoadAssetAsync<ExcelConfigJson>(loadUrl).Task;
|
|
85
|
-
if (configJson != null)
|
|
86
|
-
{
|
|
87
|
-
var jsonObjs = JSON.parse<${RowClass}[]>(configJson.JsonText);
|
|
88
|
-
var configs = ${RowClass}.Configs;
|
|
89
|
-
configs.Clear();
|
|
90
|
-
configs.AddRange(jsonObjs);
|
|
91
|
-
}
|
|
92
|
-
else
|
|
93
|
-
{
|
|
94
|
-
Debug.LogError($"配表资源缺失: {loadUrl}");
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
`;
|
|
100
|
-
return temp;
|
|
101
|
-
}
|
|
102
|
-
class ExportUJsonPluginV1 extends export_table_lib_1.PluginBase {
|
|
103
|
-
constructor() {
|
|
104
|
-
super(...arguments);
|
|
105
|
-
this.name = "ujson1";
|
|
106
|
-
this.tags = ["ujson1"];
|
|
107
|
-
}
|
|
108
|
-
handleSheet(paras) {
|
|
109
|
-
var fullName = `${paras.table.workbookName}-${paras.name}`;
|
|
110
|
-
{
|
|
111
|
-
let content1 = exportUJsonLoader(paras);
|
|
112
|
-
if (content1 != null) {
|
|
113
|
-
let savePath = new export_table_lib_1.OutFilePath(paras.outPath, fullName, "Loader.cs").fullPath;
|
|
114
|
-
fs.outputFileSync(savePath, content1, "utf-8");
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
{
|
|
118
|
-
let content2 = exportUJson(paras);
|
|
119
|
-
if (content2 != null) {
|
|
120
|
-
let savePath = new export_table_lib_1.OutFilePath(paras.outPath, fullName, ".asset").fullPath;
|
|
121
|
-
fs.outputFileSync(savePath, content2, "utf-8");
|
|
122
|
-
}
|
|
123
|
-
return content2;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
handleBatch(paras) {
|
|
127
|
-
var tables = paras.tables;
|
|
128
|
-
var temp = `
|
|
129
|
-
using System;
|
|
130
|
-
using System.Collections.Generic;
|
|
131
|
-
using System.Threading.Tasks;
|
|
132
|
-
|
|
133
|
-
namespace MEEC.ExportedConfigs
|
|
134
|
-
{
|
|
135
|
-
public static class DefaultConfigLoader{
|
|
136
|
-
public static IEnumerable<Func<Task>> Load(){
|
|
137
|
-
${(0, export_table_lib_1.foreach)(tables, (table) => `
|
|
138
|
-
yield return ${firstLetterUpper(table.name)}.Load;
|
|
139
|
-
`)}
|
|
140
|
-
yield break;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
`;
|
|
145
|
-
let savePath = paras.outPath + "/DefaultConfigLoader.cs";
|
|
146
|
-
fs.outputFileSync(savePath, temp, "utf-8");
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
exports.ExportUJsonPluginV1 = ExportUJsonPluginV1;
|