using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using UnityEngine; using Object = UnityEngine.Object; namespace Explorer { public class UIStyles { public static Color LightGreen = new Color(Color.green.r - 0.3f, Color.green.g - 0.3f, Color.green.b - 0.3f); public static GUISkin WindowSkin { get { if (_customSkin == null) { try { _customSkin = CreateWindowSkin(); } catch { _customSkin = GUI.skin; } } return _customSkin; } } public static void HorizontalLine(Color color) { var c = GUI.color; GUI.color = color; GUILayout.Box(GUIContent.none, HorizontalBar, null); GUI.color = c; } private static GUISkin _customSkin; public static Texture2D m_nofocusTex; public static Texture2D m_focusTex; private static GUIStyle _horizBarStyle; private static GUIStyle HorizontalBar { get { if (_horizBarStyle == null) { _horizBarStyle = new GUIStyle(); _horizBarStyle.normal.background = Texture2D.whiteTexture; _horizBarStyle.margin = new RectOffset(0, 0, 4, 4); _horizBarStyle.fixedHeight = 2; } return _horizBarStyle; } } private static GUISkin CreateWindowSkin() { var newSkin = Object.Instantiate(GUI.skin); Object.DontDestroyOnLoad(newSkin); m_nofocusTex = MakeTex(550, 700, new Color(0.1f, 0.1f, 0.1f, 0.7f)); m_focusTex = MakeTex(550, 700, new Color(0.3f, 0.3f, 0.3f, 1f)); newSkin.window.normal.background = m_nofocusTex; newSkin.window.onNormal.background = m_focusTex; newSkin.box.normal.textColor = Color.white; newSkin.window.normal.textColor = Color.white; newSkin.button.normal.textColor = Color.white; newSkin.textField.normal.textColor = Color.white; newSkin.label.normal.textColor = Color.white; return newSkin; } public static Texture2D MakeTex(int width, int height, Color col) { Color[] pix = new Color[width * height]; for (int i = 0; i < pix.Length; ++i) { pix[i] = col; } Texture2D result = new Texture2D(width, height); result.SetPixels(pix); result.Apply(); return result; } } }