@needle-tools/needle-component-compiler 1.10.3 → 1.11.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.
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.11.0] - 2023-11-18
8
+ - Add: support to wrap fields with `#if UNITY_EDITOR` if their namespace contains UnityEditor
9
+ - Add: more threejs types to generate Unity Material fields for
10
+
7
11
  ## [1.10.3] - 2023-09-08
8
12
  - Add: Needle Engine type `RGBAColor` is now automatically emitted as `UnityEngine.Color`
9
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/needle-component-compiler",
3
- "version": "1.10.3",
3
+ "version": "1.11.0",
4
4
  "description": "Compile mock unity components from typescript",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -377,7 +377,14 @@ function run(program, outputDir, sourceFile) {
377
377
  if (allowDebugLogs)
378
378
  console.log("EMIT member: \"" + typeString + "\" " + varName, assignment, "Last type found:", lastTypeFound);
379
379
  var prefix = shouldCommentTheLine ? "// " : "";
380
+ var isUnityEditorType = typeString === null || typeString === void 0 ? void 0 : typeString.includes("UnityEditor");
381
+ if (isUnityEditorType) {
382
+ context.appendLine("#if UNITY_EDITOR");
383
+ }
380
384
  context.append(prefix + visibility + " " + typeString + " " + varName + assignment + ";" + postFix + "\n");
385
+ if (isUnityEditorType) {
386
+ context.appendLine("#endif");
387
+ }
381
388
  lastTypeFound = null;
382
389
  if (requireEndIf) {
383
390
  context.appendLine("#endif");
@@ -409,7 +409,14 @@ export function run(program: ts.Program, outputDir: string | null, sourceFile: t
409
409
  if (allowDebugLogs)
410
410
  console.log("EMIT member: \"" + typeString + "\" " + varName, assignment, "Last type found:", lastTypeFound);
411
411
  const prefix = shouldCommentTheLine ? "// " : "";
412
+ const isUnityEditorType = typeString?.includes("UnityEditor");
413
+ if (isUnityEditorType) {
414
+ context.appendLine("#if UNITY_EDITOR");
415
+ }
412
416
  context.append(prefix + visibility + " " + typeString + " " + varName + assignment + ";" + postFix + "\n");
417
+ if (isUnityEditorType) {
418
+ context.appendLine("#endif");
419
+ }
413
420
  lastTypeFound = null;
414
421
  if (requireEndIf) {
415
422
  context.appendLine("#endif");
package/src/types.js CHANGED
@@ -40,7 +40,13 @@ const dict = {
40
40
  // Rendering
41
41
  "Renderer" : "UnityEngine.Renderer",
42
42
  "Material" : "UnityEngine.Material",
43
+ "MeshBasicMaterial": "UnityEngine.Material",
44
+ "MeshPhysicalMaterial": "UnityEngine.Material",
45
+ "MeshStandardMaterial": "UnityEngine.Material",
46
+ "ShaderMaterial": "UnityEngine.Material",
47
+ "RawShaderMaterial": "UnityEngine.Material",
43
48
  "Mesh" : "UnityEngine.Mesh",
49
+ "SkinnedMesh" : "UnityEngine.Mesh",
44
50
  "Texture" : "UnityEngine.Texture",
45
51
  // UI
46
52
  "Text" : "UnityEngine.UI.Text",