- Home /
Unity Custom Editor Texture Warning
Hi there,
I would like to know how can I display a texture warning according to the texture type. Is it possible to display a warning depending on the selected texture type (Texture, Normal, GUI, etc.) ? How ?
Texture2D t = textureProperty.objectReferenceValue as Texture2D;
t = EditorGUI.ObjectField(rect, t, typeof(Texture2D), false) as Texture2D;
textureProperty.objectReferenceValue = t;
// if the texture is Normal, GUI or whatever, display a warning or anything.
Thanks a lot.
Thanks for your answer, I already saw that but it needs to always import the texture and I don't think that its good for performances even in the Editor.
Just tested and it works, I'm not sure how performance hungry this thing. I don't know any other way to do that.
Alright, thank you. I've accepted your answer but you could maybe add some details.
Answer by Positive7 · Sep 03, 2015 at 08:41 PM
http://docs.unity3d.com/ScriptReference/TextureImporter.html
TextureImporter.textureType; in if()
statement should do the trick. Haven't tried it yet.
Answer by Jessespike · Sep 03, 2015 at 08:59 PM
Right but as I said in the comments, it needs to always import the texture and I don't think that its good for performances even in the Editor.
I thought that there was a better or elegant way than searching for the path, Importing the asset, creating the TextureImporter etc. inside on GUI even if we can check for any change to reduce performance costs.
Assets aren't actually imported until you call SaveAndImport() or AssetDatabase.ImportAsset(), reading a path then reading textureSettings shouldn't cause performance issues.