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)
UnityEngine.Debug:LogException(Exception)
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](https://discord.com/channels/717429793926283276/1106129982171918387)
*by user 909845602358161440*
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 {
@serializable()
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
console.log(this);
}
// 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)
![image.png](https://cdn.discordapp.com/attachments/1106129982171918387/1106131035068043294/image.png?ex=65d7014d&is=65c48c4d&hm=c051221840f09669f076b70becf9a799a1539cf14b154e3ecf520254cf4c4556&)
*by user 909845602358161440*
@marcel 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).
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;
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?