Hi there,
I have an editor script that loads image files and creates textures from them and then applies some of them to an object. The script is structured as this:
- Load all texture files
- Create GameObject
- Create mesh for the object
- Add renderer to the object
- Create material for the object
- Apply texture to material
- Apply material to the renderer
It works like a charm, but the thing is that I’m trying to use AssetDatabase.StartAssetEditing right before 1 (Load all textures) and AssetDatabase.StopAssetEditing after 1, so it loads all textures as if it was one asset import block. But if I use it, assets are imported but not added to the material and the gameobject appears untextured.
The Load all texture files part is just a loop that cycles through an array of file paths, copies each file to the assets folder and then loads a Texture2D from the file in the assets folder and stores the reference in an array to be used later on (to be added to the gameobject).
Any idea why that could be happening? Is there something that I need to do before or after calling the AssetDatabase.StopAssetEditing?