Can I do this with editor scripting?

Hi,

I have my own sprite system. I now updated it so it shows stuff in the editor too (like SM2). Problem is that this way it already sets all materials to the renderers, and this will be serialized. This is a problem because I want to load materials dynamically based on the screen resolution (for iPad and retina devices I use different textures).

So can I write an editor script that when building automatically goes to every scene, loops through all objects, and if it has my sprite class attached it removes the material reference?
Alternatively I can create an editor window with a button that does this, but it would be more convenient if it was automatic.

Any other options? I don’t think I can tell a renderer not to serialize it’s material property, right? Maybe by inheriting from it in another class and using that as a component? (edit: nope, “cannot derive from sealed type `UnityEngine.MeshRenderer’”)

Thanks!

Ok, this is no longer needed since I found another solution.
In case anyone is wondering : Instead of setting the material’s to null, I have written an editorscript (which I have to trigger manually) that goes through all materials in my assets folder (with System.IO since I didn’t find a method that does this) and sets their textures to null. I then load their textures with Resources.Load. That’s good enough for my needs.