@holoscript/core 6.0.4 → 7.0.0

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.
Files changed (236) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/compiler/index.d.ts +82 -0
  4. package/dist/constants.d.ts +3 -2
  5. package/dist/coordinators/index.d.ts +189 -0
  6. package/dist/index.d.ts +501 -19
  7. package/dist/paper-0c-spike/index.d.ts +29 -0
  8. package/dist/reconstruction/index.d.ts +78 -0
  9. package/dist/tools/index.d.ts +22 -1
  10. package/dist/traitDocs/traitDocs.d.ts +69 -0
  11. package/dist/traits/index.d.ts +61 -0
  12. package/package.json +105 -57
  13. package/dist/GLTFPipeline-DEN36VNK.js +0 -12
  14. package/dist/GLTFPipeline-YPCAK236.cjs +0 -33
  15. package/dist/HoloScriptPlusParser-BN6KVRCM.js +0 -692
  16. package/dist/HoloScriptPlusParser-NC5FE6AL.cjs +0 -697
  17. package/dist/USDZExporter-NTMBNTDB.js +0 -707
  18. package/dist/USDZExporter-UWGWNMMD.cjs +0 -709
  19. package/dist/chunk-27LWW5FU.cjs +0 -410
  20. package/dist/chunk-2CWOLHTE.js +0 -69
  21. package/dist/chunk-33LSUQDD.cjs +0 -835
  22. package/dist/chunk-3FJCK5XA.js +0 -2232
  23. package/dist/chunk-3FXV5S25.cjs +0 -633
  24. package/dist/chunk-3FYZOR7S.cjs +0 -69
  25. package/dist/chunk-3SAK5KFL.cjs +0 -83
  26. package/dist/chunk-4XSNJCLC.cjs +0 -1859
  27. package/dist/chunk-54FHG2MX.js +0 -655
  28. package/dist/chunk-56IF4NTA.js +0 -56
  29. package/dist/chunk-5BGSECRJ.cjs +0 -2237
  30. package/dist/chunk-5GLCTO44.js +0 -161
  31. package/dist/chunk-5O6TQC6M.cjs +0 -1871
  32. package/dist/chunk-5OEOHAAW.cjs +0 -682
  33. package/dist/chunk-5TOFIR6L.js +0 -407
  34. package/dist/chunk-5WUNN6ZN.cjs +0 -428
  35. package/dist/chunk-6TZPZCOJ.cjs +0 -1404
  36. package/dist/chunk-6UEHYZ7V.cjs +0 -773
  37. package/dist/chunk-6XSERL6L.js +0 -5678
  38. package/dist/chunk-72EQECGT.cjs +0 -908
  39. package/dist/chunk-7AGYRWKW.cjs +0 -507
  40. package/dist/chunk-7LCYLPW2.cjs +0 -663
  41. package/dist/chunk-A7PIMZGU.js +0 -263
  42. package/dist/chunk-ATSKSYVE.cjs +0 -51683
  43. package/dist/chunk-B5TCIAPQ.cjs +0 -117
  44. package/dist/chunk-BF2235SI.cjs +0 -5714
  45. package/dist/chunk-BKIGPPVM.js +0 -629
  46. package/dist/chunk-BND3ST2K.cjs +0 -662
  47. package/dist/chunk-BU7VWW2K.js +0 -2522
  48. package/dist/chunk-BWFJEM5A.js +0 -5419
  49. package/dist/chunk-CAUCGUEA.cjs +0 -130
  50. package/dist/chunk-CBJSLA2E.cjs +0 -5423
  51. package/dist/chunk-CDPGV4DN.js +0 -114
  52. package/dist/chunk-CLYEIWA5.cjs +0 -408
  53. package/dist/chunk-CS2EMTGF.js +0 -1966
  54. package/dist/chunk-DMG7C4H2.js +0 -975
  55. package/dist/chunk-DXJQDCFL.js +0 -468
  56. package/dist/chunk-E3FWRT3Z.js +0 -608
  57. package/dist/chunk-E3UALNFA.js +0 -421
  58. package/dist/chunk-EONILVMF.js +0 -762
  59. package/dist/chunk-EQV4R3EV.cjs +0 -769
  60. package/dist/chunk-F3HH56EB.cjs +0 -5538
  61. package/dist/chunk-F4IULT7N.js +0 -1488
  62. package/dist/chunk-FF3Q7ADR.js +0 -380
  63. package/dist/chunk-FFKU7BTK.cjs +0 -1046
  64. package/dist/chunk-FHQVYCH2.js +0 -70
  65. package/dist/chunk-FSF7EQVA.cjs +0 -1974
  66. package/dist/chunk-G4VZTCIB.js +0 -659
  67. package/dist/chunk-G7CT3EMP.cjs +0 -1002
  68. package/dist/chunk-GGHSW2NN.js +0 -51334
  69. package/dist/chunk-GVUR45UF.cjs +0 -777
  70. package/dist/chunk-H5Z7NASB.js +0 -9662
  71. package/dist/chunk-HE7ULERA.cjs +0 -697
  72. package/dist/chunk-HJJLD366.js +0 -1169
  73. package/dist/chunk-HPS76H7Q.js +0 -309
  74. package/dist/chunk-HQUEA5R6.cjs +0 -424
  75. package/dist/chunk-HYNTS5CP.js +0 -422
  76. package/dist/chunk-I6XZ5DZF.cjs +0 -488
  77. package/dist/chunk-IBDG74G2.cjs +0 -1219
  78. package/dist/chunk-IFNQFCTM.js +0 -3098
  79. package/dist/chunk-IHOUYQIA.js +0 -406
  80. package/dist/chunk-ILRBGFVD.cjs +0 -72
  81. package/dist/chunk-IWI6J7FX.js +0 -421
  82. package/dist/chunk-K3JDKWGI.cjs +0 -270
  83. package/dist/chunk-K6EKD26I.js +0 -630
  84. package/dist/chunk-KCQ5NDYC.cjs +0 -3172
  85. package/dist/chunk-KED34ILP.js +0 -832
  86. package/dist/chunk-KSGXLT74.cjs +0 -457
  87. package/dist/chunk-L4G4RLXX.js +0 -767
  88. package/dist/chunk-LDP5OK6G.js +0 -1216
  89. package/dist/chunk-LGGRPKTV.cjs +0 -735
  90. package/dist/chunk-LK5IAVH6.cjs +0 -1173
  91. package/dist/chunk-LSW7P7ML.js +0 -3675
  92. package/dist/chunk-LXJ4667L.cjs +0 -3874
  93. package/dist/chunk-LZ266PCM.cjs +0 -4499
  94. package/dist/chunk-MD6KDHVE.cjs +0 -237
  95. package/dist/chunk-MEASWI2Y.js +0 -126
  96. package/dist/chunk-MPXBVFHQ.js +0 -768
  97. package/dist/chunk-N5FTS757.cjs +0 -415
  98. package/dist/chunk-NCUKG4SK.cjs +0 -3075
  99. package/dist/chunk-NDQNIJEH.js +0 -1715
  100. package/dist/chunk-NOZZ46QU.js +0 -168
  101. package/dist/chunk-OFKWH2IP.js +0 -449
  102. package/dist/chunk-PHENW4MQ.js +0 -65
  103. package/dist/chunk-PMGODDJA.cjs +0 -319
  104. package/dist/chunk-Q4QX3AET.cjs +0 -1505
  105. package/dist/chunk-Q56TT7IL.js +0 -483
  106. package/dist/chunk-Q5JT3YML.cjs +0 -129
  107. package/dist/chunk-Q5SJOGHQ.cjs +0 -4256
  108. package/dist/chunk-QGKNANZ3.js +0 -3071
  109. package/dist/chunk-QLEAOI3Q.cjs +0 -424
  110. package/dist/chunk-R7MA7QWV.js +0 -732
  111. package/dist/chunk-RVYPEYPX.js +0 -678
  112. package/dist/chunk-S2N5TNMA.js +0 -1855
  113. package/dist/chunk-S565K7NK.js +0 -752
  114. package/dist/chunk-SDAMZIRE.js +0 -765
  115. package/dist/chunk-T36DDXSF.js +0 -4250
  116. package/dist/chunk-T4NKMBDL.js +0 -5474
  117. package/dist/chunk-T7LEXZUZ.cjs +0 -2526
  118. package/dist/chunk-TEWCN33Y.js +0 -694
  119. package/dist/chunk-TQSZUOW5.cjs +0 -793
  120. package/dist/chunk-TSH3MSQU.cjs +0 -129
  121. package/dist/chunk-UERJ3YJV.js +0 -504
  122. package/dist/chunk-UPJBDCVF.js +0 -1395
  123. package/dist/chunk-V3NN3HPP.js +0 -4462
  124. package/dist/chunk-VJ3L7CHT.cjs +0 -169
  125. package/dist/chunk-WB4Z63GG.js +0 -229
  126. package/dist/chunk-WDW67DZB.cjs +0 -9728
  127. package/dist/chunk-WGMEAYBG.js +0 -126
  128. package/dist/chunk-X4ZF6CNE.cjs +0 -473
  129. package/dist/chunk-X6SEAXAX.cjs +0 -3681
  130. package/dist/chunk-XCWFGZAA.js +0 -1043
  131. package/dist/chunk-XD6IYDUX.js +0 -903
  132. package/dist/chunk-XG23EUQX.cjs +0 -1717
  133. package/dist/chunk-XRKWN5PL.cjs +0 -173
  134. package/dist/chunk-XUILI4KB.cjs +0 -430
  135. package/dist/chunk-XUTX5CBW.js +0 -126
  136. package/dist/chunk-XWPNTWDN.cjs +0 -755
  137. package/dist/chunk-XXINBTZK.cjs +0 -633
  138. package/dist/chunk-YCXFCXDS.js +0 -1868
  139. package/dist/chunk-YQK5JNFK.js +0 -3725
  140. package/dist/chunk-YYXH45E2.js +0 -426
  141. package/dist/chunk-Z34RLXRA.cjs +0 -612
  142. package/dist/chunk-ZP4D3CSX.cjs +0 -72
  143. package/dist/cli/holoscript-runner.cjs +0 -2259
  144. package/dist/cli/holoscript-runner.js +0 -2234
  145. package/dist/codebase/index.cjs +0 -336
  146. package/dist/codebase/index.js +0 -331
  147. package/dist/compiler/agent-inference.cjs +0 -28
  148. package/dist/compiler/agent-inference.js +0 -5
  149. package/dist/compiler/android-xr.cjs +0 -19
  150. package/dist/compiler/android-xr.js +0 -9
  151. package/dist/compiler/android.cjs +0 -20
  152. package/dist/compiler/android.js +0 -10
  153. package/dist/compiler/ar.cjs +0 -20
  154. package/dist/compiler/ar.js +0 -8
  155. package/dist/compiler/babylon.cjs +0 -17
  156. package/dist/compiler/babylon.js +0 -11
  157. package/dist/compiler/coco.cjs +0 -27
  158. package/dist/compiler/coco.js +0 -4
  159. package/dist/compiler/domain-block-utils.cjs +0 -602
  160. package/dist/compiler/domain-block-utils.js +0 -8
  161. package/dist/compiler/dtdl.cjs +0 -24
  162. package/dist/compiler/dtdl.js +0 -8
  163. package/dist/compiler/gltf-pipeline.cjs +0 -39
  164. package/dist/compiler/gltf-pipeline.js +0 -4
  165. package/dist/compiler/godot.cjs +0 -15
  166. package/dist/compiler/godot.js +0 -9
  167. package/dist/compiler/incremental.cjs +0 -29
  168. package/dist/compiler/incremental.js +0 -4
  169. package/dist/compiler/index.cjs +0 -2578
  170. package/dist/compiler/index.js +0 -2383
  171. package/dist/compiler/ios.cjs +0 -20
  172. package/dist/compiler/ios.js +0 -10
  173. package/dist/compiler/multi-layer.cjs +0 -20
  174. package/dist/compiler/multi-layer.js +0 -11
  175. package/dist/compiler/nodetoy.cjs +0 -23
  176. package/dist/compiler/nodetoy.js +0 -4
  177. package/dist/compiler/openxr.cjs +0 -15
  178. package/dist/compiler/openxr.js +0 -9
  179. package/dist/compiler/playcanvas.cjs +0 -16
  180. package/dist/compiler/playcanvas.js +0 -10
  181. package/dist/compiler/r3f.cjs +0 -34
  182. package/dist/compiler/r3f.js +0 -12
  183. package/dist/compiler/remotion.cjs +0 -23
  184. package/dist/compiler/remotion.js +0 -4
  185. package/dist/compiler/reproducibility.cjs +0 -39
  186. package/dist/compiler/reproducibility.js +0 -4
  187. package/dist/compiler/sdf.cjs +0 -21
  188. package/dist/compiler/sdf.js +0 -9
  189. package/dist/compiler/semantic-scene.cjs +0 -31
  190. package/dist/compiler/semantic-scene.js +0 -4
  191. package/dist/compiler/state.cjs +0 -17
  192. package/dist/compiler/state.js +0 -7
  193. package/dist/compiler/trait-composition.cjs +0 -26
  194. package/dist/compiler/trait-composition.js +0 -5
  195. package/dist/compiler/unity.cjs +0 -15
  196. package/dist/compiler/unity.js +0 -9
  197. package/dist/compiler/unreal.cjs +0 -19
  198. package/dist/compiler/unreal.js +0 -9
  199. package/dist/compiler/urdf.cjs +0 -45
  200. package/dist/compiler/urdf.js +0 -9
  201. package/dist/compiler/usd-physics.cjs +0 -23
  202. package/dist/compiler/usd-physics.js +0 -6
  203. package/dist/compiler/visionos.cjs +0 -15
  204. package/dist/compiler/visionos.js +0 -9
  205. package/dist/compiler/vrchat.cjs +0 -19
  206. package/dist/compiler/vrchat.js +0 -9
  207. package/dist/compiler/vrr.cjs +0 -21
  208. package/dist/compiler/vrr.js +0 -9
  209. package/dist/compiler/wasm.cjs +0 -33
  210. package/dist/compiler/wasm.js +0 -9
  211. package/dist/compiler/webgpu.cjs +0 -15
  212. package/dist/compiler/webgpu.js +0 -9
  213. package/dist/debugger.cjs +0 -21
  214. package/dist/debugger.js +0 -8
  215. package/dist/entries/interop.cjs +0 -62
  216. package/dist/entries/interop.js +0 -5
  217. package/dist/entries/scripting.cjs +0 -68
  218. package/dist/entries/scripting.js +0 -11
  219. package/dist/index.cjs +0 -40921
  220. package/dist/index.js +0 -37763
  221. package/dist/math/vec3.cjs +0 -57
  222. package/dist/math/vec3.js +0 -4
  223. package/dist/ml-dsa-PHCWUBPX.cjs +0 -1178
  224. package/dist/ml-dsa-WYLJHJO6.js +0 -1178
  225. package/dist/parser.cjs +0 -27
  226. package/dist/parser.js +0 -10
  227. package/dist/playwright-5OSAPTNH.js +0 -98660
  228. package/dist/playwright-RL6GY4F7.cjs +0 -98673
  229. package/dist/runtime.cjs +0 -16
  230. package/dist/runtime.js +0 -7
  231. package/dist/storage/index.cjs +0 -37
  232. package/dist/storage/index.js +0 -4
  233. package/dist/traits/index.cjs +0 -14649
  234. package/dist/traits/index.js +0 -12243
  235. package/dist/type-checker.cjs +0 -18
  236. package/dist/type-checker.js +0 -5
