How to save data outside the resources folder? without assetbundles? like KSP

In the Kerbal Space Program game directory, there's a folder containing all the game resources (icons, sounds, models, textures), but the "Resources" folder is empty. However, when I create a sample game with some sprite models and textures, no folder is created with those files, so I can assume they are "packed". How can I make a game function like KSP, where it stores its resources outside the "Resources" folder and preserves their original formats?

Resources folders and files are bundled in a build into one of these larger .asset files.

But StreamingAssets folder is copied and used verbatim.

If the folder that Kerbal uses isn't named "StreamingAssets" they must have created their own loader. Perhaps this was done by a modding plugin because the only reason why a game would do so is to enable gamers to mod the content.

Note that the application cannot (normally) write to the folder where it is installed. For writable files Application.dataPath should be used.

1 Like


You can use Application.dataPath as a base to locate any folder of your choosing and add custom loader. Note that said folder may be non-writeable.


On PC/Windows, a game will be often installed into a folder writeable without admin privilegies. Basically, on PC a reasonable idea is to design the game in such way that it never requests elevated privilegies, because elevated privilegies mean the APP may be trying to screw up system files. That means Steam will not be installed within program files, but elsewhere.

1 Like


I don't think I've ever had Steam not install itself to "Program Files (x86)". I'd have to look into it to know for certain but I believe an app has permission to modify its own directory once it's been permitted to install there.

9703835--1385708--upload_2024-3-15_15-19-14.png

I like to override it and store on a different drive because it allows me to reinstall my OS without having to reinstall my games library, but it's always defaulted to that folder for me.

1 Like


My steam install is on drive D. D:\Games\Steam. Always has been there. I believe steam works from any folder, it pulls missing files when launched. Main reason not to install onto C:\ is because it is a system drive on SSD, and with steam you'll be eating space there.

Now, it is possible that steam creates writeable permission in Program Files, but at the moment Program Files are treated pretty much like /usr, meaning they should not be writeable without elevated privileges.

From my personal user perspective if an app requests elevated privileges, then it is trying to do something funny and that is suspicious. Proper unity game should work even if it is distributed in a zip archive. You dump it anywhere, and launch it. Installers are untrustworthy, and installers requesting admin rights is probably trying to install unwanted system service.

1 Like


thank you for your response. So would that "custom loader" do the same job as Unity, but only when the game needs it? therefore to have such functionality I should write my own. I have only found information about the Resources folder and asset bundles on Google. Could you provide me with an idea of how to create a "custom loader," a hint on where to look? It would save me days of research.
In this link https://docs.unity3d.com/Manual/AssetDatabaseCustomizingWorkflow.html, they talk about how assets are managed in Unity, but it's not clear to me if the same approach is used for a game that's already built


Unity stores data as assets. Assets are custom, unity-specific data format. On a PC you are allowed, however, to access whatever you want from filesystem, or at least attempt to. So you could create a custom folder, dump files in there, including images, models, and then load anything you want at runtime. However, you would need to handle by yourself how you construct game object out of this. What's more (as far as I rememebr) runtime loading by default is limited, for example, you can load a *.png image from disk, but not a mesh, unless you include extra libraries or write them.

AssetDatabase class is UnityEditor namespace meaning it only exists while you're working on your project in your editor, and once you built the game it is no longer available.

If you want runtime data loading of data, you'll need to look into AssetBundles and Addressables. And if you want users to be able to load data at runtime without need of installing unity, you would likely need to look into creating custom loaders.

2 Likes


Almost anything. If I'm not mistaken shaders can't be loaded as plain text and compiled at runtime.


Hmm.... This seems to be true, as Shader doesn't have a constructor. Most likely reason is that they're facades abstracting away hardware-specific version. But you can hijack shader creation via NativePlugin:

https://github.com/przemyslawzaworski/Unity-Post-Processing-Mod-Tool

Obviously you'll need different plugin for each platform.

1 Like

Do keep in mind that "loading anything" is relative. You will not be able to use all the Inspector settings, for example how a texture should be interpreted as 16-bit RGB565 without transparency or how a mesh is supposed to import materials and set up the avatar, or how a .wav file should be compressed and turned to mono and so forth.

By loading assets manually from their source format you leave many, many Unity asset features by the wayside! This means a lot more work and the asset usage is less efficient.

You also need to track your loaded assets and unload/reload them as needed, there's nothing that automatically unloads unused custom assets nor is there a feature that automatically loads custom assets when they are needed.

Do NOT underestimate this additional development effort and the potential bugs it brings with it!
If there is a custom asset management system that does all this for you on the store, it'll be worth any money they ask for it (unless it's too cheap to be that good).

Got it. Sometimes us enthusiastic developers tend to underestimate the effort/time it takes to develop some system just for the heck of it


It seems the most reasonable to me for now. thank you

1 Like


I don't know about a complete one but there are individual ones like TriLib which handles models.

https://assetstore.unity.com/packages/tools/modeling/trilib-2-model-loading-package-157548