I’m going to explain my problem using screenshots.
During runtime I create a RenderTexture that is shown using the Standard shader set up to use rendering mode “fade”. In the editor it looks fine, casting a shadow and being transparent:
I haven’t changed any code at all between taking these screenshots, the only difference is that I add that green quad in the editor. Somehow this affects how Unity is building the standalone exe.
How can I make the Standard shader work correctly without having to use a Standard shader in the scene that is created inside the Unity Editor? (I need to create all my textures and materials via script during runtime.)
I just noticed that this is also true if I want to make the Standard shader emissive.
myMeshRenderer.material.SetColor("_EmissionColor", new Color(1f, 1f, 1f));
myMeshRenderer.material.EnableKeyword("_EMISSION");
(The material is created from new Material(Shader.Find(“Standard”)) and then configured correctly to use the rendering mode “fade”.)
In the Unity Editor the texture gets a white overlay. If I Build & Run a standalone exe the texture does not.
HOWEVER if I also add emission to the green dummy quad via the Unity Editor and then Build & Run a standalone exe THEN the texture appears like it should.
What magic is this? What is the Unity Editor doing to make these things work all of a sudden?
Note that the GameObject I work with in the Unity Editor has nothing to do with the material that is created via code yet somehow simply because it is there in the scene it somehow affect the stuff I create in C# and enables alpha (original topic of the thread) and emission to work correctly.
For me I spent a lot of time and finally find out that it’s because my Standalone app uses default Graphics Quality: Fastest, but in Editor the default graphics quality seems to be Fantastic, which causes some texture behavior differences. Edit->Project Settings->Quality->Choose “Fastest” and then change “Texture Quality” from “Half Res” to “Full Res” and everything in Standalone build goes the same with Editor.