Hi guys, quick question for a late friday afternoon Is there a way to keep the default loading screen and only override the displayed scene name?
Hi Krizzl0r!
To override the displayed scene name on the default loading screen in Needle Engine, you primarily work with the SceneSwitcher
component. Hereβs a rough outline of the steps you can take:
-
Identify the Loading Scene: You can specify which loading scene to display while the main scenes are loading using the
loadingScene
property in theSceneSwitcher
. -
Override Scene Name: Utilize the
sceneLoadingProgress
event to update the loading name dynamically based on the scene being loaded.
Hereβs an example of how to achieve this in code:
import { SceneSwitcher } from "@needle-tools/engine";
const sceneSwitcher = new SceneSwitcher();
sceneSwitcher.addEventListener("sceneLoadingProgress", (event) => {
const loadingName = getSceneName(event.detail.scene.url); // Function to get the scene name
sceneSwitcher.loadingView?.setMessage(loadingName); // Update the loading screen message
});
function getSceneName(url: string): string {
const name = url.split("/").pop();
return name ? name.replace(/\.[^/.]+$/, "") : "Loading..."; // Remove file extension for a clean name
}
Key Points:
- The
setMessage
method updates the loading screen with your custom scene name. - You need to make sure that the
sceneLoadingProgress
event is properly handled to capture the loading state. - This allows you to retain the default loading screen while dynamically updating the displayed name.
For further customization on loading views, you might want to look into the options available in the Engine Loading View.
Check the documentation for more about scene management and loading screens:
If you need additional details or specific integration, feel free to ask!
1 replies left - Get a PRO license for more AI replies.
thread_fShfTWowuLXkldinVZINXMRv
Reply to this message to continue the conversation
Hi, not at the moment