- Home /
Question by
mohit-mittal · Feb 26, 2019 at 12:47 PM ·
spritetexture2dconvert
Convert texture 2d to sprite and save
Its a editor script: my texture gets downloaded from server and is stored in the assets folder. I have to convert it to sprite using script.
Comment
Solved it: Answering it for anyone who might get stuck like me
TextureImporter ti = AssetImporter.GetAtPath(path + "/background.png") as TextureImporter;
ti.textureType = TextureImporterType.Sprite;
EditorUtility.SetDirty(ti);
ti.SaveAndReimport();