Building MeshLibrary from EditorScript, how to load material

MikeWieringMikeWiering Posts: 3Member

I'm using an EditorScript to build a MeshLibrary and it sort of works, it sets the MeshLibrary as the theme for my GridMap and I can place meshes and it looks great in the editor.

However, when I run the game, everything is black.

What I'm doing is:

var mlib =
var mesh1 = CreateMesh(1)
mlib.set_item_name(0, "0")
mlib.set_item_mesh(0, mesh1)
get_scene().get_node("GridMap").theme = mlib

In CreateMesh I create the material and set it to the surfacetool:

var image_texture =
var image =
mat.albedo_texture = image_texture

I get a warning:
core/image.cpp:1587 - Loaded resource as image file, this will not work on export: 'res://Map1.png'. Instead, import the image file as an Image resource and load it normally as a resource.

I'm not sure what is meant with that advice.

Now I can get it to work by browing through the Inspector and going to tile 0, finding AlbedoTexture and dragging the file there manually. Then running the game works. But then it gets lost again every time I rerun the script.
So what is the correct way to load the texture?

Also, I'm now getting the following error whenever I save the EditorScript:
scene/3d/spatial.cpp:267 - Condition ' !is_inside_tree() ' is true. returned: Transform()
Resource was not pre cached for the resource section, bug?

I'm using the latest build I could find of Godot 3.1 dev

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file