Any way to let users create scenes or prefab in one project and load them at runtime in another?

I already asked this questions in the forum but didn’t get a single response. I figured that maybe a different crowd is reading the “Question” section, so, I’m asking the same thing here. Hope that’s okay.

Sorry, I had a really hard time coming up with a title that really explains what I want. My apologies, it will probably become quiet lengthy but I think there’s no super simple way to describe my problem.

Here’s my situation: I’m in the earlier stages of creating a 2D game for which I want to add mod support. I’ll add some light modding like outsourcing config values into JSON files, etc.But it’d also be great if users could e.g. make their own levels or change existing ones. But how to go about it?

One way would surely be to write my own level editor and save/load levels from text files. But writing a good level editor would be a huge amount of work and I’d only reinvent the wheel and still end up with something that’s worse than a lot of great tools out there already offer.
Right now, I’m using Tiled and Tiled2Unity with some custom importers and those are excellent and provide far more than what I could ever create myself in a reasonable amount of time.

Now, I’d like users to be able to use this tools too (including Unity), because they’re free and come with a lot of functionality and it would be a shame not to leverage it. No sense in spending time creating tools that are worse than what’s already available anyway.
Of course, the easiest would be to just share the whole Unity project. But this comes with a few disadvantages:

  • Most importantly, I couldn’t use any assets i bought on the asset store because I wouldn’t be allowed to distribute them
  • That way, every mod would have to have it’s own build of the game. You couldn’t just create a mod, drop it into a folder and the game could load it alongside other mods. If you wanted a specific mod combination, you’d have to gather the assets of every single mod, add them all in the same Unity project and rebuild the game. That’s way more cumbersome and impractical than I’m aiming for.
  • I wouldn’t feel comfortable sharing all of the code/assets. It’s not about piracy protection (if someone wants to play a game for free, there’s always a way) but more about a gut feeling and also about not presenting asset flippers a project on the silver platter.

Optimal way I’d wish for: What I would like best is a situation where I have two projects:

  • One Project is the “core” project, if you will. This contains the core of the game logic. It would have a start scene that’s able to detect user generated scenes/prefabs within the folder structure of the game, let the user chose what to load, then do so. This project would also contain all the classes, etc. used by the game.
  • The other project would be a user project. It would contain only a part of the source code (the one needed to create levels, etc.) as *.dll files as well as some prefabs also used for world building and similar stuff. This project could be used to import maps via Tiled2Unity, and enhance them with the scripts and prefabs I’d provide in this project (think doors, NPCs, signs, etc.). Now here’s the tricky part: After importing and editing the map, the user would/should be able to somehow export this data to the disk in a way that it could be read and imported by the core project at runtime again. And that’s where I’m absolutely stuck at.

I feel like this approach, if somehow achievable, would be a great way to protect resources like bought 3rd party assets (if anyone has another idea how to solve this, that’s welcome too, of course).

Let’s say I buy some kind of shader. I could only put that shader in the core project and create a “ShaderDummy.cs” MonoBehaviour that’s known to both projects. The user can then (in the user project) put the ShaderDummy script on every game object that should receive this shader.

When the scene/prefab gets loaded later on by the core project, the core project could just iterate through every single game object at the beginning and replace the ShaderDummy script with the respective shader component.

How to go about it?
Like mentioned above, I have really no idea if/how this could be achieved. And I did a few hours of research. So, there either isn’t really something out there explaining how this problem could be tackled or it’s just way above my level of understanding.

Of course I stumbled upon asset bundles but I’m really not sure that’s the way to go. As far as I understood (sadly, tools and information about them are scattered and not too easy to understand imho), you can only use asset bundles in the same project they were created in, which would not work with the "a core project and a project for users to generate content with)-approach. Also, if I got this right, every time I’d update the Unity project to a higher version, chances are that most asset bundles will break and need to be recreated again too, which in turn means, mods would break every time I update the project.

Can it really be that hard to create a bunch of prefabs that can be saved to disk and imported at run time or am I missing the obvious?

Any kind of suggestion is appreciated greatly, since I’m really stuck on this and absolutely have no idea how to properly go about it.

If you need any more info, feel free to ask!

Thank you very much!

just use asset bundle for model or scene or anything asset related u cant load code using that way u have to implement an interpreter or u can always use cs script or lua its not hard to be very honest