I’m in the early stages of planning mod support for my unity game. I’ve already been working with scanning/loading mod DLLs but now I need to think about assets.
What’s the best way to load an asset (sprites, sounds, etc) from an external path? I can’t use the resource loader because these will come from a mod folder in the Application.persistantDataPath.
I’ve been debating hacking together custom load calls (I’ve found several ways to load images into sprites (example1, example2) - it seems like more effort but also allows modders to provide the assets directly.
Or, I can require asset bundles, which are now possible with all editions of unity. I’d rather not make modders have to use unity for things to work, and I haven’t really looked into how asset bundles work, but I get the concept.
I’m hoping for advice - which method would work best? Are there any hidden dangers or problems with either method I might be missing?
I went the manual text loading/sprite creating/packing from your two examples (example1 is my answer in fact) since asset bundles were only available in the pro editor at the time if I’m remembering right. If you pack the sprites into a sprite sheet you will run into some interesting issues if you want to use anything but point filtering.
I haven’t really done anything to allow modding sounds at this point so I’m not aware of what is available.
I think I would be inclined to try the asset bundle route if I were to do it over again? Maybe? I still have reservations about requiring the Unity install, but they do provide a fairly simple method for adding content. If we could create asset bundles in a standalone app then it would be a no brainer, but to my knowledge that isn’t possible.
I do wish asset bundles could made without Unity, but at least it’s free and the only real cost to future modders is some install time, hard drive space, and a bit more of a learning curve if they’ve never used it before.
However, it will probably be the best bet in the long term. I see that sprites can be loaded but as you mentioned there are some caveats, and as for audio it may be difficult to handle. If I ever want to allow mods to add new scenes or other assets, bundles are probably the only way.
So I’ll give it a try and see how it goes.