@needle-tools/needle-component-compiler 1.9.4 → 1.10.1
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/Changelog.md +4 -0
- package/Readme.md +3 -1
- package/package.json +1 -1
- package/src/component-compiler.js +28 -12
- package/src/component-compiler.ts +20 -3
- package/COMPILE.bat +0 -1
- package/DEV.bat +0 -1
- package/INSTALL.bat +0 -1
- package/PUBLISH.bat +0 -8
- package/RUN_MANUAL_TEST.bat +0 -1
- package/RUN_TESTS.bat +0 -1
- package/src/test.js +0 -194
- package/src/test.ts +0 -234
- package/test/component.basic.test.js +0 -26
- package/test/component.basic.test.ts +0 -57
- package/test/component.methods.test.js +0 -82
- package/test/component.methods.test.ts +0 -185
- package/test/component.nonserialized.test.js +0 -20
- package/test/component.nonserialized.test.ts +0 -45
- package/test/component.primitives.test.js +0 -61
- package/test/component.primitives.test.ts +0 -158
- package/test/helpers.js +0 -54
- package/test/helpers.ts +0 -72
package/Changelog.md
CHANGED
|
@@ -4,6 +4,10 @@ All notable changes to this package will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [1.10.1] - 2023-08-02
|
|
8
|
+
- Add: use `@tooltip` to emit a UnityEngine.Tooltip
|
|
9
|
+
- Update Readme
|
|
10
|
+
|
|
7
11
|
## [1.9.4] - 2023-05-24
|
|
8
12
|
- Change: `Object3D` now emits `GameObject` field instead of `Transform`
|
|
9
13
|
- Fix: ignore `static` methods
|
package/Readme.md
CHANGED
|
@@ -13,4 +13,6 @@ Please run ``npm install`` first before using.
|
|
|
13
13
|
- ``@serializeField`` field decorator, similar to ``[SerializeField]`` in Unity
|
|
14
14
|
- ``@nonSerialized`` field or method decorator to skip generating c# code for a field or a method, similar to ``[NonSerialized]`` in Unity
|
|
15
15
|
- ``@type MyNamespace.MyType`` decorator for fields or classes, specifiy C# type of field or class
|
|
16
|
-
- ``@ifdef MY_IFDEF`` field decorator only at the moment
|
|
16
|
+
- ``@ifdef MY_IFDEF`` field decorator only at the moment
|
|
17
|
+
- ``@tooltip My Text`` field decorator, generates a Unity `[Tooltip("My Text")]`
|
|
18
|
+
- ``@contextmenu MethodName`` method decorator, generates a `[ContextMenu("MethodName")]`
|
package/package.json
CHANGED
|
@@ -70,14 +70,22 @@ var ExportContext = /** @class */ (function () {
|
|
|
70
70
|
this.classEnd = -1;
|
|
71
71
|
this.indentLevel = 0;
|
|
72
72
|
this.emitMethodContextMenu = null;
|
|
73
|
+
this.emitTooltip = null;
|
|
73
74
|
this.outputDir = outputDir;
|
|
74
75
|
this.fileName = fileName;
|
|
75
76
|
this.reset();
|
|
76
77
|
}
|
|
78
|
+
ExportContext.prototype.onBeforeField = function (name) {
|
|
79
|
+
if (this.emitTooltip) {
|
|
80
|
+
this.appendLine("[UnityEngine.Tooltip(\"" + this.emitTooltip.trim().replace("\"", "'") + "\")]");
|
|
81
|
+
this.emitTooltip = undefined;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
77
84
|
ExportContext.prototype.onBeforeMethod = function (name) {
|
|
78
85
|
if (this.emitMethodContextMenu !== undefined) {
|
|
79
86
|
var contextMenuText = this.emitMethodContextMenu === null ? name : this.emitMethodContextMenu;
|
|
80
87
|
this.appendLine("[UnityEngine.ContextMenu(\"" + contextMenuText + "\")]");
|
|
88
|
+
this.emitMethodContextMenu = undefined;
|
|
81
89
|
}
|
|
82
90
|
};
|
|
83
91
|
ExportContext.prototype.append = function (text) {
|
|
@@ -156,7 +164,7 @@ function run(program, outputDir, sourceFile) {
|
|
|
156
164
|
}
|
|
157
165
|
return results;
|
|
158
166
|
function visit(node) {
|
|
159
|
-
var _a, _b, _c, _d, _e, _f;
|
|
167
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
160
168
|
var context = contexts.length > 0 ? contexts[contexts.length - 1] : null;
|
|
161
169
|
if (context) {
|
|
162
170
|
if ((context === null || context === void 0 ? void 0 : context.classEnd) > 0 && node.pos >= (context === null || context === void 0 ? void 0 : context.classEnd)) {
|
|
@@ -181,12 +189,19 @@ function run(program, outputDir, sourceFile) {
|
|
|
181
189
|
continue;
|
|
182
190
|
commentStarts.push(r.pos);
|
|
183
191
|
var comment = node.getSourceFile().getFullText().slice(r.pos, r.end);
|
|
192
|
+
console.log(comment);
|
|
184
193
|
if (context) {
|
|
185
194
|
// https://regex101.com/r/ud4oev/1
|
|
186
|
-
var emitContextMenu = comment.match("(\/{2,}|\/\*)
|
|
195
|
+
var emitContextMenu = comment.match("(\/{2,}|\/\*) {0,}@contextmenu {1,}(?<text>[a-zA-Z 0-9]+)?");
|
|
187
196
|
if (emitContextMenu) {
|
|
188
197
|
context.emitMethodContextMenu = (_b = (_a = emitContextMenu.groups) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : null;
|
|
189
198
|
}
|
|
199
|
+
// https://regex101.com/r/Sa6Q8T/3
|
|
200
|
+
var emitTooltip = comment.match("\/{2,} {0,}(@tooltip) *?(?<text>.+)");
|
|
201
|
+
if (emitTooltip) {
|
|
202
|
+
console.log((_c = emitTooltip.groups) === null || _c === void 0 ? void 0 : _c.text);
|
|
203
|
+
context.emitTooltip = (_e = (_d = emitTooltip.groups) === null || _d === void 0 ? void 0 : _d.text) !== null && _e !== void 0 ? _e : null;
|
|
204
|
+
}
|
|
190
205
|
else if (comment.includes(serializeCommand))
|
|
191
206
|
serializeField = true;
|
|
192
207
|
else if (comment.includes(dontSerializeCommand))
|
|
@@ -246,8 +261,8 @@ function run(program, outputDir, sourceFile) {
|
|
|
246
261
|
if (!pub_1)
|
|
247
262
|
return;
|
|
248
263
|
var paramsStr = "";
|
|
249
|
-
for (var
|
|
250
|
-
var param =
|
|
264
|
+
for (var _k = 0, _l = meth.parameters; _k < _l.length; _k++) {
|
|
265
|
+
var param = _l[_k];
|
|
251
266
|
if (!param || !param.name)
|
|
252
267
|
continue;
|
|
253
268
|
if (paramsStr.length > 0)
|
|
@@ -304,15 +319,15 @@ function run(program, outputDir, sourceFile) {
|
|
|
304
319
|
break;
|
|
305
320
|
var typeString = lastTypeFound !== null && lastTypeFound !== void 0 ? lastTypeFound : tryResolveTypeRecursive(node);
|
|
306
321
|
var postFix = "";
|
|
307
|
-
var typeName = (
|
|
322
|
+
var typeName = (_f = vardec.type) === null || _f === void 0 ? void 0 : _f.getText();
|
|
308
323
|
var shouldCommentTheLine = typeString === undefined;
|
|
309
324
|
if (typeString === undefined) {
|
|
310
325
|
postFix = " → Could not resolve C# type";
|
|
311
326
|
}
|
|
312
327
|
var assignment = "";
|
|
313
328
|
if (typeString !== undefined) {
|
|
314
|
-
for (var
|
|
315
|
-
var ch =
|
|
329
|
+
for (var _m = 0, _o = node.getChildren(); _m < _o.length; _m++) {
|
|
330
|
+
var ch = _o[_m];
|
|
316
331
|
switch (ch.kind) {
|
|
317
332
|
default:
|
|
318
333
|
// console.log("Unknown assignment:", ts.SyntaxKind[ch.kind]);
|
|
@@ -358,6 +373,7 @@ function run(program, outputDir, sourceFile) {
|
|
|
358
373
|
// assignment = " = new object[0]";
|
|
359
374
|
shouldCommentTheLine = true;
|
|
360
375
|
}
|
|
376
|
+
context.onBeforeField(varName);
|
|
361
377
|
if (allowDebugLogs)
|
|
362
378
|
console.log("EMIT member: \"" + typeString + "\" " + varName, assignment, "Last type found:", lastTypeFound);
|
|
363
379
|
var prefix = shouldCommentTheLine ? "// " : "";
|
|
@@ -374,10 +390,10 @@ function run(program, outputDir, sourceFile) {
|
|
|
374
390
|
var inheritsComponent = testInheritsComponent(node);
|
|
375
391
|
if (!dontExportNextClass && (lastTypeFound || exportNextClass || inheritsComponent)) {
|
|
376
392
|
resetExportNextClass();
|
|
377
|
-
var name_2 = (
|
|
393
|
+
var name_2 = (_g = dec.name) === null || _g === void 0 ? void 0 : _g.escapedText;
|
|
378
394
|
if (allowDebugLogs)
|
|
379
395
|
console.log("Found class: ", name_2);
|
|
380
|
-
var namespace = (
|
|
396
|
+
var namespace = (_h = tryParseNamespace(node)) !== null && _h !== void 0 ? _h : "Needle.Typescript.GeneratedComponents";
|
|
381
397
|
if (allowDebugLogs)
|
|
382
398
|
console.log("NAMESPACE", namespace);
|
|
383
399
|
var newContext = new ExportContext(outputDir, name_2 + ".cs");
|
|
@@ -398,8 +414,8 @@ function run(program, outputDir, sourceFile) {
|
|
|
398
414
|
console.log(name_2 + " inherits " + typeName_1);
|
|
399
415
|
var modifiers = "";
|
|
400
416
|
if (dec.modifiers) {
|
|
401
|
-
for (var
|
|
402
|
-
var mod =
|
|
417
|
+
for (var _p = 0, _q = dec.modifiers; _p < _q.length; _p++) {
|
|
418
|
+
var mod = _q[_p];
|
|
403
419
|
switch (mod.getText()) {
|
|
404
420
|
case "abstract":
|
|
405
421
|
modifiers += " abstract";
|
|
@@ -418,7 +434,7 @@ function run(program, outputDir, sourceFile) {
|
|
|
418
434
|
}
|
|
419
435
|
else {
|
|
420
436
|
if (allowDebugLogs)
|
|
421
|
-
console.log("Class type is unknown and will not generate a component: ", (
|
|
437
|
+
console.log("Class type is unknown and will not generate a component: ", (_j = dec.name) === null || _j === void 0 ? void 0 : _j.escapedText);
|
|
422
438
|
}
|
|
423
439
|
lastTypeFound = null;
|
|
424
440
|
break;
|
|
@@ -90,11 +90,20 @@ class ExportContext {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
emitMethodContextMenu: string | null | undefined = null;
|
|
93
|
+
emitTooltip: string | null | undefined = null;
|
|
94
|
+
|
|
95
|
+
onBeforeField(name: string) {
|
|
96
|
+
if (this.emitTooltip) {
|
|
97
|
+
this.appendLine("[UnityEngine.Tooltip(\"" + this.emitTooltip.trim().replace("\"", "'") + "\")]");
|
|
98
|
+
this.emitTooltip = undefined;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
93
101
|
|
|
94
102
|
onBeforeMethod(name: string) {
|
|
95
103
|
if (this.emitMethodContextMenu !== undefined) {
|
|
96
104
|
const contextMenuText = this.emitMethodContextMenu === null ? name : this.emitMethodContextMenu;
|
|
97
105
|
this.appendLine("[UnityEngine.ContextMenu(\"" + contextMenuText + "\")]");
|
|
106
|
+
this.emitMethodContextMenu = undefined;
|
|
98
107
|
}
|
|
99
108
|
}
|
|
100
109
|
|
|
@@ -116,7 +125,7 @@ class ExportContext {
|
|
|
116
125
|
this.textBuffer = CODEGEN_MARKER_START + "\n" + this.textBuffer + "\n" + CODEGEN_MARKER_END;
|
|
117
126
|
let code = this.textBuffer;
|
|
118
127
|
if (this.outputDir !== null) {
|
|
119
|
-
if(!fs.existsSync(this.outputDir))
|
|
128
|
+
if (!fs.existsSync(this.outputDir))
|
|
120
129
|
fs.mkdirSync(this.outputDir);
|
|
121
130
|
const dir = this.outputDir + "/";
|
|
122
131
|
const path = dir + this.fileName;
|
|
@@ -137,7 +146,7 @@ class ExportContext {
|
|
|
137
146
|
this.classEnd = -1;
|
|
138
147
|
}
|
|
139
148
|
|
|
140
|
-
private replaceGeneratedCodeSection(path: string, code:string) {
|
|
149
|
+
private replaceGeneratedCodeSection(path: string, code: string) {
|
|
141
150
|
if (fs.existsSync(path)) {
|
|
142
151
|
const existing = fs.readFileSync(path, "utf8");
|
|
143
152
|
const regex = new RegExp("(?<before>.*?)\/\/ ?NEEDLE_CODEGEN_START.+\/\/ ?NEEDLE_CODEGEN_END(?<after>.*)", "s");
|
|
@@ -218,12 +227,19 @@ export function run(program: ts.Program, outputDir: string | null, sourceFile: t
|
|
|
218
227
|
if (commentStarts.includes(r.pos)) continue;
|
|
219
228
|
commentStarts.push(r.pos);
|
|
220
229
|
const comment = node.getSourceFile().getFullText().slice(r.pos, r.end);
|
|
230
|
+
console.log(comment);
|
|
221
231
|
if (context) {
|
|
222
232
|
// https://regex101.com/r/ud4oev/1
|
|
223
|
-
const emitContextMenu = comment.match("(\/{2,}|\/\*)
|
|
233
|
+
const emitContextMenu = comment.match("(\/{2,}|\/\*) {0,}@contextmenu {1,}(?<text>[a-zA-Z 0-9]+)?");
|
|
224
234
|
if (emitContextMenu) {
|
|
225
235
|
context.emitMethodContextMenu = emitContextMenu.groups?.text ?? null;
|
|
226
236
|
}
|
|
237
|
+
// https://regex101.com/r/Sa6Q8T/3
|
|
238
|
+
const emitTooltip = comment.match("\/{2,} {0,}(@tooltip) *?(?<text>.+)");
|
|
239
|
+
if (emitTooltip) {
|
|
240
|
+
console.log(emitTooltip.groups?.text);
|
|
241
|
+
context.emitTooltip = emitTooltip.groups?.text ?? null;
|
|
242
|
+
}
|
|
227
243
|
else if (comment.includes(serializeCommand))
|
|
228
244
|
serializeField = true;
|
|
229
245
|
else if (comment.includes(dontSerializeCommand))
|
|
@@ -389,6 +405,7 @@ export function run(program: ts.Program, outputDir: string | null, sourceFile: t
|
|
|
389
405
|
// assignment = " = new object[0]";
|
|
390
406
|
shouldCommentTheLine = true;
|
|
391
407
|
}
|
|
408
|
+
context.onBeforeField(varName);
|
|
392
409
|
if (allowDebugLogs)
|
|
393
410
|
console.log("EMIT member: \"" + typeString + "\" " + varName, assignment, "Last type found:", lastTypeFound);
|
|
394
411
|
const prefix = shouldCommentTheLine ? "// " : "";
|
package/COMPILE.bat
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npm run tsc src/component-compiler
|
package/DEV.bat
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npm install && npm run dev
|
package/INSTALL.bat
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npm install && timeout 10
|
package/PUBLISH.bat
DELETED
package/RUN_MANUAL_TEST.bat
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npm run tsc src/component-compiler && node src/component-compiler.js dist src/test.ts
|
package/RUN_TESTS.bat
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npm run test & pause
|
package/src/test.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
exports.__esModule = true;
|
|
18
|
-
exports.MyTestComponent = void 0;
|
|
19
|
-
var MyTestComponent = /** @class */ (function (_super) {
|
|
20
|
-
__extends(MyTestComponent, _super);
|
|
21
|
-
function MyTestComponent() {
|
|
22
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
-
_this.myVector2 = new Vector2(1, .5);
|
|
24
|
-
return _this;
|
|
25
|
-
}
|
|
26
|
-
MyTestComponent.prototype.myMethod = function () {
|
|
27
|
-
};
|
|
28
|
-
return MyTestComponent;
|
|
29
|
-
}(Behaviour));
|
|
30
|
-
exports.MyTestComponent = MyTestComponent;
|
|
31
|
-
// export class SkipFieldAndMethod extends Behaviour {
|
|
32
|
-
// //@nonSerialized
|
|
33
|
-
// myMethod() {
|
|
34
|
-
// }
|
|
35
|
-
// // @nonSerialized
|
|
36
|
-
// myField : string;
|
|
37
|
-
// }
|
|
38
|
-
// export class ComponentWithUnknownType extends Behaviour {
|
|
39
|
-
// views: SomeUnknownType;
|
|
40
|
-
// }
|
|
41
|
-
// export class ComponentWithAnimationClip extends Behaviour implements IPointerClickHandler {
|
|
42
|
-
// @serializeable(AnimationClip)
|
|
43
|
-
// animation?: THREE.AnimationClip;
|
|
44
|
-
// }
|
|
45
|
-
// export abstract class MyAbstractComponent extends Behaviour {
|
|
46
|
-
// abstract myMethod();
|
|
47
|
-
// }
|
|
48
|
-
// export class CameraView extends Behaviour {
|
|
49
|
-
// static views: CameraView[] = [];
|
|
50
|
-
// }
|
|
51
|
-
// export class EventComponent extends Behaviour {
|
|
52
|
-
// @serializeable(EventList)
|
|
53
|
-
// roomChanged: EventList = new EventList();
|
|
54
|
-
// }
|
|
55
|
-
// export class SocLoader extends Behaviour {
|
|
56
|
-
// @serializeable(AssetReference)
|
|
57
|
-
// scenes: Array<AssetReference> = [];
|
|
58
|
-
// }
|
|
59
|
-
// // class Test123 {}
|
|
60
|
-
// export class Bla extends Behaviour
|
|
61
|
-
// {
|
|
62
|
-
// myNumber:number = 42;
|
|
63
|
-
// myBool:boolean = true;
|
|
64
|
-
// myString:string = "test";
|
|
65
|
-
// numberArr: number[] = [1,2,3];
|
|
66
|
-
// myColor : THREE.Color = new THREE.Color(255, 0, 0);
|
|
67
|
-
// renderers = new Array<Renderer>();
|
|
68
|
-
// renderers2 : Renderer[] = [];
|
|
69
|
-
// objArr : object[];
|
|
70
|
-
// colArr: THREE.Color[] = [new THREE.Color(1,2,3)];
|
|
71
|
-
// map : Map<string> = new Map<string>();
|
|
72
|
-
// map2 : Map<object> = new Map<object>();
|
|
73
|
-
// private myThing : Test123;
|
|
74
|
-
// }
|
|
75
|
-
// //@type UnityEngine.MonoBehaviour
|
|
76
|
-
// export class ButtonObject extends Interactable implements IPointerClickHandler, ISerializable {
|
|
77
|
-
// //@type UnityEngine.Transform[]
|
|
78
|
-
// myType?: SceneFXWindow;
|
|
79
|
-
// }
|
|
80
|
-
// import { Behaviour } from "needle.tiny.engine/engine-components/Component";
|
|
81
|
-
// import { RoomEntity } from "./Room";
|
|
82
|
-
// import { Behaviour } from "needle.tiny.engine/engine-components/Component";
|
|
83
|
-
// export class MyNewScript extends DriveClient
|
|
84
|
-
// {
|
|
85
|
-
// //@type test
|
|
86
|
-
// texture : RenderTexture;
|
|
87
|
-
// }
|
|
88
|
-
// namespace Hello.World
|
|
89
|
-
// {
|
|
90
|
-
// namespace Deep {
|
|
91
|
-
// export class MyClass extends Behaviour {
|
|
92
|
-
// //@ifdef TEST
|
|
93
|
-
// public myFloat :number;
|
|
94
|
-
// }
|
|
95
|
-
// }
|
|
96
|
-
// }
|
|
97
|
-
// class OtherClass extends Behaviour {
|
|
98
|
-
// }
|
|
99
|
-
//@type (RoomEntity)
|
|
100
|
-
// export class NavigationManager extends RoomEntity {
|
|
101
|
-
// fl:number = 1;
|
|
102
|
-
// nav_forward() {
|
|
103
|
-
// }
|
|
104
|
-
// nav_backward() {
|
|
105
|
-
// }
|
|
106
|
-
// }
|
|
107
|
-
// export abstract class NavComponent extends Behaviour {
|
|
108
|
-
// abstract next();
|
|
109
|
-
// abstract prev();
|
|
110
|
-
// abstract isAtEnd():boolean;
|
|
111
|
-
// }
|
|
112
|
-
// export class PointOfInterest extends Behaviour {
|
|
113
|
-
// myVal:number = 12;
|
|
114
|
-
// // @type(HELLO)
|
|
115
|
-
// myFunction(){
|
|
116
|
-
// }
|
|
117
|
-
// // @type(UnityEngine.Camera)
|
|
118
|
-
// view?:Camera;
|
|
119
|
-
// test:string = "123";
|
|
120
|
-
// // test
|
|
121
|
-
// }
|
|
122
|
-
// export class MaterialColorHandler extends Behaviour {
|
|
123
|
-
// @serializeable(Renderer)
|
|
124
|
-
// renderer?: Renderer[];
|
|
125
|
-
// }
|
|
126
|
-
// export class MyArray extends Behaviour {
|
|
127
|
-
// arr? : Array<number> = [1,2,3];
|
|
128
|
-
// }
|
|
129
|
-
// export class PrivateSerializedField extends Behaviour {
|
|
130
|
-
// //@serializeField
|
|
131
|
-
// private color? : THREE.Color;
|
|
132
|
-
// }
|
|
133
|
-
// export class MyPropertyClass extends Behaviour {
|
|
134
|
-
// set color(col: THREE.Color) {
|
|
135
|
-
// }
|
|
136
|
-
// }
|
|
137
|
-
// export class MyClassWithAFloat extends Behaviour {
|
|
138
|
-
// myfloat:number = .5;
|
|
139
|
-
// private myString : string;
|
|
140
|
-
// }
|
|
141
|
-
// export class GltfExport extends Behaviour {
|
|
142
|
-
// binary: boolean = true;
|
|
143
|
-
// "$serializedTypes" = {
|
|
144
|
-
// url:null
|
|
145
|
-
// }
|
|
146
|
-
// // @contextmenu enable this
|
|
147
|
-
// test(){
|
|
148
|
-
// }
|
|
149
|
-
// }
|
|
150
|
-
// export class SetColor extends Behaviour {
|
|
151
|
-
// "@serializedTypes" = {
|
|
152
|
-
// col: Number,
|
|
153
|
-
// }
|
|
154
|
-
// }
|
|
155
|
-
// class Behaviour {
|
|
156
|
-
// }
|
|
157
|
-
// export class PlatformerMusic extends Behaviour implements IPlaymodeChangeListener {
|
|
158
|
-
// source?: AudioSource;
|
|
159
|
-
// editMode?: string;
|
|
160
|
-
// playMode?: string;
|
|
161
|
-
// onPlaymodeChange(playmode: PlayMode): void {
|
|
162
|
-
// console.log(this);
|
|
163
|
-
// if(!this.source) return;
|
|
164
|
-
// const clip = playmode.isInPlayMode ? this.playMode : this.editMode;
|
|
165
|
-
// console.log("PLAY", clip);
|
|
166
|
-
// this.source.play(clip);
|
|
167
|
-
// }
|
|
168
|
-
// }
|
|
169
|
-
// // TODO: export UnityEvent like this
|
|
170
|
-
// // disable codegen
|
|
171
|
-
// class UnityEvent {
|
|
172
|
-
// methods: Function[] = [];
|
|
173
|
-
// invoke() {
|
|
174
|
-
// for (const m of this.methods) {
|
|
175
|
-
// m();
|
|
176
|
-
// }
|
|
177
|
-
// }
|
|
178
|
-
// }
|
|
179
|
-
// export class MyClass extends Behaviour {
|
|
180
|
-
// myFloat: number = 15;
|
|
181
|
-
// myBool: boolean;
|
|
182
|
-
// // just some default values
|
|
183
|
-
// myArray: number[] = [1, 2, 3];
|
|
184
|
-
// // comment for myString
|
|
185
|
-
// myString: string = "this is a string1";
|
|
186
|
-
// myObject: THREE.Object3D;
|
|
187
|
-
// myBool2: boolean;
|
|
188
|
-
// myFunction() { }
|
|
189
|
-
// myFunctionWithStringParameter(string: string) { }
|
|
190
|
-
// myFunctionWithSomeObjectAndArray(obj: THREE.Object3D, arr: number[]) { }
|
|
191
|
-
// myFunctionWithoutParamTypes(test) { }
|
|
192
|
-
// someOtherStuff: THREE.Object3D[] | null = null;
|
|
193
|
-
// myEvent: UnityEvent;
|
|
194
|
-
// }
|
package/src/test.ts
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import { ThisExpression } from "typescript";
|
|
2
|
-
|
|
3
|
-
export class MyTestComponent extends Behaviour {
|
|
4
|
-
public myVector2: Vector2 = new Vector2(1, .5);
|
|
5
|
-
private myMethod(){
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// export class SkipFieldAndMethod extends Behaviour {
|
|
12
|
-
|
|
13
|
-
// //@nonSerialized
|
|
14
|
-
// myMethod() {
|
|
15
|
-
|
|
16
|
-
// }
|
|
17
|
-
|
|
18
|
-
// // @nonSerialized
|
|
19
|
-
// myField : string;
|
|
20
|
-
|
|
21
|
-
// }
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// export class ComponentWithUnknownType extends Behaviour {
|
|
25
|
-
// views: SomeUnknownType;
|
|
26
|
-
// }
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// export class ComponentWithAnimationClip extends Behaviour implements IPointerClickHandler {
|
|
30
|
-
|
|
31
|
-
// @serializeable(AnimationClip)
|
|
32
|
-
// animation?: THREE.AnimationClip;
|
|
33
|
-
// }
|
|
34
|
-
|
|
35
|
-
// export abstract class MyAbstractComponent extends Behaviour {
|
|
36
|
-
// abstract myMethod();
|
|
37
|
-
// }
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// export class CameraView extends Behaviour {
|
|
41
|
-
// static views: CameraView[] = [];
|
|
42
|
-
// }
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// export class EventComponent extends Behaviour {
|
|
46
|
-
// @serializeable(EventList)
|
|
47
|
-
// roomChanged: EventList = new EventList();
|
|
48
|
-
// }
|
|
49
|
-
|
|
50
|
-
// export class SocLoader extends Behaviour {
|
|
51
|
-
|
|
52
|
-
// @serializeable(AssetReference)
|
|
53
|
-
// scenes: Array<AssetReference> = [];
|
|
54
|
-
// }
|
|
55
|
-
// // class Test123 {}
|
|
56
|
-
|
|
57
|
-
// export class Bla extends Behaviour
|
|
58
|
-
// {
|
|
59
|
-
// myNumber:number = 42;
|
|
60
|
-
// myBool:boolean = true;
|
|
61
|
-
// myString:string = "test";
|
|
62
|
-
// numberArr: number[] = [1,2,3];
|
|
63
|
-
// myColor : THREE.Color = new THREE.Color(255, 0, 0);
|
|
64
|
-
// renderers = new Array<Renderer>();
|
|
65
|
-
// renderers2 : Renderer[] = [];
|
|
66
|
-
// objArr : object[];
|
|
67
|
-
// colArr: THREE.Color[] = [new THREE.Color(1,2,3)];
|
|
68
|
-
// map : Map<string> = new Map<string>();
|
|
69
|
-
// map2 : Map<object> = new Map<object>();
|
|
70
|
-
// private myThing : Test123;
|
|
71
|
-
// }
|
|
72
|
-
|
|
73
|
-
// //@type UnityEngine.MonoBehaviour
|
|
74
|
-
// export class ButtonObject extends Interactable implements IPointerClickHandler, ISerializable {
|
|
75
|
-
|
|
76
|
-
// //@type UnityEngine.Transform[]
|
|
77
|
-
// myType?: SceneFXWindow;
|
|
78
|
-
// }
|
|
79
|
-
|
|
80
|
-
// import { Behaviour } from "needle.tiny.engine/engine-components/Component";
|
|
81
|
-
// import { RoomEntity } from "./Room";
|
|
82
|
-
|
|
83
|
-
// import { Behaviour } from "needle.tiny.engine/engine-components/Component";
|
|
84
|
-
|
|
85
|
-
// export class MyNewScript extends DriveClient
|
|
86
|
-
// {
|
|
87
|
-
// //@type test
|
|
88
|
-
// texture : RenderTexture;
|
|
89
|
-
// }
|
|
90
|
-
|
|
91
|
-
// namespace Hello.World
|
|
92
|
-
// {
|
|
93
|
-
// namespace Deep {
|
|
94
|
-
// export class MyClass extends Behaviour {
|
|
95
|
-
// //@ifdef TEST
|
|
96
|
-
// public myFloat :number;
|
|
97
|
-
// }
|
|
98
|
-
// }
|
|
99
|
-
// }
|
|
100
|
-
|
|
101
|
-
// class OtherClass extends Behaviour {
|
|
102
|
-
|
|
103
|
-
// }
|
|
104
|
-
|
|
105
|
-
//@type (RoomEntity)
|
|
106
|
-
// export class NavigationManager extends RoomEntity {
|
|
107
|
-
|
|
108
|
-
// fl:number = 1;
|
|
109
|
-
|
|
110
|
-
// nav_forward() {
|
|
111
|
-
|
|
112
|
-
// }
|
|
113
|
-
|
|
114
|
-
// nav_backward() {
|
|
115
|
-
|
|
116
|
-
// }
|
|
117
|
-
// }
|
|
118
|
-
|
|
119
|
-
// export abstract class NavComponent extends Behaviour {
|
|
120
|
-
|
|
121
|
-
// abstract next();
|
|
122
|
-
// abstract prev();
|
|
123
|
-
// abstract isAtEnd():boolean;
|
|
124
|
-
// }
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
// export class PointOfInterest extends Behaviour {
|
|
128
|
-
|
|
129
|
-
// myVal:number = 12;
|
|
130
|
-
|
|
131
|
-
// // @type(HELLO)
|
|
132
|
-
// myFunction(){
|
|
133
|
-
|
|
134
|
-
// }
|
|
135
|
-
|
|
136
|
-
// // @type(UnityEngine.Camera)
|
|
137
|
-
// view?:Camera;
|
|
138
|
-
// test:string = "123";
|
|
139
|
-
// // test
|
|
140
|
-
// }
|
|
141
|
-
|
|
142
|
-
// export class MaterialColorHandler extends Behaviour {
|
|
143
|
-
|
|
144
|
-
// @serializeable(Renderer)
|
|
145
|
-
// renderer?: Renderer[];
|
|
146
|
-
// }
|
|
147
|
-
|
|
148
|
-
// export class MyArray extends Behaviour {
|
|
149
|
-
|
|
150
|
-
// arr? : Array<number> = [1,2,3];
|
|
151
|
-
// }
|
|
152
|
-
|
|
153
|
-
// export class PrivateSerializedField extends Behaviour {
|
|
154
|
-
|
|
155
|
-
// //@serializeField
|
|
156
|
-
// private color? : THREE.Color;
|
|
157
|
-
// }
|
|
158
|
-
// export class MyPropertyClass extends Behaviour {
|
|
159
|
-
// set color(col: THREE.Color) {
|
|
160
|
-
// }
|
|
161
|
-
// }
|
|
162
|
-
|
|
163
|
-
// export class MyClassWithAFloat extends Behaviour {
|
|
164
|
-
// myfloat:number = .5;
|
|
165
|
-
// private myString : string;
|
|
166
|
-
// }
|
|
167
|
-
|
|
168
|
-
// export class GltfExport extends Behaviour {
|
|
169
|
-
// binary: boolean = true;
|
|
170
|
-
// "$serializedTypes" = {
|
|
171
|
-
// url:null
|
|
172
|
-
// }
|
|
173
|
-
|
|
174
|
-
// // @contextmenu enable this
|
|
175
|
-
// test(){
|
|
176
|
-
|
|
177
|
-
// }
|
|
178
|
-
// }
|
|
179
|
-
|
|
180
|
-
// export class SetColor extends Behaviour {
|
|
181
|
-
|
|
182
|
-
// "@serializedTypes" = {
|
|
183
|
-
// col: Number,
|
|
184
|
-
// }
|
|
185
|
-
// }
|
|
186
|
-
|
|
187
|
-
// class Behaviour {
|
|
188
|
-
|
|
189
|
-
// }
|
|
190
|
-
|
|
191
|
-
// export class PlatformerMusic extends Behaviour implements IPlaymodeChangeListener {
|
|
192
|
-
// source?: AudioSource;
|
|
193
|
-
// editMode?: string;
|
|
194
|
-
// playMode?: string;
|
|
195
|
-
|
|
196
|
-
// onPlaymodeChange(playmode: PlayMode): void {
|
|
197
|
-
// console.log(this);
|
|
198
|
-
// if(!this.source) return;
|
|
199
|
-
// const clip = playmode.isInPlayMode ? this.playMode : this.editMode;
|
|
200
|
-
// console.log("PLAY", clip);
|
|
201
|
-
// this.source.play(clip);
|
|
202
|
-
// }
|
|
203
|
-
|
|
204
|
-
// }
|
|
205
|
-
|
|
206
|
-
// // TODO: export UnityEvent like this
|
|
207
|
-
// // disable codegen
|
|
208
|
-
// class UnityEvent {
|
|
209
|
-
// methods: Function[] = [];
|
|
210
|
-
// invoke() {
|
|
211
|
-
// for (const m of this.methods) {
|
|
212
|
-
// m();
|
|
213
|
-
// }
|
|
214
|
-
// }
|
|
215
|
-
// }
|
|
216
|
-
|
|
217
|
-
// export class MyClass extends Behaviour {
|
|
218
|
-
// myFloat: number = 15;
|
|
219
|
-
// myBool: boolean;
|
|
220
|
-
// // just some default values
|
|
221
|
-
// myArray: number[] = [1, 2, 3];
|
|
222
|
-
// // comment for myString
|
|
223
|
-
// myString: string = "this is a string1";
|
|
224
|
-
// myObject: THREE.Object3D;
|
|
225
|
-
// myBool2: boolean;
|
|
226
|
-
|
|
227
|
-
// myFunction() { }
|
|
228
|
-
// myFunctionWithStringParameter(string: string) { }
|
|
229
|
-
// myFunctionWithSomeObjectAndArray(obj: THREE.Object3D, arr: number[]) { }
|
|
230
|
-
// myFunctionWithoutParamTypes(test) { }
|
|
231
|
-
|
|
232
|
-
// someOtherStuff: THREE.Object3D[] | null = null;
|
|
233
|
-
// myEvent: UnityEvent;
|
|
234
|
-
// }
|