Make function static/accessible from Javascript side outside of Needle?

Why do you not simply import the component with the static getter inside that class/file then?

As in I’m putting my built dist into a HTML web project where there is a separate .js file talking to my stuff

by user 103054507105067008

Yes that’s what the sample does as well but instead of accessing a static getter it calls a function. There’s no other difference besides that

It’s just adapting that sample to do something with a serialized gameObject or script from the scene is where I’m stuck :frowning_with_open_mouth:

by user 103054507105067008

does this maybe help? Needle-engine - Vite Template (forked) - StackBlitz

imagine main.ts to be your js file or file.

Is it the @registerType I should try out?

by user 103054507105067008

I’m sure this is really simple but the sample scene for it from the Needle Samples has me confused :frowning_with_open_mouth:

by user 103054507105067008

I mean this part
image.png

External .js file > Imports a static function from my code, that function does something with seralized variables like hide/show a gameobject

by user 103054507105067008

Yep

I can see you are adding stuff to the scene there but not quite what I’m trying to do

by user 103054507105067008

Well you import the type from your package and access the static getter OR use GameObject.find… methods to find the types in the scene that you’re interested in.

Might be lazy and use GameObject.find to try that

by user 103054507105067008

What’s your package name with your script that you want to use?

then just do: import {StaticEvents } from "yourpackagename/StaticEvents.ts for example

I’ve actually ditched the package, made it all just scripts in the main project now to reduce my confusion

by user 103054507105067008

Does the external static stuff even need to be a package?

by user 103054507105067008

No

then it would be from "relpath/../StaticEvents.ts" (not sure where what is in your project)