Skip to content

Instantly share code, notes, and snippets.

@Stuyk
Last active August 25, 2023 16:21
Show Gist options
  • Save Stuyk/116c79e12269d327708a82cd91affb13 to your computer and use it in GitHub Desktop.
Save Stuyk/116c79e12269d327708a82cd91affb13 to your computer and use it in GitHub Desktop.
Global Godot Singleton - Without Auto Loading
extends Node2D
class_name MySingleton
var hello_world: String = "Hello World!";
static var _instance: MySingleton;
static func instance() -> MySingleton:
if (!_instance):
_instance = MySingleton.new();
return _instance;
func print_hello():
print(hello_world);
func _ready():
MySingleton.instance().print_hello();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment