Git Product home page Git Product logo

asyncscene's Introduction

AsyncScene - Asynchronous Scene Loader

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

Features

  • Load scenes in the background without freezing the main thread.
  • Replace the current scene or add the loaded scene additively.
  • Choose between immediate or manual scene switching after loading.
  • Track loading progress with a percentage value.
  • Receive notifications upon successful or failed scene loading.

Usage

1. Loading a scene:

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)

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

func on_scene_load_complete():
	# Do something after the scene is loaded, e.g., hide loading screen.
	pass

2. Manually switching to the loaded scene (if using Replace mode):

func _process(delta):
	if scene and scene.isCompleted:
		scene.ChangeScene()

3. Accessing loading progress:

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

4. Unloading the loaded scene:

scene.UnloadScene()

5. Getting the loading status:

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

Example

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

This readme provides a basic overview of the AsyncScene tool and its usage. You can further customize and extend this tool to suit your specific needs.

asyncscene's People

Contributors

eitanbariboa avatar

Stargazers

Corey Johnson avatar Hyr avatar ElFlashor avatar  avatar George Pitoy avatar  avatar  avatar WeatherStone avatar

Watchers

 avatar

Forkers

zhangjiangen11

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.