is there an Alternative for Unity's Resources?

I am making a game where I have to load a “Module” that gets used as a customizable feature of a vehicle. This will be a big list of modules eventually. Right now i am trying to use XML files to store the information about the modules and in the future a editor tool to further help with custom features.

However I am running into an issue: I have no idea how to store information about the model (or preferable prefab), I have tried all the naïve aprouches already like: storing a gameobject refrence, a path to a model(but couldn’t import it and a refrence to a Resource file. The last one kinda works but I hear people say that I have to stay away from Resources for some reason, they say it’s only for prototyping. Is that true? and if so is there an alternative or should I just use an entirely different approach?

Resources can still be used, but it’s generally suggested to start moving away from it. Direct references or using addressables may be a better method now. Addressables have a huge advantage in that the file can reside anywhere in your project (and remotely if needed) and be loaded in. It does require a little more code, but I would say look into them if you’re trying to get away from resources.

Addressables are what you need to learn about. They work very similarly to Resources (in fact these days Resources basically acts as a simplified wrapper for one inflexible configuration of Addressables) but they have much better memory management and will support advanced features later without needing to change code (such as streaming assets from a server, for example). Addressables also supports something called AssetReference, which allows you to drag an addressable asset into an inspector like you would use a direct reference, but it won’t take up memory until it’s instantiated. Basically, Addressables are the best of all worlds… with the downside being that they’re relatively new and not exceptionally well documented, which makes them a little tougher to learn about.

wow, fast replies thx.

Anyways i kinda read into it and will give it a shot. Will it be as moddable as for example loading a .obj model. As in can people add their own models after export?

There is a possibility that users could use the Unity editor and a package you could release to them to build their own AssetBundles, and Addressables could be a way into this. That’s a pretty tricky and intricate system, but it is possible through AssetBundles.

Depending on the level of modding support you need it may be simpler to not go through Addressables for it, though. A built Unity player can’t read files like .obj (it expects files to come in via stuff built through the Unity editor), but you can get third-party packages on the Asset store to allow your player to load .obj files, and once you have that file as a Mesh you can put that anywhere.

That kind of modding is definitely less tricky and obfuscated than using Addressables, but it wouldn’t support things like letting modders add and configure components on objects to create their own prefabs, like Addressables would.

1 Like

Thanks so much for the input!
I am keeping the Adressables in mind.
I found a simple obj loader script on the unity wiki. I will use that to load the models and I will bake the textures and use my “tool” to do all the manipulations that a prefab would have.

Agreed here. OP you should consider making a fresh project and simulating some of the asset packaging and delivery steps you contemplate there, using the Addressables method. There is enough noise and churn and chuff to learn that you will probably want to do it two or even three times to make sure you understand all the terminology and how it all relates to your assets.

Once you have it kinda nailed down and understood, then think about how it would integrate with your actual project.

Kurt great idea, I kinda am already doing that buy having my code just return simple debug stuff like text and simple meshes. then when that works I’l intergrate. This whole game that I’m making is a “distraction” from my main project in hopes of learning more to work on that.

Oh and BTW Having alot of fun in your kurt pilot game/demo!

1 Like