Browse Source

[Core] Expose ResourceLoader.get_resource_uid.

Fabio Alessandrelli 4 years ago
parent
commit
9798d08ac2
3 changed files with 13 additions and 0 deletions
  1. 5 0
      core/core_bind.cpp
  2. 1 0
      core/core_bind.h
  3. 7 0
      doc/classes/ResourceLoader.xml

+ 5 - 0
core/core_bind.cpp

@@ -107,6 +107,10 @@ bool _ResourceLoader::exists(const String &p_path, const String &p_type_hint) {
 	return ResourceLoader::exists(p_path, p_type_hint);
 }
 
+ResourceUID::ID _ResourceLoader::get_resource_uid(const String &p_path) {
+	return ResourceLoader::get_resource_uid(p_path);
+}
+
 void _ResourceLoader::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("load_threaded_request", "path", "type_hint", "use_sub_threads"), &_ResourceLoader::load_threaded_request, DEFVAL(""), DEFVAL(false));
 	ClassDB::bind_method(D_METHOD("load_threaded_get_status", "path", "progress"), &_ResourceLoader::load_threaded_get_status, DEFVAL(Array()));
@@ -118,6 +122,7 @@ void _ResourceLoader::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("get_dependencies", "path"), &_ResourceLoader::get_dependencies);
 	ClassDB::bind_method(D_METHOD("has_cached", "path"), &_ResourceLoader::has_cached);
 	ClassDB::bind_method(D_METHOD("exists", "path", "type_hint"), &_ResourceLoader::exists, DEFVAL(""));
+	ClassDB::bind_method(D_METHOD("get_resource_uid", "path"), &_ResourceLoader::get_resource_uid);
 
 	BIND_ENUM_CONSTANT(THREAD_LOAD_INVALID_RESOURCE);
 	BIND_ENUM_CONSTANT(THREAD_LOAD_IN_PROGRESS);

+ 1 - 0
core/core_bind.h

@@ -75,6 +75,7 @@ public:
 	PackedStringArray get_dependencies(const String &p_path);
 	bool has_cached(const String &p_path);
 	bool exists(const String &p_path, const String &p_type_hint = "");
+	ResourceUID::ID get_resource_uid(const String &p_path);
 
 	_ResourceLoader() { singleton = this; }
 };

+ 7 - 0
doc/classes/ResourceLoader.xml

@@ -34,6 +34,13 @@
 				Returns the list of recognized extensions for a resource type.
 			</description>
 		</method>
+		<method name="get_resource_uid">
+			<return type="int" />
+			<argument index="0" name="path" type="String" />
+			<description>
+				Returns the ID associated with a given resource path, or [code]-1[/code] when no such ID exists.
+			</description>
+		</method>
 		<method name="has_cached">
 			<return type="bool" />
 			<argument index="0" name="path" type="String" />