Skip to content

Commit 896fbd4

Browse files
committed
FAQ update
1 parent d9e718f commit 896fbd4

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

documentation/reference/faq.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,50 @@ export class MyScript extends Behaviour
339339
}
340340
```
341341

342+
## My custom TypeScript class fields don't show up in the Unity/Blender Inspector
343+
344+
The Needle component compiler only auto-generates editor stubs for classes that **extend `Behaviour`** (i.e. components). If you define a plain TypeScript class (e.g. a custom data class used inside a component), it will **not** be generated automatically — you need to create the matching class in your editor project yourself.
345+
346+
For example, if you have:
347+
348+
```ts
349+
import { Behaviour, serializable } from "@needle-tools/engine";
350+
import { Object3D } from "three";
351+
352+
export class WaypointData {
353+
@serializable()
354+
speed: number = 1;
355+
356+
@serializable(Object3D)
357+
target: Object3D | null = null;
358+
}
359+
360+
export class WaypointController extends Behaviour {
361+
@serializable([WaypointData])
362+
waypoints: WaypointData[] = [];
363+
}
364+
```
365+
366+
The component compiler will generate a stub for `WaypointController` (because it extends `Behaviour`), but **not** for `WaypointData`. You must create the matching class manually in your editor project.
367+
368+
:::: tabs
369+
@tab Unity
370+
Create a C# class in your Unity project:
371+
```csharp
372+
[System.Serializable]
373+
public class WaypointData
374+
{
375+
public float speed = 1;
376+
public GameObject target;
377+
}
378+
```
379+
380+
@tab Blender
381+
Custom non-component classes are currently not supported in the Blender integration. As a workaround, consider restructuring your data so that the fields are directly on the component itself, or use separate components instead of nested data classes.
382+
::::
383+
384+
Without this class, the `waypoints` field on `WaypointController` will not be editable in the Inspector.
385+
342386
## I created a new script in a sub-scene but it does not work
343387
When creating new scripts in npmdefs in sub-scenes (that is a scene that is exported as a reference from a script in your root export scene) you currently have to re-export the root scene again. This is because the code-gen that is responsible for registering new scripts currently only runs for scenes with a ``Needle Engine`` component. This will be fixed in the future.
344388

0 commit comments

Comments
 (0)