AssetBundle.mainAsset can't be checked wihtout getting an error message

Hi community,

when we are loading asset bundles with our application, we are getting following error message for example:

“AssetBundle pasted__roof.geometry doesn’t have main asset!

As we understand this error message, unity is throwing this error because the mainAsset of the loaded assetbundle is null. The strange thing about this is, that we are getting this error message when we are checking the mainAsset for null.

Example code:

if(assetBundle.mainAsset == null)
//DO Something
//DO Something else

It’s very strange to have this error because we are trying to react on the main asset if it’s null or not. Is their any other solution for hanlding the mainAsset when it’s null?

My Unity threw the same error.

AssetBundle ab;
Object mainAsset;
try {mainAsset = ab.mainAsset;}
catch {mainAsset = null;}

I couldn’t catch the error.