We’re developing an app where we need to take control of when this function is invoked, but it is not possible as-is. At the moment I’m just replacing ‘start.js’ with my own copy that has been modified to be a callable function. But this is not really future-safe and leaves me feeling a little nervous
If it were a callable function by default, then it only leaves me to worry about injecting my code into the html and I can keep the default ‘start.js’ file without having a custom copy. Not super urgent, just would be useful.
*note, the filename should have two underscores on either side, but the text printing thinks I want the name bold instead.
Just to verify, do you actually need to control when that function in start.js gets called or more that you don’t want the main content of the application to start until an external event is triggered?
The reason I ask is that you could have the application load to a splash or holding screen until it receives that external event to progress onto the main content?
It’s more that I’d like to control when that function is called. We are running within another third-party framework and we’re not supposed to begin any processing until they have told us it is time to do so.
It maybe that I’m misunderstanding the second part of your message sorry, as it reads like the behaviour I am looking for
I don’t know what the 3rd party’s definition of ‘processing’ is so my proposed workaround could still work pending on their wording.
What I’m saying is that your app when page loads, it loads as normal but doesn’t do anything beyond show a holding image or message. Once you are ready to ‘process’, then you can fire an event to the app to start processing whatever it needs to do.
As an example, think of game that when it loads, it starts on the title screen and doesn’t start playing until the user presses the start button.
Is this preloader.js script automatically detected or should it be placed in the script priorities list (I am unable to open the script priorities in the example)? Does the presence of this file prevent the automatic loading of resources (that might seem a silly question, just want to be sure).
You should be able to just double click on it from the assets window (if that doesn’t work, please let me know but as a workaround, you can just fork the project).
TBH, you don’t really need a preloader. The sample is more to show you that you can prevent certain entities being shown/processed/etc until an event takes place (in that sample case, the user presses space bar).
You just need a mechanism in place that doesn’t start the processing until the the external event is triggered. A simple FSM would suffice.
So as quick and dirty another example, you could put everything as a child of one entity, disable that entity in the editor so when the app starts, none of the scripts in the children update. And then enable that parent entity when the external event is fired.