Last active
August 25, 2023 16:21
-
-
Save Stuyk/116c79e12269d327708a82cd91affb13 to your computer and use it in GitHub Desktop.
Global Godot Singleton - Without Auto Loading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func _ready(): | |
MySingleton.instance().print_hello(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment