Mention MeshLibrary.get_item_preview()
not working in running project
This commit is contained in:
parent
edf9055b7f
commit
a199e2b263
2 changed files with 14 additions and 6 deletions
|
@ -4,7 +4,7 @@
|
||||||
Library of meshes.
|
Library of meshes.
|
||||||
</brief_description>
|
</brief_description>
|
||||||
<description>
|
<description>
|
||||||
Library of meshes. Contains a list of [Mesh] resources, each with name and ID. This resource is used in [GridMap].
|
A library of meshes. Contains a list of [Mesh] resources, each with a name and ID. This resource is used in [GridMap].
|
||||||
</description>
|
</description>
|
||||||
<tutorials>
|
<tutorials>
|
||||||
</tutorials>
|
</tutorials>
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
<return type="void">
|
<return type="void">
|
||||||
</return>
|
</return>
|
||||||
<description>
|
<description>
|
||||||
Clear the library.
|
Clears the library.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="create_item">
|
<method name="create_item">
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
<argument index="0" name="id" type="int">
|
<argument index="0" name="id" type="int">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Create a new item in the library, supplied an id.
|
Create a new item in the library, supplied as an ID.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="find_item_by_name" qualifiers="const">
|
<method name="find_item_by_name" qualifiers="const">
|
||||||
|
@ -80,6 +80,8 @@
|
||||||
<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).
|
||||||
|
[b]Note:[/b] Since item previews are only generated in an editor context, this function will return an empty [Texture] in a running project.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_item_shapes" qualifiers="const">
|
<method name="get_item_shapes" qualifiers="const">
|
||||||
|
@ -94,7 +96,7 @@
|
||||||
<return type="int">
|
<return type="int">
|
||||||
</return>
|
</return>
|
||||||
<description>
|
<description>
|
||||||
Gets an unused id for a new item.
|
Gets an unused ID for a new item.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="remove_item">
|
<method name="remove_item">
|
||||||
|
@ -114,7 +116,7 @@
|
||||||
<argument index="1" name="mesh" type="Mesh">
|
<argument index="1" name="mesh" type="Mesh">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Sets the mesh of the item.
|
Sets the item's mesh.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="set_item_name">
|
<method name="set_item_name">
|
||||||
|
@ -125,7 +127,7 @@
|
||||||
<argument index="1" name="name" type="String">
|
<argument index="1" name="name" type="String">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Sets the name of the item.
|
Sets the item's name.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="set_item_navmesh">
|
<method name="set_item_navmesh">
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#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) {
|
||||||
|
|
||||||
|
@ -201,6 +202,11 @@ Transform MeshLibrary::get_item_navmesh_transform(int p_item) const {
|
||||||
|
|
||||||
Ref<Texture> MeshLibrary::get_item_preview(int p_item) const {
|
Ref<Texture> 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<Texture>();
|
||||||
|
}
|
||||||
|
|
||||||
ERR_FAIL_COND_V_MSG(!item_map.has(p_item), Ref<Texture>(), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
|
ERR_FAIL_COND_V_MSG(!item_map.has(p_item), Ref<Texture>(), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
|
||||||
return item_map[p_item].preview;
|
return item_map[p_item].preview;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue