I have some code that uses AssetDatabase.LoadAllAssetsAtPath(string assetName) to create some assets that are put into an asset bundle. The assets are mostly images and text. The code looks like this:
foreach(string assetPath in assetPathsList) { UnityEngine.Object[] assets = AssetDatabase.LoadAllAssetsAtPath(assetPath); foreach(UnityEngine.Object asset in assets) { writer.WriteLine(assetPath + "::" + asset.name + " (Type: " + asset.GetType().ToString() + ")"); assetList.Add(asset); } }
For most of the assets I expect the size of the array to be 1 but in every case I get back two assets in the array. Here's some of the output:
Assets/Text/file.xml::file (Type: UnityEngine.TextAsset) Assets/Text/file.xml:: (Type: UnityEngine.Object) ... Assets/Graphics/image.png::image (Type: UnityEngine.Texture2D) Assets/Graphics/image.png:: (Type: UnityEngine.Object)
file.txt is an xml file and so is correctly listed as a TextAsset. But what is the second one shown as a UnityEngine.Object? You can see similar results with the png. There is the expected UnityEngine.Texture2D and then the mysterious UnityEngine.Object. What is that?