Best Practices for Reusable (Shared) Code?
Hi,
Are there any good resources on managing code in complex Lens Studio projects? I'd like to port a game from Unity to Lens Studio and the biggest obstacle is code organization. For example, I'd like to be able to have helper classes and methods accessible from any script. I am not sure if my mental model is correct but it seems that:
1. Scripts execute generally from top to bottom order in the scene, meaning an object at the very top of the scene can be used to instantiate methods or objects accessed globally.
2. The "global" object is the only way to share things among scripts attached to different script components throughout the scene.
3. script.api is a convenience variable that actually lives on the ScriptComponent just as anything else added to the "script" object.
Seems to me that the only way to cleanly create e.g. N shared systems is to write a script for each system, attach N script components to a top-level object (each bound to the Awake event), and then have each of those add its API methods to "global".
Is that roughly correct or is there a better way?
Thank you,
Bart