Added function ResourceLoader.exists(), to check if a resource exists. Closes #19140

This commit is contained in:
Juan Linietsky
2018-08-10 15:57:43 -03:00
parent 767fb2fa0b
commit 852378109f
4 changed files with 45 additions and 4 deletions

View File

@@ -112,11 +112,15 @@ PoolStringArray _ResourceLoader::get_dependencies(const String &p_path) {
return ret;
};
bool _ResourceLoader::has(const String &p_path) {
bool _ResourceLoader::has_cached(const String &p_path) {
String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
return ResourceCache::has(local_path);
};
}
bool _ResourceLoader::exists(const String &p_path, const String &p_type_hint) {
return ResourceLoader::exists(p_path, p_type_hint);
}
void _ResourceLoader::_bind_methods() {
@@ -125,7 +129,8 @@ void _ResourceLoader::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_recognized_extensions_for_type", "type"), &_ResourceLoader::get_recognized_extensions_for_type);
ClassDB::bind_method(D_METHOD("set_abort_on_missing_resources", "abort"), &_ResourceLoader::set_abort_on_missing_resources);
ClassDB::bind_method(D_METHOD("get_dependencies", "path"), &_ResourceLoader::get_dependencies);
ClassDB::bind_method(D_METHOD("has", "path"), &_ResourceLoader::has);
ClassDB::bind_method(D_METHOD("has_cached", "path"), &_ResourceLoader::has_cached);
ClassDB::bind_method(D_METHOD("exists", "path", "type_hint"), &_ResourceLoader::exists, DEFVAL(""));
}
_ResourceLoader::_ResourceLoader() {