When bringing my Unity Application via Needle to the web, Iād like to communicate with Components on a webpage, build interactive interfaces or might want to implement functionality using Web APIs which Unity does not expose. Combining Unity with React or Flutter might be a great way to achieve these goals.
Are there any best practices on how to integrate my needle experience within a website, e. g. web buttons to trigger animatons, variants etc. My goal is the development of an interactive product configurator on the web. The questions might be simple, but Iām still new to all of this - so sorry
We recently added a React template which might get you started there.
What we usually did is we built application specific logic inside npmdef files and then per npmdef exposed one or more of those types as apis for your vanilla js or frontend framework to talk to. That way you keep kind of an overview of what is exposed when e.g. refactoring your application without having to do the same for your frontend.
Basically you can use any framework you like and e.g. add a <needle-engine> component tag somewhere.
From there you can access the Context which gives you the scene etc (it is the same as when you write this.context from a script-component)
You can use methods like GameObject.findObjectOfType(Animator) for example (from vanilla js it would be Needle.GameObject.findObjectOfType(Needle.Animator))
We also patch the threejs object with some of these methods - e.g. if you have access to an Object3D you can write myObject.getComponent(Needle.Animator)