Loading materials for node in 2.6


Recommended Posts

In 2.5 materials loads automaticaly after using this statement:


Could you provide me how to load materials in 2.6 ?

Same instructions can't find materials' guids.

Log outputs:

Object::setMaterial(): can't find guid "..." material for "mesh..." obejct

Now I solve the problem by using Materials::get()->loadMeterial(path) function with manual pointing to materials' files. Is it more simpliest and/or correct way to load materials?

Edited by shtams
Link to post

Hi shtams!

Materials for NodeReferences are loaded automatically when you call this:


the same way they did in 2.5. So, normally you shouldn't use the Materials manager to load materials and assign them manually one by one.

But in your case the problem seems to be in wrong material GUIDs stored in the *.node file, that you use to create a NodeReference or some sort of GUID mismatch (can't tell you exactly, as you didn't specify the details of your project's migration).

The point is that materials system has changed in 2.6 (see the devlog) and the hierarchy is now based on GUIDs. Make sure you carefully read the content migration guide.

Maybe something went wrong while you were upgrading your project from 2.5 to 2.6.

Try checking if GUIDs of materials assigned to surfaces in the contents of your *.node file are the same as the GUIDs stored in the corresponding *.mat files, that you're loading via Materials::get()->loadMaterial(path) ...

Fixing the mismatches should solve your problem!

Hope this helps!


Link to post

I don't wanna make migration from 2.5 to 2.6 

I just placing model at scene and save node to file, but loading node after that materials missmached.

Link to post

If I put materials in main data_path, works great. But materials wont load from additional data pathes? Why not?

Console command filesystem_list shows that materials loaded to cache at first time.

Link to post

In case of moving .mat files in main data_path and puting textures at additional data_path textures loads, but materials cannot be found at additional data_path.

Link to post

More info here!

I use "filesystem_reload" at runtime.

Case 1:

  1. put .mat in data2
  2. create .ulink file in data1 with text: "c:\data2"
  3. filesystem_list shows c:\data2 in cache
  4. start arguments is "-data_path ../data1"
  5. findMaterialByGUID returns not null

Case 2:

  1. put .mat in data2
  2. create .ulink file in data1 (empty)
  3. start argumets is "-data_path ../data1"
  4. modify .ulink with absolute path to data2
  5. run console "filesystem_reload"
  6. filesystem_list shows c:\data2 in cache
  7. findMaterialByGUID returns nullptr
Link to post

I see, now it's much clearer!

The point is, that the Engine loads all materials from all data folders at startup. At runtime filesystem_reload does add new external folders, but it does not update the list of materials in the Materials manager. So, the only way in your case is indeed to load them manually via Materials::get()->loadMaterial(path)


  • Like 1
Link to post