Loading Screen and Quitting game? #137
-
Would you mind helping me with 2 questions?
Regards, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 14 replies
-
P.S. Would you mind to share your template....? I having problems when trying to implement react into my webgl build project.....I am confused whethere I should put the import React from "react"; inside my index.html or I should create a new js file?? Thanks.... Rick |
Beta Was this translation helpful? Give feedback.
-
Hi Dean! Thanks for opening this discussion. I'm afraid you're misunderstanding the purpose of this module and the use of React. The React Unity WebGL module is meant to implement your Unity Build into your React Application so you can create your own interface and everything around it. I think you're confusing it with the Templating-Tool Unity has added to their Build-Pipeline. If you want a pre-game loading screen, you have to build one yourself using React, as the loading screen you're referring to is not included in your Unity Build, but is living inside of the HTML which Unity's Templating-Tool has created. It's simply not the purpose of a module like this to serve things such as a loading screen, but instead to serve you - the developer - the tools needed to create one yourself. For more information about building a loading screen, please see this section in the Wiki for further details. A basic example would look something like: this.unityContext.on("progress", progression => {
this.setState({ percent: progression * 100 });
});
...
<div>
<div>{`Loading... ${percent}%...`}</div>
<Unity unityContext={this.unityContext} />
</div> The same goes for your second point, when you have quitted your application, it is up to you - the developer - to act on this. All Quiting the Application does is freeing up memory for your browser. You can add behaviour by adding an event listener to the Quit event. Please see this section in the Wiki for further details. A basic example would look something like: this.unityContext.on("quitted", () => {
window.location.href = "...";
}); I hope this clears up some of your questions. Best of luck with your project, and stay safe! If you're having any other questions feel free to reply on this thread. |
Beta Was this translation helpful? Give feedback.
Hi Dean! Thanks for opening this discussion. I'm afraid you're misunderstanding the purpose of this module and the use of React.
The React Unity WebGL module is meant to implement your Unity Build into your React Application so you can create your own interface and everything around it. I think you're confusing it with the Templating-Tool Unity has added to their Build-Pipeline. If you want a pre-game loading screen, you have to build one yourself using React, as the loading screen you're referring to is not included in your Unity Build, but is living inside of the HTML which Unity's Templating-Tool has created.
It's simply not the purpose of a module like this to serve things such as a l…