diff --git a/singleton/prop_cache.cpp b/singleton/prop_cache.cpp index a7a1059..f7d6bd0 100644 --- a/singleton/prop_cache.cpp +++ b/singleton/prop_cache.cpp @@ -128,6 +128,12 @@ void PropCache::material_add(const Ref &value) { _materials.push_back(value); } +Ref PropCache::material_get(const int index) { + ERR_FAIL_INDEX_V(index, _materials.size(), Ref()); + + return _materials[index]; +} + void PropCache::material_set(const int index, const Ref &value) { ERR_FAIL_INDEX(index, _materials.size()); @@ -363,6 +369,7 @@ void PropCache::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::POOL_STRING_ARRAY, "material_paths"), "material_paths_set", "material_paths_get"); ClassDB::bind_method(D_METHOD("material_add", "value"), &PropCache::material_add); + ClassDB::bind_method(D_METHOD("material_get", "index"), &PropCache::material_get); ClassDB::bind_method(D_METHOD("material_set", "index", "value"), &PropCache::material_set); ClassDB::bind_method(D_METHOD("material_remove", "index"), &PropCache::material_remove); ClassDB::bind_method(D_METHOD("material_get_num"), &PropCache::material_get_num); diff --git a/singleton/prop_cache.h b/singleton/prop_cache.h index eb5e6b6..3055f4a 100644 --- a/singleton/prop_cache.h +++ b/singleton/prop_cache.h @@ -79,6 +79,7 @@ public: void material_paths_set(const PoolStringArray &array); void material_add(const Ref &value); + Ref material_get(const int index); void material_set(const int index, const Ref &value); void material_remove(const int index); int material_get_num() const;