From 14fb9358fc216527317dc38365effd8bd3375c95 Mon Sep 17 00:00:00 2001 From: Ryan <73148864+Ryan-000@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:05:29 -0500 Subject: [PATCH] Expose ResourceLoader::get_resource_type and ResourceLoader::get_resource_script_class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Pedro J. Estébanez --- core/core_bind.cpp | 10 ++++++++++ core/core_bind.h | 2 ++ doc/classes/ResourceLoader.xml | 15 +++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 66bf5f41e14..dff3005dfb4 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -132,6 +132,14 @@ ResourceUID::ID ResourceLoader::get_resource_uid(const String &p_path) { return ::ResourceLoader::get_resource_uid(p_path); } +String ResourceLoader::get_resource_type(const String &p_path) { + return ::ResourceLoader::get_resource_type(p_path); +} + +String ResourceLoader::get_resource_script_class(const String &p_path) { + return ::ResourceLoader::get_resource_script_class(p_path); +} + Vector ResourceLoader::list_directory(const String &p_directory) { return ::ResourceLoader::list_directory(p_directory); } @@ -151,6 +159,8 @@ void ResourceLoader::_bind_methods() { ClassDB::bind_method(D_METHOD("get_cached_ref", "path"), &ResourceLoader::get_cached_ref); 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); + ClassDB::bind_method(D_METHOD("get_resource_type", "path"), &ResourceLoader::get_resource_type); + ClassDB::bind_method(D_METHOD("get_resource_script_class", "path"), &ResourceLoader::get_resource_script_class); ClassDB::bind_method(D_METHOD("list_directory", "directory_path"), &ResourceLoader::list_directory); BIND_ENUM_CONSTANT(THREAD_LOAD_INVALID_RESOURCE); diff --git a/core/core_bind.h b/core/core_bind.h index 3b0442bd65a..bd9925460df 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -85,6 +85,8 @@ public: Ref get_cached_ref(const String &p_path); bool exists(const String &p_path, const String &p_type_hint = ""); ResourceUID::ID get_resource_uid(const String &p_path); + String get_resource_type(const String &p_path); + String get_resource_script_class(const String &p_path); Vector list_directory(const String &p_directory); diff --git a/doc/classes/ResourceLoader.xml b/doc/classes/ResourceLoader.xml index ae862dd52f1..028a1458c62 100644 --- a/doc/classes/ResourceLoader.xml +++ b/doc/classes/ResourceLoader.xml @@ -60,6 +60,21 @@ Returns the list of recognized extensions for a resource type. + + + + + Returns the global script class name a given [param path], as set by the [code]class_name[/code] keyword in GDScript or the [code][GlobalClass][/code] attribute in C#. + If there is none, it returns an empty string. + + + + + + + Returns the type of the resource at the given [param path]. + +