Allow using `MeshLibrary.get_item_preview()` in non-editor builds again

This closes #36268.
This commit is contained in:
Hugo Locurcio 2020-02-17 00:01:52 +01:00
parent c837dd4408
commit 64fac9dd5d
No known key found for this signature in database
GPG Key ID: 39E8F8BE30B0A49C
2 changed files with 1 additions and 8 deletions

View File

@ -84,8 +84,7 @@
<argument index="0" name="id" type="int"> <argument index="0" name="id" type="int">
</argument> </argument>
<description> <description>
Returns a generated item preview (a 3D rendering in isometric perspective). When running in the editor, returns a generated item preview (a 3D rendering in isometric perspective). When used in a running project, returns the manually-defined item preview which can be set using [method set_item_preview]. Returns an empty [Texture2D] if no preview was manually set in a running project.
[b]Note:[/b] Since item previews are only generated in an editor context, this function will return an empty [Texture2D] in a running project.
</description> </description>
</method> </method>
<method name="get_item_shapes" qualifiers="const"> <method name="get_item_shapes" qualifiers="const">

View File

@ -29,7 +29,6 @@
/*************************************************************************/ /*************************************************************************/
#include "mesh_library.h" #include "mesh_library.h"
#include "core/engine.h"
bool MeshLibrary::_set(const StringName &p_name, const Variant &p_value) { bool MeshLibrary::_set(const StringName &p_name, const Variant &p_value) {
@ -202,11 +201,6 @@ Transform MeshLibrary::get_item_navmesh_transform(int p_item) const {
Ref<Texture2D> MeshLibrary::get_item_preview(int p_item) const { Ref<Texture2D> MeshLibrary::get_item_preview(int p_item) const {
if (!Engine::get_singleton()->is_editor_hint()) {
ERR_PRINT("MeshLibrary item previews are only generated in an editor context, which means they aren't available in a running project.");
return Ref<Texture2D>();
}
ERR_FAIL_COND_V_MSG(!item_map.has(p_item), Ref<Texture2D>(), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'."); ERR_FAIL_COND_V_MSG(!item_map.has(p_item), Ref<Texture2D>(), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
return item_map[p_item].preview; return item_map[p_item].preview;
} }