Hi everybody, i am trying to load UMaterial from uassert files using the path, this material aren´t in the editor, only i have the file, this is the code:
UMaterial* mat = Cast<UMaterial>(StaticLoadObject(UMaterial::StaticClass(), nullptr, *sPath));
if (mat != nullptr) {
Dyn = UMaterialInstanceDynamic::Create(mat, Mesh);
UE_LOG(LogTemp, Warning, TEXT("material "));
}
the problem is never encounter the material but when i add the material to the project works, is it possible use a material witout the material is in the editor?
The editor processes and packages up all kinds of assets as part of the build process (and while you edit, in the background, so that you can preview these.)
Without having the built asset, you cannot use it in the game.
If you’re making a plugin, plugins can have their own Content directory, where you can put input assets used by classes in that plugin.
I am doing a function,which created terrain reading different files, every terrain have a different file and i can create more terrain adding more file, and my idea is, the texture,the material, can be added reading a file because i need the user can add his texture using his texture file for create different terrain without the editor only the proyect after packing.
i need the user can create different terrain without use the editor, but If It is not posible, i Will add different material and i Will get a list with the different material.
You can make the texture be a parameter of the material, and create a dynamic material instance, and then configure a runtime generated (loaded) texture into that material.
A: terrain → material → Dynamic Material Instance (“MID”)
B: texture on disk → bitmap in RAM → Runtime texture
Configure B as the texture parameter on A. Done!
You may need to use a little bit of C++, but there’s reasonable suggestions of a few different approaches:
It mainly boils down to using something like Ramas plugin (or writing your own similar C++ code):