Added ensure_materials_loaded method to PropCache.

This commit is contained in:
Relintai 2021-08-09 21:05:36 +02:00
parent cbad187673
commit 9ea2951c66
2 changed files with 8 additions and 0 deletions

View File

@ -162,6 +162,12 @@ void PropCache::materials_load() {
}
}
void PropCache::ensure_materials_loaded() {
if (_materials.size() != _material_paths.size()) {
materials_load();
}
}
Vector<Variant> PropCache::materials_get() {
VARIANT_ARRAY_GET(_materials);
}
@ -329,6 +335,7 @@ void PropCache::_bind_methods() {
ClassDB::bind_method(D_METHOD("material_get_num"), &PropCache::material_get_num);
ClassDB::bind_method(D_METHOD("materials_clear"), &PropCache::materials_clear);
ClassDB::bind_method(D_METHOD("materials_load"), &PropCache::materials_load);
ClassDB::bind_method(D_METHOD("ensure_materials_loaded"), &PropCache::ensure_materials_loaded);
ClassDB::bind_method(D_METHOD("materials_get"), &PropCache::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &PropCache::materials_set);

View File

@ -84,6 +84,7 @@ public:
int material_get_num() const;
void materials_clear();
void materials_load();
void ensure_materials_loaded();
Vector<Variant> materials_get();
void materials_set(const Vector<Variant> &materials);