- Home /
[Editor] separate AssetBundle name and variant
I am building a tool for our workflow and I need to know for each string returned by AssetDatabase.GetAllAssetBundleNames() if there is a variant part in it or not.
I have read the online documentation again and again but did not find any way to do it except after building the assets and having a reference to the manifest. I need to do it before building the bundles.
Is there any hidden method to do that? Using UnityEditorInternal maybe?
Answer by menshikh · May 26, 2017 at 09:55 AM
This works for me (Unity 5.5.3):
var m1 = typeof(AssetDatabase).GetMethod("GetAllAssetBundleNamesWithoutVariant", BindingFlags.Static | BindingFlags.NonPublic);
var bundles = (string[])m1.Invoke(null, null);
var m2 = typeof(AssetDatabase).GetMethod("GetAllAssetBundleVariants", BindingFlags.Static | BindingFlags.NonPublic);
var variants = (string[])m2.Invoke(null, null);
This answer has been accepted on good faith since I won't be able to test it again.
Answer by pitimoi · Jul 17, 2015 at 07:27 PM
Hi Tourist,
Are you looking for this information ? http://docs.unity3d.com/ScriptReference/AssetImporter-assetBundleVariant.html
At any time you can get the assetimporter information using AssetImporter.GetAtPath() method and then read the assetbundleVariant value in it.
Yes that would do the trick. Thank you. I was hoping something easier than to scan all asset paths. This a data they have since you can choose between all existing variants.