- Home /
How to remove unneeded references (texture, audio) when doing headless server builds?
I'd like to remove some audio and texture/material references from scenes in headless server builds, to save ram when running servers. What's the best way to do that?
I was thinking about doing it in PostProcessScene but I didn't find a way to check if I'm building a headless build or not.
Bump as I have the same question. I'm also trying to have a $$anonymous$$imal, headless server build.
Answer by Dave-Carlile · Apr 11, 2016 at 08:52 PM
You can add conditional compilation symbols in project settings which could be used to cause code to compile or not. e.g. define HEADLESS, then do something like...
#if HEADLESS
// my code to do stuff when HEADLESS is defined
#endif
Now, I don't know if PostProcessScene allows you to strip out assets, but if so then you could choose to strip them or not by using conditional compilation.
Another option would be to do something with assset bundles - just don't load certain bundles when in headless mode.
You can potentially do something in PostProcessBuild as well, but again, I don't know if you can cause assets to be stripped or not.
Hopefully that gives you enough info to do some more research.
Thanks, I was looking for something like this. $$anonymous$$y understanding is that this directive is only applicable to scripts. How could I use this to remove meshes and materials from prefab GameObjects and scene GameObjects? If this possible, would it also then exclude these files from the build to cut down on the build size?
You can use it to compile the code that does the removal when you do a headless build. As I mentioned in my answer, I don't know how to actually do that other than potentially using asset bundles. The info I gave would the where you could do the stripping - assu$$anonymous$$g it's possible.
Answer by DeMexi · Feb 06, 2018 at 01:57 PM
I know this thread is quite old, but I stumbled upon an asset that does this exact thing for you. It's called Headless Builder, and it's on the Unity Asset Store.