Can C# originally scripts be used in Needle?

So imagine you’re converting a previous Unity project to a Needle project. Can those old C# scripts be used without modification or do you have to figure out how to convert those C# scripts into JS/TS (and then needle will auto-convert that correctly to C#)??

Original Post on Discord

by user 352282921056468993

Hey :wave: what do you want to do?

Do you want the original project to still work on other platforms or is that a one way conversion to Needle?

Sadly you can’t use C# scripts directly in Needle runtime and you need to write typescript counterparts.

Ah okay got it. Yea, just wondering if a regular C# script would work (despite it not originating from a TS script). Thanks!

by user 352282921056468993

I think a good start would be here:
This also lets you to get the grasp of the main differences between the Unity C# api and the Three.js Typescript + Needle API

Let me know if you would get stuck or if you wouldn’t be sure about something :cactus:

@Shmoji typically when porting an application you’d write the .ts scripts that contain matching data and logic to your C# scripts. To avoid the C# stubs being created, you can add // @dont-generate-component in the line above your TS component declaration.

This way, the components you already have in your scene will automatically be translated to those TypeScript components (where you re-add the logic building on the same data you already have).

So in a typical flow you don’t have to even swap components in your scene - you just build the matching TS files and we take care of the rest.