Godot Version
v4.4.1.stable.mono.arch_linux
Question
`I have a simple ItemDatabase which derives from Resource. I set this up to be an Autoload singleton, how can I access the instance from nodes within the scene?
Since Resource has no _Ready method to override, I cannot assign my own Instance reference like I can with an Autoload that derives from Node.
Thanks!`
Perhaps instead, create a scene that [Export]
s the desired Resource
type and Autoload this instead (dragging the resource into the Inspector). Use a type that has a _Ready
function, do the work there with your resource and provide properties and/or methods to access the resource.
C#'s singleton pattern works here too, where the _Ready
-idiom could be on the first call to an Instance
property or static constructor.
2 Likes
Thank you! This was the solution I ended up going for.
1 Like