The problem is that Unity on Windows uses DirectX, not OpenGL, so it works there (as mentioned in the comments to your question).
Unity -force-opengl Windows, , .
. http://answers.unity3d.com/questions/447206/forcing-opengl-in-windows-editor.html
, . .
. http://answers.unity3d.com/questions/55392/why-my-glcolor-doesnt-work.html
:.
Shader "Unlit Transparent Vertex Colored"
{
Properties
{
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
Category
{
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
ZWrite Off
//Alphatest Greater 0
Blend SrcAlpha OneMinusSrcAlpha
Fog { Color(0,0,0,0) }
Lighting Off
Cull Off //we can turn backface culling off because we know nothing will be facing backwards
BindChannels
{
Bind "Vertex", vertex
Bind "texcoord", texcoord
Bind "Color", color
}
SubShader
{
Pass
{
SetTexture [_MainTex]
{
Combine texture * primary
}
}
}
}
}
https://github.com/edbartley/BombaFiesta-Unity3D-Futile/blob/master/Assets/Resources/Shaders/UnlitTransparentVertexColored.shader
- Assets/Resources, . test.shader Awake() :
private void Awake()
{
DontDestroyOnLoad(this);
m_Instance = this;
var shader = Shader.Find("Unlit Transparent Vertex Colored");
m_Material = new Material(shader);
}
Shader.Find http://docs.unity3d.com/ScriptReference/Shader.Find.html
, GL.Begin() GL DrawQuad().
private void DrawQuad(Color aColor,float aAlpha)
{
aColor.a = aAlpha;
m_Material.SetPass(0);
GL.Begin(GL.QUADS);
GL.Color(aColor);
GL.PushMatrix();
GL.LoadOrtho();
GL.Vertex3(0, 0, -1);
GL.Vertex3(0, 1, -1);
GL.Vertex3(1, 1, -1);
GL.Vertex3(1, 0, -1);
GL.End();
GL.PopMatrix();
}
.: -)
, - !
:
, .
, OpenGL, Windows Unity 4.6.3, -force-opengl, ( , OpenGL).
. http://answers.unity3d.com/questions/447206/forcing-opengl-in-windows-editor.html
, , OpenGL, DirectX.
"DrawQuad" :
private void DrawQuad(Color aColor, float aAlpha)
{
aColor.a = aAlpha;
Texture2D texture = new Texture2D(1, 1);
texture.SetPixel(0, 0, aColor);
texture.Apply();
GUI.skin.box.normal.background = texture;
GUI.Box(new Rect(0, 0, Screen.width, Screen.height), GUIContent.none);
}
. http://forum.unity3d.com/threads/draw-a-simple-rectangle-filled-with-a-color.116348/