Skip to main content

Excluding Assets From Build

Similarly to a widespread proverb "the fastest code is the code which does not run", the easiest way to reduce build size is to remove some assets completely. As outlined briefly in the previous section, it is sometimes useful to completely eliminate certain things, especially the ones residing in Resources folder so that they don't take space in the build. Luna (and Unity) is unable to do that automatically as user code can always request loading of an asset with Resources.Load API with the name constructed dynamically, thus Luna has to keep everything in resources folder. There are a few options available to aid the situation.

How Luna exports using your game scene

By default Luna detects all assets in use by the scenes you have selected in the plugin window, this includes: all prefabs, textures, animations and other resources found in the project.

Whilst this strategy often produces undesirably big builds, especially with games which have a lot of assets, it is a preferable starting point because it helps avoid issues caused by misconfiguration and eases debugging of first exports.

If you wish to include additional resources you can:

  • Select "Resources" to include the Resources folder
  • Select "Streaming Assets" to include the Streaming Assets folder
  • Manually include specific assets as documented here


If you want to start thinning down your build a good place to start is with excluding assets, which is explained below.

Excluding or including individual assets

There are instances when more fine control is needed: for instance, you might have 20 prefabs for different levels, but you know your playable ad will only load the first 3. Instead of reorganizing your project structure, you can force Luna to include specific assets or, otherwise, force to exclude specific ones.

This can be done simply by navigating to the Assets section and the Assets tab, and marking an asset or even a whole folder in corresponding parts of the screen:


Force-include always wins

Please note that "Force Include" section has the highest priority: assets selected there will get into the build along with their dependencies even if they are excluded by all other means.

Luna Asset Hints in Project Browser

Playable Plugin also provides a tool that highlights assets in your project window depending on if they have been marked for force-inclusion or force-exclusion.

How to enable

To enable this tool click the button with the Luna logo along to the left of the project window search bar (circled in the image below).


Highlight key

  • Opaque (solid) Green: Assets currently marked for force-inclusion.
  • Opaque (solid) Red: Assets currently marked for force-exclusion.
  • Transparent Red: Assets that were excluded in the last build.
  • Transparent Green: Assets that were included in the last build.
  • Yellow Outline: Assets that were referenced in the previous build, but were not included.

Display settings cog for assets

Hitting the alt key (Windows) or the option key (Mac) will toggle showing a settings cog icon on all files in your project window, clicking on these cogs will show you the available Playable Plugin settings that you can configure for that asset (example in the image below).


Luna Assets Context Menu

You can also access options for you assets by the right click menu in Unity; simply right click on an asset and hover over the 'Luna' context menu to expand it and see the available options for that asset (example in the image below).


Next steps

The previously listed controls should be sufficient to configure any sort of membership of assets within a given project. Please note that Luna export will do its best to avoid broken references and otherwise invalid state: it will propagate inclusion status to any dependencies, i.e. include textures referenced by a material if the material gets it into the build.

It is possible, however, to break that. For instance, one can accidentally force-exclude a texture used by a material on the scene that is not a member of "Force Include" section, so excluding the assets must be done with care. Nothing is irreversible, though: Luna will never delete anything from a Unity project and restoring any previous settings is as easy as checking out a previous version of luna.json file shall a developer accidentally break a Luna build by excluding too many assets.

If all assets are excluded, but the build size is still undesirably big, it is a good time to try applying specific compression settings to individual items as described in the Optimising Assets section.