Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be 📖

Asynchronous Scene Loader

An asset by EiTaNBaRiBoA
The page banner background of a mountain and forest
Asynchronous Scene Loader hero image

Quick Information

0 ratings
Asynchronous Scene Loader icon image
EiTaNBaRiBoA
Asynchronous Scene Loader

This Godot tool provides a simple way to load scenes asynchronously, improving your game's loading times and user experience.

Supported Engine Version
4.3
Version String
1.0.1
License Version
MIT
Support Level
community
Modified Date
8 months ago
Git URL
Issue URL

AsyncScene - Asynchronous Scene Loader

This Godot tool simplifies loading scenes asynchronously, improving game loading times and enhancing the user experience.

Features

  • Background Loading: Load scenes without freezing the main thread, keeping your game responsive.
  • Flexible Loading Options: Replace the current scene, add the loaded scene additively, or control loading behavior using different operation types.
  • Control over Scene Changes: Choose to switch scenes immediately after loading or manually initiate the scene change.
  • Progress Tracking: Monitor the loading progress with a percentage value to provide feedback to the player.
  • Load Completion Notifications: Receive signals when scene loading is complete, successful, or failed, allowing for flexible handling.

Usage

1. Initializing the AsyncScene:

extends Node2D

var scene : AsyncScene

func _ready() -> void:
    # Replace the current scene immediately after loading:
    scene = AsyncScene.new("res://path/to/your/scene.tscn", AsyncScene.LoadingSceneOperation.ReplaceImmediate)

    # Replace the current scene manually after loading (call scene.ChangeScene() later):
    # scene = AsyncScene.new("res://path/to/your/scene.tscn", AsyncScene.LoadingSceneOperation.Replace) 

    # Add the loaded scene to the current scene tree:
    # scene = AsyncScene.new("res://path/to/your/scene.tscn", AsyncScene.LoadingSceneOperation.Additive)

    # Add the loaded scene to the current scene tree immediately:
    # scene = AsyncScene.new("res://path/to/your/scene.tscn", AsyncScene.LoadingSceneOperation.AdditiveImmediate)

    # Connect to the OnComplete signal to get notified when loading is finished:
    scene.OnComplete.connect(on_scene_load_complete)

2. Handling Scene Changes (Replace and Additive Operations):

func on_scene_load_complete():
    # If using Replace or Additive operations, call ChangeScene() to finalize the scene change
    scene.ChangeScene()

    # Do something after the scene is loaded, e.g., hide loading screen.
    pass
func _process(delta):
    if scene and scene.isCompleted:
        scene.ChangeScene()

3. Monitoring Loading Progress:

func _process(delta):
    if scene:
        print("Loading progress: ", scene.progress, "%")

4. Unloading the Loaded Scene:

scene.UnloadScene()

5. Checking Loading Status:

var status = scene.GetStatus()  # Returns a string like "THREAD_LOAD_IN_PROGRESS", "THREAD_LOAD_LOADED", etc.

Example

Check the example folder for a practical demonstration of how to use the AsyncScene tool.

Additional Notes

  • This tool can be further customized and extended to fit your specific needs.
  • You can incorporate loading bars, progress indicators, or other visual elements to provide a better loading experience for your players.
  • Consider using LoadingSceneOperation.ReplaceImmediate for smooth transitions between scenes, while LoadingSceneOperation.Replace allows for more control over when the scene change occurs.
  • Remember to call ChangeScene() only if you're using LoadingSceneOperation.Replace or LoadingSceneOperation.Additive for the scene change to take effect.

This Godot tool provides a simple way to load scenes asynchronously, improving your game's loading times and user experience.

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
Asynchronous Scene Loader icon image
EiTaNBaRiBoA
Asynchronous Scene Loader

This Godot tool provides a simple way to load scenes asynchronously, improving your game's loading times and user experience.

Supported Engine Version
4.3
Version String
1.0.1
License Version
MIT
Support Level
community
Modified Date
8 months ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers