1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Merge pull request #102499 from Jordyfel/resource-docs

Improve documentation of some `Resource` methods
This commit is contained in:
Rémi Verschelde
2025-06-28 13:02:54 +02:00
3 changed files with 14 additions and 14 deletions

View File

@@ -671,7 +671,7 @@ void Resource::set_as_translation_remapped(bool p_remapped) {
} }
} }
//helps keep IDs same number when loading/saving scenes. -1 clears ID and it Returns -1 when no id stored // Helps keep IDs the same when loading/saving scenes. An empty ID clears the entry, and an empty ID is returned when not found.
void Resource::set_id_for_path(const String &p_path, const String &p_id) { void Resource::set_id_for_path(const String &p_path, const String &p_id) {
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
if (p_id.is_empty()) { if (p_id.is_empty()) {

View File

@@ -122,12 +122,12 @@ protected:
virtual Ref<Resource> _duplicate(const DuplicateParams &p_params) const; virtual Ref<Resource> _duplicate(const DuplicateParams &p_params) const;
public: public:
static Node *(*_get_local_scene_func)(); //used by editor static Node *(*_get_local_scene_func)(); // Used by the editor.
static void (*_update_configuration_warning)(); //used by editor static void (*_update_configuration_warning)(); // Used by the editor.
void update_configuration_warning(); void update_configuration_warning();
virtual bool editor_can_reload_from_file(); virtual bool editor_can_reload_from_file();
virtual void reset_state(); //for resources that use variable amount of properties, either via _validate_property or _get_property_list, this function needs to be implemented to correctly clear state virtual void reset_state(); // For resources that store state in non-exposed properties, such as via _validate_property or _get_property_list, this function must be implemented to clear them.
virtual Error copy_from(const Ref<Resource> &p_resource); virtual Error copy_from(const Ref<Resource> &p_resource);
virtual void reload_from_file(); virtual void reload_from_file();
@@ -178,9 +178,9 @@ public:
void set_as_translation_remapped(bool p_remapped); void set_as_translation_remapped(bool p_remapped);
virtual RID get_rid() const; // some resources may offer conversion to RID virtual RID get_rid() const; // Some resources may offer conversion to RID.
//helps keep IDs same number when loading/saving scenes. -1 clears ID and it Returns -1 when no id stored // Helps keep IDs the same when loading/saving scenes. An empty ID clears the entry, and an empty ID is returned when not found.
void set_id_for_path(const String &p_path, const String &p_id); void set_id_for_path(const String &p_path, const String &p_id);
String get_id_for_path(const String &p_path) const; String get_id_for_path(const String &p_path) const;
@@ -192,7 +192,7 @@ VARIANT_ENUM_CAST(Resource::DeepDuplicateMode);
class ResourceCache { class ResourceCache {
friend class Resource; friend class Resource;
friend class ResourceLoader; //need the lock friend class ResourceLoader; // Need the lock.
static Mutex lock; static Mutex lock;
static HashMap<String, Resource *> resources; static HashMap<String, Resource *> resources;
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED

View File

@@ -23,14 +23,14 @@
<method name="_reset_state" qualifiers="virtual"> <method name="_reset_state" qualifiers="virtual">
<return type="void" /> <return type="void" />
<description> <description>
For resources that use a variable number of properties, either via [method Object._validate_property] or [method Object._get_property_list], this method should be implemented to correctly clear the resource's state. For resources that store state in non-exported properties, such as via [method Object._validate_property] or [method Object._get_property_list], this method must be implemented to clear them.
</description> </description>
</method> </method>
<method name="_set_path_cache" qualifiers="virtual const"> <method name="_set_path_cache" qualifiers="virtual const">
<return type="void" /> <return type="void" />
<param index="0" name="path" type="String" /> <param index="0" name="path" type="String" />
<description> <description>
Sets the resource's path to [param path] without involving the resource cache. Override this method to execute additional logic after [method set_path_cache] is called on this object.
</description> </description>
</method> </method>
<method name="_setup_local_to_scene" qualifiers="virtual"> <method name="_setup_local_to_scene" qualifiers="virtual">
@@ -94,7 +94,7 @@
<return type="String" /> <return type="String" />
<param index="0" name="path" type="String" /> <param index="0" name="path" type="String" />
<description> <description>
Returns the unique identifier for the resource with the given [param path] from the resource cache. If the resource is not loaded and cached, an empty string is returned. From the internal cache for scene-unique IDs, returns the ID of this resource for the scene at [param path]. If there is no entry, an empty string is returned. Useful to keep scene-unique IDs the same when implementing a VCS-friendly custom resource format by extending [ResourceFormatLoader] and [ResourceFormatSaver].
[b]Note:[/b] This method is only implemented when running in an editor context. At runtime, it returns an empty string. [b]Note:[/b] This method is only implemented when running in an editor context. At runtime, it returns an empty string.
</description> </description>
</method> </method>
@@ -113,13 +113,13 @@
<method name="is_built_in" qualifiers="const"> <method name="is_built_in" qualifiers="const">
<return type="bool" /> <return type="bool" />
<description> <description>
Returns [code]true[/code] if the resource is built-in (from the engine) or [code]false[/code] if it is user-defined. Returns [code]true[/code] if the resource is saved on disk as a part of another resource's file.
</description> </description>
</method> </method>
<method name="reset_state"> <method name="reset_state">
<return type="void" /> <return type="void" />
<description> <description>
For resources that use a variable number of properties, either via [method Object._validate_property] or [method Object._get_property_list], override [method _reset_state] to correctly clear the resource's state. Makes the resource clear its non-exported properties. See also [method _reset_state]. Useful when implementing a custom resource format by extending [ResourceFormatLoader] and [ResourceFormatSaver].
</description> </description>
</method> </method>
<method name="set_id_for_path"> <method name="set_id_for_path">
@@ -127,7 +127,7 @@
<param index="0" name="path" type="String" /> <param index="0" name="path" type="String" />
<param index="1" name="id" type="String" /> <param index="1" name="id" type="String" />
<description> <description>
Sets the unique identifier to [param id] for the resource with the given [param path] in the resource cache. If the unique identifier is empty, the cache entry using [param path] is removed if it exists. In the internal cache for scene-unique IDs, sets the ID of this resource to [param id] for the scene at [param path]. If [param id] is empty, the cache entry for [param path] is cleared. Useful to keep scene-unique IDs the same when implementing a VCS-friendly custom resource format by extending [ResourceFormatLoader] and [ResourceFormatSaver].
[b]Note:[/b] This method is only implemented when running in an editor context. [b]Note:[/b] This method is only implemented when running in an editor context.
</description> </description>
</method> </method>
@@ -135,7 +135,7 @@
<return type="void" /> <return type="void" />
<param index="0" name="path" type="String" /> <param index="0" name="path" type="String" />
<description> <description>
Sets the resource's path to [param path] without involving the resource cache. Sets the resource's path to [param path] without involving the resource cache. Useful for handling [enum ResourceFormatLoader.CacheMode] values when implementing a custom resource format by extending [ResourceFormatLoader] and [ResourceFormatSaver].
</description> </description>
</method> </method>
<method name="setup_local_to_scene" deprecated="This method should only be called internally."> <method name="setup_local_to_scene" deprecated="This method should only be called internally.">