Code Monkey home page Code Monkey logo

godotasyncloader's Introduction

Godot Async Loader

Video on how plugin works

Loading scenes asynchronously in Godot

How to install and use plugin

  1. Find, download, and install the "Godot Async Loader" plugin in AssetLib

groups

  1. Enable the plugin (Project -> Project Settings -> Plugins -> Enable)

groups

  1. Add scenes to groups

groups

  1. Setup plugin in main scene
const GROUPS := [
	"terrain",
	"building",
	"furniture",
	"plant",
	"item",
	"npc",
	"etc",
]

func _init() -> void:
	SceneAdder._sleep_msec = 100
	SceneAdder.set_groups(GROUPS)
  1. Use the plugin to change to a new scene and load it asynchronously
func _on_start_pressed() -> void:
	SceneSwitcher.change_scene("res://examples/World/World.tscn")

How to load child scene async

# Instance scene asynchronously and add to current scene
var target = get_tree().get_current_scene()
var scene_file := "res://examples/Animals/Puma.tscn"
var pos := Vector3(0, 1, 0)
SceneLoader.load_scene_async(target, scene_file, pos, true)

How to load child scene async with callback

# Instance scene asynchronously and send to callback
var target = get_tree().get_current_scene()
var scene_file := "res://examples/Animals/Puma.tscn"
var pos := Vector3(0, 1, 0)
SceneLoader.load_scene_async_with_cb(target, scene_file, pos, true, funcref(self, "on_animal_loaded"), {})

func on_animal_loaded(path : String, instance : Node, pos : Vector3, is_pos_global : bool, data : Dictionary) -> void:
	var target = get_tree().get_current_scene()
	instance.transform.origin = pos
	target.add_child(instance)

How to load child scene sync

# Instance scene synchronously and add to target scene
var scene_file := "res://examples/Animals/Puma.tscn"
var target = get_tree().get_current_scene()
var instance := SceneLoader.load_scene_sync(target, scene_file)

godotasyncloader's People

Contributors

workhorsy avatar

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.