I make custom classes which inherited by Reference class. These classes made for just holding data and functions (like a map or a dungeon for example)

extends Reference
class_name Room

var x: int
var y: int

# etc...

Are there better classes for making custom data-structure classes then Reference class?

I do not think so. Reference is pretty bare bones, and even internally, Godot uses Reference for base classes (like Collision pShape2d) that get extended (BoxShape2d). You could use Object, but then you’d need to manage memory, as Objects are not reference counted (from what I remember).

I've been using Resource, though I can't remember why anymore. I think I remember digging into it and finding that it has the least amount of things I needed while still being useful.

Let me know if I should change to Reference.

@Kequc said: I've been using Resource, though I can't remember why anymore. I think I remember digging into it and finding that it has the least amount of things I needed while still being useful.

Let me know if I should change to Reference.

Wait, after reading this (and double checking), I was Resource, not Reference. Things like CollisionShape2d expand on Resource, not reference like I said in my previous post. Sorry about the confusion! I shouldn’t try to multitask :sweat_smile:

Yeah, I agree... Resource for your data classes just makes sense.

I do have one class that inherits from Object, because it is literally just const data and static functions, so that made the most sense there.

One of the main differences between Object and Resource is that Resource offers built-in methods for (de)serializing, unlike Object.

See also this page in the documentation.

2 years later