- Home /
AssetDatabase.LoadAssetAtPath is null? Any way to load Sprite asset?
AssetDatabase.GetMainAssetTypeAtPath for the same path is Texture2d.
I remember that I used same code a few years ago but now AssetDatabase.LoadAssetAtPath returns null. Is something changed with this api?
How to load Texture2d as a Sprite? Surprisingly I was unable to google something useful on this issue...
Answer by haruna9x · Feb 05, 2019 at 03:13 PM
You load a Texture2D as a Sprite, this is not possible. You can change the import settings to Sprite and load it as a Sprite. Or you have to create the Sprite at runtime, use Create function.
Окаy, so I made a preset with sprite settings and applied it to texture. Then I tried to receive this texture as Sprite once more, but AssetDatabase returns null. $$anonymous$$aybe I need somehow refresh asset database after preset apply...