i have created some TS scripts. They got codegen’ed to C#. I used them in unity editor. I exported.
For some reason in the console it is saying all these scripts i created are unknown components. Attached are some useful pics. Any idea why this is happening?
Some other weird stuff:
this is a Next.js project and i can only run the app from the web project. If i try to press play in unity it doesnt work. It says it cant detect the compiler type or something like that. This could be unrelated tho
Normally the types are automatically registered (by code generated by the Unity exporter). Can you check if your next.js project has a register_types.ts somewhere? If yes try importing it from somewhere
Hi @Shmoji I’ve just tried to reproduce it here with our next sample but that works as expected.
Can you check if you have perhaps both a register_types.js and a register_types.ts in that directory? Otherwise can you send us a bugreport from Unity with Needle Engine/Report a bug ?
You also seem to reference prefab assets in your Unity Event functions in which case the methods that are called by the Unity Event do receive a string (the url to the exported glb).
You can do this to fix that in the SpawnHandler line ~28:
async handlePlayerSpawn(obj: Object3D | string) {
if (typeof obj === "string") {
obj = await AssetReference.getOrCreate(this.sourceId, obj, this.context)?.instantiate();
}
<rest of your code>
i also had to change a little bit in the needleEngine.tsx - this is something we have to update in the sample for your usecase. Below is the fixed code (in needleEngine.ts line 27 it now always imports the /generated/gen path)
oo okay thank you, im going to process all of this. Also, for this part specifically i was confused by the sample because i couldnt figure out where the sample code was instantiating the player that gets spawned
the one here from first person controller sample. My code is basically the same as the sample. I mainly just copy and pasted everything from the samples. And i noticed i didnt see handlePlayerSpawn actually instantiating any players anywhere (until you suggested that change above, but that’s not in the sample itself)