- Home /
Display material only in editor
Is there a way to have a material only show in the editor and not ingame but in the editor make it have a certain transparency and texture? Maybe through a customized shader ?
It is supposed to be something like the no collision proxy material in the cryengine:
The method listed in my answer is a perfectly acceptable way of doing it. The only other way that you can do this is checking against Application.platform:
http://docs.unity3d.com/Documentation/ScriptReference/RuntimePlatform.html
I need it to check if its ingame or in editor meaning that if I enter game mode it changes the material. What you are suggesting is that it checks if it is running as a standalone build or in the editor itself and then changes the material appropriately.
Answer by Catlinman · Oct 28, 2012 at 03:53 PM
So here is the code that I eventually came up with:
@script ExecuteInEditMode()
function Start () {
if(EditorApplication.isPlaying || Application.isPlaying){
renderer.material.color.a = 0;
}
else return;
}
Just made a transparent material for the object and attached the script to it.
Answer by dannyskim · Oct 24, 2012 at 03:37 PM
Preprocessor directives, or sometimes called Macros allow you the ability to separate your code depending on the platform that you're currently using, as well as some other things:
http://docs.unity3d.com/Documentation/Manual/PlatformDependentCompilation.html