shtams Posted February 20, 2018 Share Posted February 20, 2018 (edited) In 2.5 materials loads automaticaly after using this statement: NodeReference::create(path) 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 February 20, 2018 by shtams Link to comment
fox Posted February 21, 2018 Share Posted February 21, 2018 Hi shtams! Materials for NodeReferences are loaded automatically when you call this: NodeReference::create(path) 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! Thanks! Link to comment
shtams Posted February 21, 2018 Author Share Posted February 21, 2018 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 comment
shtams Posted February 21, 2018 Author Share Posted February 21, 2018 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 comment
shtams Posted February 21, 2018 Author Share Posted February 21, 2018 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 comment
shtams Posted February 21, 2018 Author Share Posted February 21, 2018 More info here! I use "filesystem_reload" at runtime. Case 1: put .mat in data2 create .ulink file in data1 with text: "c:\data2" filesystem_list shows c:\data2 in cache start arguments is "-data_path ../data1" findMaterialByGUID returns not null Case 2: put .mat in data2 create .ulink file in data1 (empty) start argumets is "-data_path ../data1" modify .ulink with absolute path to data2 run console "filesystem_reload" filesystem_list shows c:\data2 in cache findMaterialByGUID returns nullptr Link to comment
fox Posted February 22, 2018 Share Posted February 22, 2018 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) Thanks! 1 Link to comment
Recommended Posts