cancel
Showing results for 
Search instead for 
Did you mean: 
Community Discussions
Connect with fellow community members to discuss general topics related to the Databricks platform, industry trends, and best practices. Share experiences, ask questions, and foster collaboration within the community.
cancel
Showing results for 
Search instead for 
Did you mean: 

Asset Bundle template: ignore file based on variable value

GeKo
New Contributor III

Hello,
I am creating an asset-bundle-template which should be able to include/exclude certain files, depending on the value of a parameter, e.g. if parameter "include_file" is set to true, then the bundle init command should include the template file(s), but if "include_file" is set to false, then the bundle init command shall ignore those file(s).

Is this somehow possible to include/exclude file(s) on bundle init, via a variable ?

many thanks!

1 REPLY 1

Kaniz_Fatma
Community Manager
Community Manager

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.

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!