public void ApplyDefaultStyles() { if (!root) { root = OGRoot.GetInstance(); } OGSkin skin = root.skin; if (!skin) { Debug.LogWarning("OpenGUI | No OGSkin attached to OGRoot"); } else { skin.ApplyDefaultStyles(this); } }
////////////////// // Draw loop ////////////////// public void OnPostRender() { if (skin != null && widgets != null) { int i = 0; int o = 0; OGWidget w; GL.PushMatrix(); GL.LoadPixelMatrix(0, screenWidth, 0, screenHeight); // Draw skin GL.Begin(GL.QUADS); OGDrawHelper.SetPass(skin.atlas); for (i = 0; i < widgets.Length; i++) { w = widgets[i]; if (w == null) { continue; } else if (w.drawRct.x == 0 && w.drawRct.y == 0 && w.drawRct.height == 0 && w.drawRct.width == 0) { w.Recalculate(); continue; } if (w.currentStyle == null) { w.currentStyle = w.styles.basic; } if (w.gameObject.activeSelf && w.isDrawn && w.drawRct.height > 0 && w.drawRct.width > 0) { w.DrawSkin(); } } GL.End(); // Draw text for (i = 0; i < skin.fonts.Length; i++) { if (skin.fonts[0] == null) { continue; } GL.Begin(GL.QUADS); if (skin.fontShader != null && skin.fonts[i].bitmapFont != null) { skin.fonts[i].bitmapFont.material.shader = skin.fontShader; } if (skin.fonts[i].bitmapFont != null) { OGDrawHelper.SetPass(skin.fonts[i].bitmapFont.material); } for (o = 0; o < widgets.Length; o++) { w = widgets[o]; if (w == null) { continue; } if (w.styles == null) { skin.ApplyDefaultStyles(w); } else if (w.isDrawn && w.gameObject.activeSelf) { if (w.currentStyle != null && w.currentStyle.text.fontIndex == i) { if (w.currentStyle.text.font == null) { w.currentStyle.text.font = skin.fonts[i]; } w.DrawText(); } } } GL.End(); } // Draw lines if (lineMaterial != null) { GL.Begin(GL.LINES); lineMaterial.SetPass(0); for (i = 0; i < widgets.Length; i++) { w = widgets[i]; if (w != null && w.gameObject.activeSelf && w.isDrawn) { w.DrawLine(); } } GL.End(); } // Draw textures for (i = 0; i < widgets.Length; i++) { w = widgets[i]; if (w != null && w.gameObject.activeSelf && w.isDrawn) { w.DrawGL(); } } GL.PopMatrix(); } }