@@ -1,697 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkLXJ4667L_cjs = require('./chunk-LXJ4667L.cjs');
4
- var chunkBF2235SI_cjs = require('./chunk-BF2235SI.cjs');
5
- var chunk3SAK5KFL_cjs = require('./chunk-3SAK5KFL.cjs');
6
- var platform = require('@holoscript/platform');
7
-
8
- // src/compiler/UnityCompiler.ts
9
- var UnityCompiler_exports = {};
10
- chunk3SAK5KFL_cjs.__export(UnityCompiler_exports, {
11
- UnityCompiler: () => exports.UnityCompiler
12
- });
13
- exports.UnityCompiler = void 0;
14
- var init_UnityCompiler = chunk3SAK5KFL_cjs.__esm({
15
- "src/compiler/UnityCompiler.ts"() {
16
- chunkBF2235SI_cjs.init_CompilerBase();
17
- chunkLXJ4667L_cjs.init_DomainBlockCompilerMixin();
18
- exports.UnityCompiler = class extends chunkBF2235SI_cjs.CompilerBase {
19
- constructor(options = {}) {
20
- super();
21
- this.compilerName = "UnityCompiler";
22
- this.lines = [];
23
- this.indentLevel = 0;
24
- this.options = {
25
- namespace: options.namespace || "HoloScene",
26
- className: options.className || "GeneratedScene",
27
- useURP: options.useURP ?? true,
28
- indent: options.indent || " "
29
- };
30
- }
31
- getRequiredCapability() {
32
- return platform.ANSCapabilityPath.UNITY;
33
- }
34
- compile(composition, agentToken, outputPath) {
35
- this.validateCompilerAccess(agentToken, outputPath);
36
- this.lines = [];
37
- this.indentLevel = 0;
38
- this.emit("// Auto-generated by HoloScript UnityCompiler");
39
- this.emit(
40
- `// Source: composition "${this.escapeStringValue(composition.name, "CSharp")}"`
41
- );
42
- this.emit("// Do not edit manually \u2014 regenerate from .holo source");
43
- this.emit("");
44
- this.emit("using UnityEngine;");
45
- this.emit("using UnityEngine.UI;");
46
- if (composition.timelines?.length) this.emit("using System.Collections;");
47
- this.emit("");
48
- this.emit(`namespace ${this.options.namespace}`);
49
- this.emit("{");
50
- this.indentLevel++;
51
- this.emit(`public class ${this.options.className} : MonoBehaviour`);
52
- this.emit("{");
53
- this.indentLevel++;
54
- if (composition.state) {
55
- this.emit("// === State ===");
56
- for (const prop of composition.state.properties) {
57
- const csType = this.toCSharpType(prop.value);
58
- const csVal = this.toCSharpValue(prop.value);
59
- this.emit(
60
- `private ${csType} ${this.escapeStringValue(prop.key, "CSharp")} = ${csVal};`
61
- );
62
- }
63
- this.emit("");
64
- }
65
- this.emit("private void Awake()");
66
- this.emit("{");
67
- this.indentLevel++;
68
- if (composition.environment) {
69
- this.compileEnvironment(composition.environment);
70
- }
71
- if (composition.lights) {
72
- for (const light of composition.lights) {
73
- this.compileLight(light);
74
- }
75
- }
76
- if (composition.camera) {
77
- this.compileCamera(composition.camera);
78
- }
79
- if (composition.objects) {
80
- for (const obj of composition.objects) {
81
- this.compileObject(obj, "transform");
82
- }
83
- }
84
- if (composition.spatialGroups) {
85
- for (const group of composition.spatialGroups) {
86
- this.compileSpatialGroup(group, "transform");
87
- }
88
- }
89
- if (composition.audio) {
90
- for (const audio of composition.audio) {
91
- this.compileAudio(audio);
92
- }
93
- }
94
- if (composition.zones) {
95
- for (const zone of composition.zones) {
96
- this.compileZone(zone);
97
- }
98
- }
99
- if (composition.timelines) {
100
- for (const tl of composition.timelines) {
101
- if (tl.autoplay) {
102
- this.emit(`StartCoroutine(${this.sanitizeName(tl.name)}Routine());`);
103
- }
104
- }
105
- }
106
- this.indentLevel--;
107
- this.emit("}");
108
- this.emit("");
109
- if (composition.timelines) {
110
- for (const tl of composition.timelines) {
111
- this.compileTimeline(tl);
112
- }
113
- }
114
- if (composition.effects) {
115
- this.compileEffects(composition.effects);
116
- }
117
- if (composition.transitions) {
118
- for (const tr of composition.transitions) {
119
- this.compileTransition(tr);
120
- }
121
- }
122
- if (composition.ui) {
123
- this.compileUI(composition.ui);
124
- }
125
- this.compileDomainBlocks(composition);
126
- this.indentLevel--;
127
- this.emit("}");
128
- this.indentLevel--;
129
- this.emit("}");
130
- return this.lines.join("\n");
131
- }
132
- compileDomainBlocks(composition) {
133
- const domainBlocks = composition.domainBlocks ?? [];
134
- if (domainBlocks.length === 0) return;
135
- this.emit("");
136
- this.emit("// === v4.2 Domain Blocks ===");
137
- let blockIdx = 0;
138
- const compiled = chunkLXJ4667L_cjs.compileDomainBlocks(
139
- domainBlocks,
140
- {
141
- material: (block) => {
142
- const mat = chunkLXJ4667L_cjs.compileMaterialBlock(block);
143
- const prefix = `db${blockIdx++}`;
144
- return chunkLXJ4667L_cjs.materialToUnity(mat, prefix);
145
- },
146
- physics: (block) => {
147
- const phys = chunkLXJ4667L_cjs.compilePhysicsBlock(block);
148
- const prefix = `db${blockIdx++}`;
149
- return chunkLXJ4667L_cjs.physicsToUnity(phys, prefix);
150
- },
151
- vfx: (block) => {
152
- const ps = chunkLXJ4667L_cjs.compileParticleBlock(block);
153
- const prefix = `db${blockIdx++}`;
154
- return chunkLXJ4667L_cjs.particlesToUnity(ps, prefix);
155
- },
156
- postfx: (block) => {
157
- const pp = chunkLXJ4667L_cjs.compilePostProcessingBlock(block);
158
- return chunkLXJ4667L_cjs.postProcessingToUnity(pp);
159
- },
160
- audio: (block) => {
161
- const audio = chunkLXJ4667L_cjs.compileAudioSourceBlock(block);
162
- const prefix = `db${blockIdx++}`;
163
- return chunkLXJ4667L_cjs.audioSourceToUnity(audio, prefix);
164
- },
165
- weather: (block) => {
166
- const weather = chunkLXJ4667L_cjs.compileWeatherBlock(block);
167
- return chunkLXJ4667L_cjs.weatherToUnity(weather);
168
- },
169
- narrative: (block) => {
170
- const narr = chunkLXJ4667L_cjs.compileNarrativeBlock(block);
171
- return chunkLXJ4667L_cjs.narrativeToUnity(narr);
172
- },
173
- payment: (block) => {
174
- const pay = chunkLXJ4667L_cjs.compilePaymentBlock(block);
175
- return chunkLXJ4667L_cjs.paymentToUnity(pay);
176
- },
177
- healthcare: (block) => {
178
- const h = chunkLXJ4667L_cjs.compileHealthcareBlock(block);
179
- return chunkLXJ4667L_cjs.healthcareToUnity(h);
180
- },
181
- robotics: (block) => {
182
- const r = chunkLXJ4667L_cjs.compileRoboticsBlock(block);
183
- return chunkLXJ4667L_cjs.roboticsToUnity(r);
184
- },
185
- iot: (block) => chunkLXJ4667L_cjs.iotToUnity(chunkLXJ4667L_cjs.compileIoTBlock(block)),
186
- dataviz: (block) => chunkLXJ4667L_cjs.datavizToUnity(chunkLXJ4667L_cjs.compileDataVizBlock(block)),
187
- education: (block) => chunkLXJ4667L_cjs.educationToUnity(chunkLXJ4667L_cjs.compileEducationBlock(block)),
188
- music: (block) => chunkLXJ4667L_cjs.musicToUnity(chunkLXJ4667L_cjs.compileMusicBlock(block)),
189
- architecture: (block) => chunkLXJ4667L_cjs.architectureToUnity(chunkLXJ4667L_cjs.compileArchitectureBlock(block)),
190
- web3: (block) => chunkLXJ4667L_cjs.web3ToUnity(chunkLXJ4667L_cjs.compileWeb3Block(block)),
191
- procedural: (block) => chunkLXJ4667L_cjs.proceduralToUnity(chunkLXJ4667L_cjs.compileProceduralBlock(block)),
192
- rendering: (block) => chunkLXJ4667L_cjs.renderingToUnity(chunkLXJ4667L_cjs.compileRenderingBlock(block)),
193
- navigation: (block) => chunkLXJ4667L_cjs.navigationToUnity(chunkLXJ4667L_cjs.compileNavigationBlock(block)),
194
- input: (block) => chunkLXJ4667L_cjs.inputToUnity(chunkLXJ4667L_cjs.compileInputBlock(block))
195
- },
196
- (block) => `// Domain block: ${block.domain}/${block.keyword} "${this.escapeStringValue(block.name, "CSharp")}"`
197
- );
198
- for (const line of compiled) {
199
- for (const l of line.split("\n")) {
200
- this.emit(l);
201
- }
202
- }
203
- }
204
- compileEnvironment(env) {
205
- this.emit("// === Environment ===");
206
- for (const prop of env.properties) {
207
- if (prop.key === "preset" || prop.key === "skybox") {
208
- this.emit(`RenderSettings.skybox = Resources.Load<Material>("Skybox/${prop.value}");`);
209
- } else if (prop.key === "fog" && typeof prop.value === "object") {
210
- const fog = prop.value;
211
- this.emit("RenderSettings.fog = true;");
212
- if (fog.color) this.emit(`RenderSettings.fogColor = ${this.toColor(fog.color)};`);
213
- if (fog.near !== void 0) this.emit(`RenderSettings.fogStartDistance = ${fog.near}f;`);
214
- if (fog.far !== void 0) this.emit(`RenderSettings.fogEndDistance = ${fog.far}f;`);
215
- } else if (prop.key === "ambient_light") {
216
- this.emit(`RenderSettings.ambientIntensity = ${prop.value}f;`);
217
- }
218
- }
219
- this.emit("");
220
- }
221
- compileLight(light) {
222
- const varName = this.sanitizeName(light.name);
223
- this.emit(`// Light: ${this.escapeStringValue(light.name, "CSharp")}`);
224
- this.emit(
225
- `var ${varName}GO = new GameObject("${this.escapeStringValue(light.name, "CSharp")}");`
226
- );
227
- this.emit(`${varName}GO.transform.SetParent(transform);`);
228
- this.emit(`var ${varName} = ${varName}GO.AddComponent<Light>();`);
229
- const typeMap = {
230
- directional: "LightType.Directional",
231
- point: "LightType.Point",
232
- spot: "LightType.Spot",
233
- area: "LightType.Area"
234
- };
235
- this.emit(`${varName}.type = ${typeMap[light.lightType] || "LightType.Directional"};`);
236
- for (const prop of light.properties) {
237
- if (prop.key === "color") {
238
- this.emit(`${varName}.color = ${this.toColor(prop.value)};`);
239
- } else if (prop.key === "intensity") {
240
- this.emit(`${varName}.intensity = ${prop.value}f;`);
241
- } else if (prop.key === "position" && Array.isArray(prop.value)) {
242
- this.emit(`${varName}GO.transform.position = ${this.toVector3(prop.value)};`);
243
- } else if (prop.key === "cast_shadow" || prop.key === "castShadow") {
244
- this.emit(
245
- `${varName}.shadows = ${prop.value ? "LightShadows.Soft" : "LightShadows.None"};`
246
- );
247
- } else if (prop.key === "angle") {
248
- this.emit(`${varName}.spotAngle = ${prop.value * (180 / Math.PI)}f;`);
249
- } else if (prop.key === "distance") {
250
- this.emit(`${varName}.range = ${prop.value}f;`);
251
- }
252
- }
253
- this.emit("");
254
- }
255
- compileCamera(camera) {
256
- this.emit("// === Camera ===");
257
- this.emit("var cam = Camera.main;");
258
- this.emit(`cam.fieldOfView = ${this.findProp(camera.properties, "fov") || 60}f;`);
259
- const pos = this.findProp(camera.properties, "position");
260
- if (pos) this.emit(`cam.transform.position = ${this.toVector3(pos)};`);
261
- const lookAt = this.findProp(camera.properties, "look_at") || this.findProp(camera.properties, "lookAt");
262
- if (lookAt) this.emit(`cam.transform.LookAt(${this.toVector3(lookAt)});`);
263
- const near = this.findProp(camera.properties, "near");
264
- if (near) this.emit(`cam.nearClipPlane = ${near}f;`);
265
- const far = this.findProp(camera.properties, "far");
266
- if (far) this.emit(`cam.farClipPlane = ${far}f;`);
267
- this.emit("");
268
- }
269
- compileObject(obj, parentVar) {
270
- const varName = this.sanitizeName(obj.name);
271
- const meshType = this.findObjProp(obj, "geometry") || this.findObjProp(obj, "mesh") || this.findObjProp(obj, "type") || "cube";
272
- const isText = meshType === "text";
273
- const isSparkles = meshType === "sparkles";
274
- const isModel = meshType === "model" || !!this.findObjProp(obj, "model") || !!this.findObjProp(obj, "src") || !!this.findObjProp(obj, "source");
275
- this.emit(`// Object: ${this.escapeStringValue(obj.name, "CSharp")}`);
276
- if (isText) {
277
- this.emit(
278
- `var ${varName}GO = new GameObject("${this.escapeStringValue(obj.name, "CSharp")}");`
279
- );
280
- this.emit(`${varName}GO.transform.SetParent(${parentVar});`);
281
- this.emit(`var ${varName}TM = ${varName}GO.AddComponent<TextMesh>();`);
282
- const text = this.findObjProp(obj, "text");
283
- if (text) this.emit(`${varName}TM.text = "${text}";`);
284
- const fontSize = this.findObjProp(obj, "font_size");
285
- if (fontSize) this.emit(`${varName}TM.fontSize = ${Math.round(fontSize * 100)};`);
286
- const color = this.findObjProp(obj, "color");
287
- if (color) this.emit(`${varName}TM.color = ${this.toColor(color)};`);
288
- } else if (isModel) {
289
- const src = this.findObjProp(obj, "model") || this.findObjProp(obj, "src") || this.findObjProp(obj, "source");
290
- if (src) {
291
- this.emit(`var ${varName}GO = Instantiate(Resources.Load<GameObject>("Models/${src}"));`);
292
- } else {
293
- this.emit(`// WARNING: geometry "model" without source \u2014 placeholder cube`);
294
- this.emit(`var ${varName}GO = GameObject.CreatePrimitive(PrimitiveType.Cube);`);
295
- }
296
- this.emit(`${varName}GO.name = "${this.escapeStringValue(obj.name, "CSharp")}";`);
297
- this.emit(`${varName}GO.transform.SetParent(${parentVar});`);
298
- } else if (isSparkles) {
299
- this.emit(
300
- `// Sparkles: use ParticleSystem for "${this.escapeStringValue(obj.name, "CSharp")}"`
301
- );
302
- this.emit(
303
- `var ${varName}GO = new GameObject("${this.escapeStringValue(obj.name, "CSharp")}");`
304
- );
305
- this.emit(`${varName}GO.transform.SetParent(${parentVar});`);
306
- this.emit(`${varName}GO.AddComponent<ParticleSystem>();`);
307
- } else {
308
- const primitiveMap = {
309
- cube: "PrimitiveType.Cube",
310
- box: "PrimitiveType.Cube",
311
- sphere: "PrimitiveType.Sphere",
312
- cylinder: "PrimitiveType.Cylinder",
313
- plane: "PrimitiveType.Plane",
314
- capsule: "PrimitiveType.Capsule"
315
- };
316
- const primitive = primitiveMap[meshType] || "PrimitiveType.Cube";
317
- this.emit(`var ${varName}GO = GameObject.CreatePrimitive(${primitive});`);
318
- this.emit(`${varName}GO.name = "${this.escapeStringValue(obj.name, "CSharp")}";`);
319
- this.emit(`${varName}GO.transform.SetParent(${parentVar});`);
320
- }
321
- const pos = this.findObjProp(obj, "position");
322
- if (pos) this.emit(`${varName}GO.transform.localPosition = ${this.toVector3(pos)};`);
323
- const rot = this.findObjProp(obj, "rotation");
324
- if (rot) this.emit(`${varName}GO.transform.localEulerAngles = ${this.toVector3(rot)};`);
325
- const scale = this.findObjProp(obj, "scale");
326
- if (scale) this.emit(`${varName}GO.transform.localScale = ${this.toVector3(scale)};`);
327
- const size = this.findObjProp(obj, "size");
328
- if (size && !isText) {
329
- if (Array.isArray(size)) {
330
- this.emit(`${varName}GO.transform.localScale = ${this.toVector3(size)};`);
331
- } else {
332
- this.emit(`${varName}GO.transform.localScale = Vector3.one * ${size}f;`);
333
- }
334
- }
335
- const material = this.findObjProp(obj, "material");
336
- if (material && typeof material === "object" && !isText && !isModel) {
337
- this.emit(`var ${varName}Mat = ${varName}GO.GetComponent<Renderer>().material;`);
338
- const mat = material;
339
- if (mat.color) this.emit(`${varName}Mat.color = ${this.toColor(mat.color)};`);
340
- if (mat.roughness !== void 0)
341
- this.emit(`${varName}Mat.SetFloat("_Smoothness", ${1 - mat.roughness}f);`);
342
- if (mat.metalness !== void 0)
343
- this.emit(`${varName}Mat.SetFloat("_Metallic", ${mat.metalness}f);`);
344
- if (mat.emissive) {
345
- this.emit(`${varName}Mat.EnableKeyword("_EMISSION");`);
346
- this.emit(`${varName}Mat.SetColor("_EmissionColor", ${this.toColor(mat.emissive)});`);
347
- }
348
- }
349
- if (obj.traits) {
350
- for (const trait of obj.traits) {
351
- if (trait.name === "collidable") {
352
- this.emit(`// Collider already present from primitive`);
353
- } else if (trait.name === "physics" || trait.name === "grabbable") {
354
- this.emit(`var ${varName}RB = ${varName}GO.AddComponent<Rigidbody>();`);
355
- if (trait.config?.mass) this.emit(`${varName}RB.mass = ${trait.config.mass}f;`);
356
- } else if (trait.name === "portal") {
357
- this.emit(
358
- `// Portal: "${trait.config?.destination}" \u2014 implement via SceneManager.LoadScene()`
359
- );
360
- } else if (trait.name === "plane_detection") {
361
- this.emit(`// @plane_detection \u2014 AR Foundation: ARPlaneManager`);
362
- this.emit(`// ${varName}GO.AddComponent<UnityEngine.XR.ARFoundation.ARPlaneManager>();`);
363
- } else if (trait.name === "mesh_detection") {
364
- this.emit(`// @mesh_detection \u2014 AR Foundation: ARMeshManager`);
365
- } else if (trait.name === "anchor") {
366
- this.emit(`// @anchor \u2014 AR Foundation: ARAnchorManager`);
367
- } else if (trait.name === "persistent_anchor" || trait.name === "shared_anchor") {
368
- this.emit(
369
- `// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 Azure Spatial Anchors or AR Foundation`
370
- );
371
- } else if (trait.name === "occlusion") {
372
- this.emit(`// @occlusion \u2014 AR Foundation: AROcclusionManager`);
373
- } else if (trait.name === "light_estimation") {
374
- this.emit(
375
- `// @light_estimation \u2014 AR Foundation: ARCameraManager.requestedLightEstimation`
376
- );
377
- } else if (trait.name === "geospatial" || trait.name === "geospatial_anchor" || trait.name === "terrain_anchor" || trait.name === "rooftop_anchor") {
378
- this.emit(
379
- `// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 ARCore Geospatial API`
380
- );
381
- } else if (trait.name === "cloth") {
382
- this.emit(`var ${varName}Cloth = ${varName}GO.AddComponent<Cloth>();`);
383
- if (trait.config?.stiffness)
384
- this.emit(`${varName}Cloth.stretchingStiffness = ${trait.config.stiffness}f;`);
385
- if (trait.config?.damping)
386
- this.emit(`${varName}Cloth.damping = ${trait.config.damping}f;`);
387
- } else if (trait.name === "wind") {
388
- this.emit(`var ${varName}Wind = ${varName}GO.AddComponent<WindZone>();`);
389
- if (trait.config?.strength)
390
- this.emit(`${varName}Wind.windMain = ${trait.config.strength}f;`);
391
- if (trait.config?.turbulence)
392
- this.emit(`${varName}Wind.windTurbulence = ${trait.config.turbulence}f;`);
393
- } else if (trait.name === "fluid" || trait.name === "soft_body" || trait.name === "rope" || trait.name === "chain" || trait.name === "buoyancy" || trait.name === "destruction") {
394
- this.emit(
395
- `// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 custom physics: ${JSON.stringify(trait.config || {})}`
396
- );
397
- } else if (trait.name === "reverb_zone") {
398
- this.emit(`var ${varName}Reverb = ${varName}GO.AddComponent<AudioReverbZone>();`);
399
- if (trait.config?.decay_time)
400
- this.emit(`${varName}Reverb.decayTime = ${trait.config.decay_time}f;`);
401
- } else if (trait.name === "audio_occlusion") {
402
- this.emit(`${varName}GO.AddComponent<AudioLowPassFilter>();`);
403
- this.emit(`// @audio_occlusion \u2014 raycast-based low-pass filter`);
404
- } else if (trait.name === "ambisonics" || trait.name === "hrtf" || trait.name === "audio_portal" || trait.name === "audio_material" || trait.name === "head_tracked_audio") {
405
- this.emit(
406
- `// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 spatial audio: ${JSON.stringify(trait.config || {})}`
407
- );
408
- } else if (trait.name === "gaussian_splat" || trait.name === "nerf" || trait.name === "volumetric_video" || trait.name === "point_cloud" || trait.name === "photogrammetry") {
409
- this.emit(
410
- `// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 volumetric renderer: ${JSON.stringify(trait.config || {})}`
411
- );
412
- } else if (trait.name === "eye_tracking") {
413
- this.emit(`// @eye_tracking \u2014 XR Interaction Toolkit: XREyeInteractor`);
414
- } else if (trait.name === "hand_tracking") {
415
- this.emit(`// @hand_tracking \u2014 XR Hands: XRHandTrackingSubsystem`);
416
- } else if (trait.name === "body_tracking") {
417
- this.emit(`// @body_tracking \u2014 XR Body Tracking subsystem`);
418
- } else if (trait.name === "face_tracking") {
419
- this.emit(`// @face_tracking \u2014 AR Foundation: ARFaceManager`);
420
- } else if (trait.name === "accessible") {
421
- this.emit(
422
- `// @accessible(role: "${trait.config?.role || "generic"}") \u2014 Unity Accessibility`
423
- );
424
- } else if (trait.name === "spatial_persona" || trait.name === "shareplay") {
425
- this.emit(
426
- `// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 visionOS-specific; use Mirror/Photon for Unity multiplayer`
427
- );
428
- } else if (trait.name === "object_tracking") {
429
- this.emit(`// @object_tracking \u2014 AR Foundation: ARTrackedObjectManager`);
430
- } else if (trait.name === "scene_reconstruction") {
431
- this.emit(`// @scene_reconstruction \u2014 AR Foundation: ARMeshManager`);
432
- } else if (trait.name === "eye_tracked") {
433
- this.emit(`// @eye_tracked \u2014 XR Interaction Toolkit: XREyeInteractor`);
434
- } else if (trait.name === "eye_hand_fusion") {
435
- this.emit(`// @eye_hand_fusion \u2014 combine XREyeInteractor + XRHandInteractorController`);
436
- } else if (trait.name === "controlnet") {
437
- const model = trait.config?.model || "canny";
438
- this.emit(`// @controlnet(model: "${model}") \u2014 route to inference API or Unity Sentis`);
439
- } else if (trait.name === "ai_texture_gen") {
440
- const style = trait.config?.style || "photorealistic";
441
- this.emit(`// @ai_texture_gen(style: "${style}") \u2014 Unity Sentis or external API`);
442
- } else if (trait.name === "diffusion_realtime") {
443
- this.emit(`// @diffusion_realtime \u2014 Unity Sentis real-time diffusion pipeline`);
444
- } else if (trait.name === "ai_upscaling") {
445
- const factor = trait.config?.factor || 2;
446
- this.emit(`// @ai_upscaling(${factor}x) \u2014 Unity Sentis super-resolution model`);
447
- } else if (trait.name === "ai_inpainting") {
448
- this.emit(`// @ai_inpainting \u2014 Unity Sentis or API-based inpainting`);
449
- } else if (trait.name === "neural_link" || trait.name === "neural_forge") {
450
- this.emit(
451
- `// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 ${JSON.stringify(trait.config || {})}`
452
- );
453
- } else if (trait.name === "embedding_search" || trait.name === "ai_npc_brain" || trait.name === "vector_db") {
454
- this.emit(
455
- `// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 AI knowledge: use external service or on-device model`
456
- );
457
- } else if (trait.name === "vision" || trait.name === "ai_vision") {
458
- this.emit(
459
- `// @${this.escapeStringValue(trait.name, "CSharp")} \u2014 Unity Barracuda / Sentis vision model`
460
- );
461
- } else if (trait.name === "spatial_awareness") {
462
- this.emit(`// @spatial_awareness \u2014 AR Foundation scene understanding`);
463
- } else if (trait.name === "neural_animation") {
464
- this.emit(`// @neural_animation \u2014 Motion Matching (com.unity.animation.rigging)`);
465
- } else {
466
- this.emit(
467
- `// @${this.escapeStringValue(trait.name, "CSharp")}: ${JSON.stringify(trait.config || {})}`
468
- );
469
- }
470
- }
471
- }
472
- if (obj.children) {
473
- for (const child of obj.children) {
474
- this.compileObject(child, `${varName}GO.transform`);
475
- }
476
- }
477
- this.emit("");
478
- }
479
- compileSpatialGroup(group, parentVar) {
480
- const varName = this.sanitizeName(group.name);
481
- this.emit(`// Spatial Group: ${this.escapeStringValue(group.name, "CSharp")}`);
482
- this.emit(
483
- `var ${varName}GO = new GameObject("${this.escapeStringValue(group.name, "CSharp")}");`
484
- );
485
- this.emit(`${varName}GO.transform.SetParent(${parentVar});`);
486
- for (const prop of group.properties) {
487
- if (prop.key === "position" && Array.isArray(prop.value)) {
488
- this.emit(`${varName}GO.transform.localPosition = ${this.toVector3(prop.value)};`);
489
- }
490
- }
491
- for (const obj of group.objects) {
492
- this.compileObject(obj, `${varName}GO.transform`);
493
- }
494
- if (group.groups) {
495
- for (const sub of group.groups) {
496
- this.compileSpatialGroup(sub, `${varName}GO.transform`);
497
- }
498
- }
499
- this.emit("");
500
- }
501
- compileAudio(audio) {
502
- const varName = this.sanitizeName(audio.name);
503
- this.emit(`// Audio: ${this.escapeStringValue(audio.name, "CSharp")}`);
504
- this.emit(
505
- `var ${varName}GO = new GameObject("${this.escapeStringValue(audio.name, "CSharp")}");`
506
- );
507
- this.emit(`${varName}GO.transform.SetParent(transform);`);
508
- this.emit(`var ${varName}AS = ${varName}GO.AddComponent<AudioSource>();`);
509
- for (const prop of audio.properties) {
510
- if (prop.key === "src" || prop.key === "source") {
511
- this.emit(`${varName}AS.clip = Resources.Load<AudioClip>("Audio/${prop.value}");`);
512
- } else if (prop.key === "volume") {
513
- this.emit(`${varName}AS.volume = ${prop.value}f;`);
514
- } else if (prop.key === "loop") {
515
- this.emit(`${varName}AS.loop = ${prop.value};`);
516
- } else if (prop.key === "spatial") {
517
- this.emit(`${varName}AS.spatialBlend = ${prop.value ? "1.0f" : "0.0f"};`);
518
- } else if (prop.key === "position" && Array.isArray(prop.value)) {
519
- this.emit(`${varName}GO.transform.position = ${this.toVector3(prop.value)};`);
520
- } else if (prop.key === "distance") {
521
- this.emit(`${varName}AS.maxDistance = ${prop.value}f;`);
522
- }
523
- }
524
- this.emit(`${varName}AS.Play();`);
525
- this.emit("");
526
- }
527
- compileZone(zone) {
528
- const varName = this.sanitizeName(zone.name);
529
- this.emit(`// Zone: ${this.escapeStringValue(zone.name, "CSharp")}`);
530
- this.emit(
531
- `var ${varName}GO = new GameObject("${this.escapeStringValue(zone.name, "CSharp")}");`
532
- );
533
- this.emit(`${varName}GO.transform.SetParent(transform);`);
534
- for (const prop of zone.properties) {
535
- if (prop.key === "position" && Array.isArray(prop.value)) {
536
- this.emit(`${varName}GO.transform.position = ${this.toVector3(prop.value)};`);
537
- } else if (prop.key === "shape" && prop.value === "box") {
538
- this.emit(`var ${varName}Col = ${varName}GO.AddComponent<BoxCollider>();`);
539
- this.emit(`${varName}Col.isTrigger = true;`);
540
- } else if (prop.key === "shape" && prop.value === "sphere") {
541
- this.emit(`var ${varName}Col = ${varName}GO.AddComponent<SphereCollider>();`);
542
- this.emit(`${varName}Col.isTrigger = true;`);
543
- } else if (prop.key === "size" && Array.isArray(prop.value)) {
544
- this.emit(
545
- `${varName}GO.GetComponent<Collider>().bounds.size == ${this.toVector3(prop.value)}; // Set via scale`
546
- );
547
- } else if (prop.key === "radius") {
548
- this.emit(`${varName}GO.GetComponent<SphereCollider>().radius = ${prop.value}f;`);
549
- }
550
- }
551
- if (zone.handlers?.length) {
552
- this.emit(
553
- `// Zone handlers: ${zone.handlers.map((h) => h.event).join(", ")} \u2014 implement via OnTriggerEnter/Exit`
554
- );
555
- }
556
- this.emit("");
557
- }
558
- compileTimeline(timeline) {
559
- const varName = this.sanitizeName(timeline.name);
560
- this.emit(`private IEnumerator ${varName}Routine()`);
561
- this.emit("{");
562
- this.indentLevel++;
563
- let lastTime = 0;
564
- for (const entry of timeline.entries) {
565
- const delay = entry.time - lastTime;
566
- if (delay > 0) {
567
- this.emit(`yield return new WaitForSeconds(${delay}f);`);
568
- }
569
- if (entry.action.kind === "animate") {
570
- this.emit(`// Animate "${entry.action.target}" \u2014 use DOTween or AnimationCurve`);
571
- const props = entry.action.properties;
572
- for (const [key, value] of Object.entries(props)) {
573
- this.emit(`// ${key}: ${JSON.stringify(value)}`);
574
- }
575
- } else if (entry.action.kind === "emit") {
576
- this.emit(`// Emit event: "${entry.action.event}"`);
577
- } else if (entry.action.kind === "call") {
578
- this.emit(`// Call: ${entry.action.method}(${entry.action.args?.join(", ") || ""})`);
579
- }
580
- lastTime = entry.time;
581
- }
582
- if (timeline.loop) {
583
- this.emit(`StartCoroutine(${varName}Routine()); // loop`);
584
- }
585
- this.indentLevel--;
586
- this.emit("}");
587
- this.emit("");
588
- }
589
- compileEffects(effects) {
590
- this.emit("// === Post-Processing (configure via URP Volume) ===");
591
- for (const effect of effects.effects) {
592
- this.emit(`// Effect: ${effect.effectType} \u2014 ${JSON.stringify(effect.properties)}`);
593
- }
594
- this.emit("");
595
- }
596
- compileTransition(tr) {
597
- const varName = this.sanitizeName(tr.name);
598
- this.emit(`public void ${varName}()`);
599
- this.emit("{");
600
- this.indentLevel++;
601
- for (const prop of tr.properties) {
602
- if (prop.key === "target") {
603
- this.emit(`// Load scene: "${prop.value}"`);
604
- this.emit(`UnityEngine.SceneManagement.SceneManager.LoadScene("${prop.value}");`);
605
- } else if (prop.key === "effect") {
606
- this.emit(`// Transition effect: ${prop.value}`);
607
- } else if (prop.key === "duration") {
608
- this.emit(`// Duration: ${prop.value}s`);
609
- }
610
- }
611
- this.indentLevel--;
612
- this.emit("}");
613
- this.emit("");
614
- }
615
- compileUI(ui) {
616
- this.emit("// === UI Setup ===");
617
- this.emit("// Create Canvas for HUD overlay");
618
- this.emit('var canvasGO = new GameObject("HoloUI");');
619
- this.emit("canvasGO.transform.SetParent(transform);");
620
- this.emit("var canvas = canvasGO.AddComponent<Canvas>();");
621
- this.emit("canvas.renderMode = RenderMode.ScreenSpaceOverlay;");
622
- this.emit("canvasGO.AddComponent<CanvasScaler>();");
623
- this.emit("");
624
- for (const el of ui.elements) {
625
- const varName = this.sanitizeName(el.name);
626
- const elType = el.properties.find((p) => p.key === "type")?.value;
627
- this.emit(
628
- `// UI Element: ${this.escapeStringValue(el.name, "CSharp")} (${elType})`
629
- );
630
- this.emit(
631
- `var ${varName}GO = new GameObject("${this.escapeStringValue(el.name, "CSharp")}");`
632
- );
633
- this.emit(`${varName}GO.transform.SetParent(canvasGO.transform);`);
634
- if (elType === "text") {
635
- this.emit(`var ${varName}Text = ${varName}GO.AddComponent<Text>();`);
636
- const text = el.properties.find((p) => p.key === "text")?.value;
637
- if (text) this.emit(`${varName}Text.text = "${text}";`);
638
- } else if (elType === "progress") {
639
- this.emit(`var ${varName}Slider = ${varName}GO.AddComponent<Slider>();`);
640
- }
641
- this.emit("");
642
- }
643
- }
644
- // ─── Helpers ───────────────────────────────────────────────────────────
645
- emit(line) {
646
- this.lines.push(this.options.indent.repeat(this.indentLevel) + line);
647
- }
648
- sanitizeName(name) {
649
- return name.replace(/[^a-zA-Z0-9_]/g, "_");
650
- }
651
- toVector3(arr) {
652
- if (Array.isArray(arr) && arr.length >= 3) {
653
- return `new Vector3(${arr[0]}f, ${arr[1]}f, ${arr[2]}f)`;
654
- }
655
- if (Array.isArray(arr) && arr.length === 2) {
656
- return `new Vector2(${arr[0]}f, ${arr[1]}f)`;
657
- }
658
- return `new Vector3(${arr}f, ${arr}f, ${arr}f)`;
659
- }
660
- toColor(value) {
661
- if (typeof value === "string" && value.startsWith("#")) {
662
- const hex = value.slice(1);
663
- const r = parseInt(hex.substring(0, 2), 16) / 255;
664
- const g = parseInt(hex.substring(2, 4), 16) / 255;
665
- const b = parseInt(hex.substring(4, 6), 16) / 255;
666
- return `new Color(${r.toFixed(3)}f, ${g.toFixed(3)}f, ${b.toFixed(3)}f)`;
667
- }
668
- return `Color.white`;
669
- }
670
- toCSharpType(value) {
671
- if (typeof value === "number") return Number.isInteger(value) ? "int" : "float";
672
- if (typeof value === "boolean") return "bool";
673
- if (typeof value === "string") return "string";
674
- if (Array.isArray(value)) return "object[]";
675
- return "object";
676
- }
677
- toCSharpValue(value) {
678
- if (typeof value === "number") return Number.isInteger(value) ? `${value}` : `${value}f`;
679
- if (typeof value === "boolean") return value ? "true" : "false";
680
- if (typeof value === "string") return `"${this.escapeStringValue(value, "CSharp")}"`;
681
- if (value === null) return "null";
682
- return "null";
683
- }
684
- findProp(props, key) {
685
- return props?.find((p) => p.key === key)?.value;
686
- }
687
- findObjProp(obj, key) {
688
- return obj.properties?.find((p) => p.key === key)?.value;
689
- }
690
- };
691
- }
692
- });
693
-
694
- exports.UnityCompiler_exports = UnityCompiler_exports;
695
- exports.init_UnityCompiler = init_UnityCompiler;
696
- //# sourceMappingURL=chunk-HE7ULERA.cjs.map
697
- //# sourceMappingURL=chunk-HE7ULERA.cjs.map