NeedleEngine fails to generate C# scripts

Hi here! I’m trying to create a TypeScript script, but the Needle Engine fails to generate corresponding C# scripts for me, with below error. How can I solve this?

ArgumentNullException: Value cannot be null.
Parameter name: path
System.IO.Path.InsecureGetFullPath (System.String path) (at <6073cf49ed704e958b8a66d540dea948>:0)
System.IO.Path.GetFullPath (System.String path) (at <6073cf49ed704e958b8a66d540dea948>:0)
Needle.Engine.Codegen.ComponentGeneratorRunner.Run (System.String generatorInstallDir, System.String filePath, System.String targetDirectory, System.String seed) (at Library/PackageCache/com.needle.engine-exporter@2.67.18/Core/Runtime/Codegen/ComponentGeneratorRunner.cs:54)
Needle.Engine.Codegen.CodeWatcher.ProcessChangedFiles () (at Library/PackageCache/com.needle.engine-exporter@2.67.18/Core/Runtime/Codegen/CodeWatcher.cs:196)
Needle.Engine.Codegen.<ProcessChangedFiles>d__32:MoveNext() (at Library/PackageCache/com.needle.engine-exporter@2.67.18/Core/Runtime/Codegen/CodeWatcher.cs:203)```

[Original Post on Discord](

*by user 909845602358161440*

Can you share some more info about the script? The name of the class and the full path to the script file on disc?

Sure! The script is in K:\Unity\needletest\Assets\MyModuel~\src\scripts\CameraBlocker.ts, and the content is in below. (It’s test script to ensure that entire system is working well)

import { Behaviour, serializable } from "@needle-tools/engine";

export class CameraBlocker extends Behaviour {
    speed: number = 1;

    start() {
        // logging this is useful for debugging in the browser. 
        // You can open the developer console (F12) to see what data your component contains

    // update will be called every frame
    update() {
        this.gameObject.rotateY(this.context.time.deltaTime * this.speed);

In case of little help, here's current project's setup: (See Image)

*by user 909845602358161440*

This looks perfectly fine. Can you try moving your script from src/scripts into the toplevel MyModule~ folder?

Sure, hold on.

by user 909845602358161440

@marcel :cactus: Great, I think it’s working now. Thank you!

by user 909845602358161440

ah interesting that it didnt work with the path. perhaps a bug with not generating the directory on the Unity side then

@marcel :cactus: One more question. How can I refer the type LayerMask which can be used in C# for Unity? I’d like to expose a property to let users specify layers(multiple).

by user 909845602358161440

something like this should work (because the type is known in Unity it should generate the correct Unity type)

// at the top of your file for example (just so you can use it in typescript)
export type LayerMask = number;

/// in your class:
@serializable() // < omit the type here because LayerMask is just a number and primitive types dont need to specifiy the type explictly
myMask : LayerMask = 0;


//@type UnityEngine.LayerMask
myMask : number = 0;

Aha, so basically, NeedleEngine identify corresponding C#(Unity) types by it’s name, right?

by user 909845602358161440

Yes. The first time it’s triggered per session a map of c# types is exported so that the component compiler knows what types exist in Unity and in which namespace.
You can totally override that with the // @type syntax FORCING the compiler to output your type (or whatever string you enter as the type)

One caveat is that when you add a new type in Unity that map has to be re-generated. It isnt every time for performance reasons so it might be necessary to do that manually sometimes

Oh, sadly, assigning number literals are going to be converted in float in C#. It is causing compilation errors. In this case, can we override the type of literal?

by user 909845602358161440

you can add @type int above your type


by user 909845602358161440