I am working on a clean plugin for this (and to convert to static mesh) but until then, the below works. Here’s what I have so far for the plugin:
Let me preface this by saying I spent ages trying to figure out a very simple, easy method for my players to add their own mesh objects to my game, without requiring them to install the unreal editor or have access to the game code. I wanted it to also be super easy to integrate with Steam Workshop. The method may or may not be the best, and definitely could use refinement. This is ONLY for basic mesh objects and will NOT work for skeletal mesh!
This will be in blueprint but I heavily suggest converting to code. The blueprint is simply a ‘proof of concept’ for me and was later converted and refined to code. However, it does work fine out of the box.
I’m sharing this because I honestly couldn’t find any other method that was similar to this anywhere. My goal was to have a simple folder players can drag and drop mesh objects and their materials into and it’d run just like that on startup. I’ve named the folder ‘Mods’ because I plan to expand further, but name it whatever you like.
This uses the Runtime Mesh Loader plugin. The plugin was originally abandoned but picked up by bubikhonza, much credit to them! GitHub - bubikhonza/RuntimeMeshLoaderUE5: RuntimeMeshLoader for UE5
Moving on.
First, you need to create the folder. If you don’t want to do it manually for your packaged game then just have the game create it automatically at startup. I have a custom empty panel which does this when it’s constructed. That way it is only being checked for if the player actually opens this panel with the intent to use custom objects.
The widget:
Here’s the big ol’ bp spaghetti. This can very much be broken down and simplified but is good for initial testing: CustomSelectPanelWidget posted by anonymous | blueprintUE | PasteBin For Unreal Engine
Next, you will need to add a button widget. The system loops over each subdirectory in the ‘Mods’ folder, and for each directory it will find the .fbx files within and create a simple button that stores that file path. This button is added to the grid. The reason I go through each directory individually is that I can easily separate them by category (in essence, which ‘pack’ it came from) to better organize later. You can simplify this if you want or even make it more complex.
Where to add the button:
The button code is simple. It basically just calls to the parent (the selection widget) when clicked and sends it’s info to the ‘Create Custom Object’ event. All this even does is spawn the actor wherever you want it. What’s important is that you have a string variable called FilePath exposed on spawn/instance editable.
Finally the actual object class itself. For me this is a child of my master object class. The key element here is that we’re using the LoadMesh function that comes with the plugin mentioned at the beginning of this whole thing. I’m basically just setting the main object mesh invisible (since it is a child class of the master) and the default mesh is never populated anyway. I am instead building a procedural mesh component onto the actor.
Spaghetti: CustomObjectActorBP posted by anonymous | blueprintUE | PasteBin For Unreal Engine
Note that I am setting the procedural mesh to visible after building it. It defaults to invisible (probably because of my master class).
Also, I am setting up materials afterward. I have a ‘base’ material with three texture parameters; BaseColor, Normal and OARM. I get these by comparing the name of the fbx object to any objects in the associated folder that end with _basecolor.png, _normal.png and _RM.png.
And that’s it. Load up the game, open up your version of the selection panel, click the new button for your custom fbx, and it will spawn in the game world. No having the players download anything or messing with your game code or editors, etc. Literally just have them drop their fbx and associated textures in the folder.
As a final note, there are cleaner ways to do this, like building a proper custom editor for your players, but I wanted a quick and simple means to go about it. I’m happy to support other ideas, too. The above has a lot of extra checks and whatnot and is entirely a proof of concept, so please do clean it up and refine it if you use it.
I’ve never written anything like this or any sort of tutorial or whatever, so please forgive me if I leave anything out or if it’s difficult to follow!