Hello all, I'm porting my game from Unity for no specific reason...

Godot has been really cool and I've been enjoying learning it, but I've also been running into some recurring porting issues that I'd like to ask some Godot experts about so I can be sure I'm doing things right and not making the wrong assumptions.

Just a disclaimer: I definitely understand that the two engines are different and don't intend to try to fit Godot into a Unity-shaped hole, but I'm mainly just looking to minimize refactoring as much as possible.

That all out of the way here are a list of my questions:

1. In Unity I like to make extensive use of "SerializeField" and serialized classes/structs to expose variables to the inspector. As I understand in Godot this is "Export"; I've been running into issues where Export does not work with a particular custom type that I have. What is the rule of thumb with these? Do they need to be Classes? Do they need to derive from a particular type such as Resource, Node, GodotObject?
For instance, Export does not seem to like an array of the example struct below:

[Serializable]
public struct MyStruct

Can you Export a generic type? For instance:

[Serializable]
public abstract class AbstractVar<T>
{
    [Export]
    protected T value = default;
}

[Serializable]
public sealed class IntVar : AbstractVar<int>
{}

2. I've been using "Node" as my equivalent to "GameObject" for the most part, unless I know it's better off as a Node3D for example. Is this a fair assumption, or should it be GodotObject?
For context if you aren't familiar with Unity, GameObjects are what exist in the scene hierarchy. They don't have to have a physical presence in game and can just exist to run scripts, act as points in world if necessary, or act as a parent container to other GameObjects. (Seems rather Node-ish?)

3. Along with my Exported variables, I like to add Attributes to specify bounds or provide inspector Tooltips. I saw that Export can accept a "PropertyHint". I've been using e.g. "PropertyHint.Range, "0.0, 1.0," as an analogue for "[Range( 0.0f, 1.0f )]. In Unity this will prevent the user from setting values outside of that range in the Inspector.
In lieu of a full Range, I also use e.g. "[Min( 0.0f )]" when I want to enforce a Minimum value. I don't see a property hint for this though, is there any way to achieve this?

4. I was using Addressables and am looking to approximate their behavior in Godot. From what I've read it looks like I'll be able to achieve this by packing Resource objects into .PCK files? Are there any built-in managers for this workflow already or maybe a 3rd party plugin people recommend?

5. Let's say you have a bunch of child Nodes under a parent Node. The children have their ProcessMode set to Inherit and the parent gets set to Disabled.
Is there a quick way to test if one of those Child Nodes are disabled? Is "IsProcessing()" generally sufficient?

6. Is there a way to create a custom Inspector display for a particular Class/Resource? Aside from creating a custom inspector, Unity has a "PropertyDrawer". Basically you can create one for a particular serialized class and anytime that class is to be displayed in the Editor Inspector, it'll use your Property Drawer instead, even if it is used as a field in another Class. (So think you Export a custom class and have code that customizes how that class should be displayed in the Inspector)

These are the main questions off the top of my head at the moment, if you've made it this far, thank you for your patience. 🙂

  • xyz replied to this.

    HeavensSword

    1. You can export only Godot's built in types (Variant), Node derived types, Resource derived types and Godot enums.

    2. Inheriting from Node is right for everything that needs to exist in the scene tree. Use Node3D instead if you need it to obey transformation hierarchy. For everything else you can go more lightweight and inherit RefCounted, which is the most basic Godot object that is memory managed. If you want to memory manage it yourself, you can go to the very root of class hierarchy and inherit from Object.

    3. Here's everything you can currently do with exports.

    4. Not familiar with Addressables.

    5. IsProcessing() should take processing inheritance into account.

    6. It can be customized to a degree by overriding Object::_GetPropertyList()

    Thanks for the quick reply, it's a big help!

    Sorry, I forgot to explain Addressables.
    Basically you can group assets such as Textures, Audio, Scriptable Objects, etc. (Resources) together and assign meta data to them if you want.
    Those asset groups are then packaged up separately from the game executable into bundles.
    Each packed asset can then be addressed via a path string or its assigned GUID ref and loaded up and instantiated during runtime.
    The benefit is packaging assets up as DLC and you can also stream/download packages from a server to add to or update existing ones since they are versioned when built.

    It very much sounds like Resources packed into .PCK files in Godot. I'm probably going to make my own wrapper/manager for it, but wasnt sure if there were maybe other plugins or something for this.