Hi @GeKo,
Excluding Assets from Unity Builds Using AssetBundles
Excluding Assets from the Main Game Build
There are a few ways to exclude assets from the main game build in Unity while still using them in AssetBundles:
1. Organize Assets into Subfolders: One approach is to organize your assets into subfolders, with one folder for the demo/release version and another for the full version. When building the demo, you can manually move the release folder out so that those assets are not included.
2. Use the Resources Folder: The Resources folder is a special folder in Unity where assets can be loaded at runtime without being included in the main build. However, this approach is not recommended for larger projects as it can lead to performance issues.
3. Leverage Addressables: Unity's Addressables system provides a more robust way to manage and load assets dynamically. With Addressables, you can easily include or exclude specific assets from the build based on your needs.
Excluding Assets from AssetBundles
To exclude specific assets from being included in an AssetBundle, you can use the following methods:
1. Assign Assets to AssetBundles Manually: In the Unity Editor, you can manually assign assets to specific AssetBundles by selecting the asset and examining the Inspector. This allows you to control which assets are included in each bundle.
2. Use an AssetBundle Browser Tool: Unity provides an AssetBundle Browser tool that allows you to view and edit the configuration of AssetBundles in your project. This can be helpful for managing which assets are included in each bundle.
3. Programmatic AssetBundle Building: You can write a custom script that programmatically builds your AssetBundles, allowing you to control which assets are included based on a parameter or condition. The search results provide examples of how to do this using the `AssetBundleBuild` and `BuildPipeline` classes.
Handling Dependencies
When excluding assets from the main build, it's important to ensure that any dependencies are also properly managed. Unity 5 and later versions automatically handle dependencies between AssetBundles, so you don't need to worry about this as much. However, it's still a good practice to carefully plan your asset organization and bundle structure to minimize redundancy and optimize performance.
Conclusion
In summary, the key approaches to excluding assets from the main Unity build while using them in AssetBundles are:
1. Organizing assets into subfolders and manually managing the build
2. Leveraging the Resources folder (not recommended for larger projects)
3. Using the Addressables system for more robust asset management
4. Manually assigning assets to AssetBundles or using the AssetBundle Browser tool
5. Programmatically building AssetBundles with custom scripts
By following these strategies, you can effectively exclude specific assets from the main game build while still utilizing them in your AssetBundles.