I have a bunch of ScriptableObjects stored in the Assets folder as .asset files. Each asset contains a number of child assets, and in Unity 4 adding those assets to a bundle worked without a problem.
Example file structure:
Assets/Scripts/ItemData.cs // Contains the ItemData class, which inherits from ScriptableObject
Assets/Data/ItemData.asset
- ItemData // This one is created automatically as blank template
- item_potion // These contain serialized data for individual items
- item_antidote
...
In Unity 4, I could load each individual child asset (e.g. "item_potion") by using AssetDatabase.LoadAllAssetsAtPath("Assets/Data/ItemData.asset") and passing the resulting list of Objects to the BuildPipeline bundle building functions.
In Unity 5, I run into the following problems:
1. Selecting the parent asset (e.g. ItemData.asset) in the project view results in a blank Inspector window, which is also missing the Asset Labels subsection (the one where you can set which bundle to include an asset in).
2. Selecting one of the child assets (e.g. item_potion) in the project view results in the ScriptableObject details appearing in the Inspector (same behavior as Unity 4), and the Asset Labels section appears, but does not contain the dropdown boxes to actually assign an asset bundle.
3. Assigning a bundle to each of the child assets via script, by fetching their AssetImporters and setting the assetBundleName property, works for setting the bundle name on the asset, but attempting to build the actual bundle results in a warning of "Unrecognized assets cannot be included in AssetBundles". This occurs when adding the parent asset or any of the child assets, and it occurs with BuildPipeline.BuildAssetBundles() (including any of the variants that take a list of AssetBundleBuild objects).
4. The original Unity 4 functionality does not seem to be working either, for reasons that are not clear to me at the moment.
Is there any way around this? I'm fine with setting the bundle names via script instead of the editor gui, but not being able to export the objects in a bundle is a huge problem. Currently using Unity 5.2.1, if it makes a difference.
↧