Godot Version
4.7
Question
Hello, everyone.
I believe my question to be straightforward. I would like to know if marshalling occurs when accessing Resources and properties within them, like in the example below:
[Godot.GlobalClass]
public partial class ExampleResource : Resource {
[Godot.Export]
public float ValueOne { get; set; }
[Godot.Export]
public float ValueTwo { get; set; }
}
[Godot.GlobalClass]
public partial class SomeEntity : Godot.Node {
[Godot.Export]
public ExampleResource CoolResource { get; set; }
public float SomeCalculation() {
float someValue = someMethod();
return CoolResource.ValueOne + someValue * 2;
}
}
The documentation says:
Most properties of Godot C# objects that are based on GodotObject (e.g. any Node like Control or Node3D like Camera3D) require native (interop) calls as they talk to Godot’s C++ core.
Resource is based on Object, but the properties within are not (e.g. ValueOne). I imagine there might be some marshalling at assignment (the initial one or if values change in code), but in my case I expect it to never be changed after the initialization.
I’m asking mostly because if it does happen, I might use an additional field to prevent marshalling if I end up doing multiple calculations within short periods of time.