- Edited
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.