Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
GD0401: La classe deve derivare da Godot.GodotObject o da una classe derivata
ID regola |
GD0401 |
Categoria |
Utilizzo |
Soluzione è distruttiva o non-distruttiva |
Distruttiva - Se si cambia la catena di ereditarietà Non-distruttiva - Se l'attributo |
Abilitato per predefinito |
Si |
Causa
Un tipo annotato con l'attributo [GlobalClass] non deriva da GodotObject.
Descrizione della regola
[GlobalClass] non ha effetto per i tipi che non derivano da GodotObject. Ogni classe globale deve ultimamente derivare da GodotObject per poterle convertire e serializzare.
// This type is not registered as a global class because it doesn't derive from GodotObject.
[GlobalClass]
class SomeType { }
// This type is a global class because it derives from Godot.Node
// which ultimately derives from GodotObject.
[GlobalClass]
class MyNode : Node { }
// This type is a global class because it derives from Godot.Resource
// which ultimately derives from GodotObject.
[GlobalClass]
class MyResource : Resource { }
Come risolvere le violazioni
Per correggere una violazione di questa regola, modificare il tipo in modo che derivi da GodotObject o rimuovere l'attributo [GlobalClass].
Quando sopprimere gli avvertimenti
Non sopprimere un avviso da questa regola. Aggiungere [GlobalClass] a un tipo che non deriva da GodotObject è un errore comune e questo avviso aiuta gli utenti a capire che potrebbe causare errori imprevisti.