Godot Version
4.5
Question
Is there a good way to set a default value for exported custom resources? So far I have tried:
@export var health: Stat = Stat.new()
But this A. does not set it to a default value, not even a blank resource and B. does not let me set a value to any of the resource’s properties
I also tried this:
@tool
extends whatever
@export var health: Stat = newStat(100.0)
func newStat(value: float) -> Stat:
var newStat: Stat = Stat.new()
newStat.base = value #base is a variable in Stat
return newStat
This works, but it requires my script to be a tool script, which I would like to avoid if possible, is there a better way to do this?