public static void BeginCustomSkin(ImageFilesContainer imageFiles, Settings settings) { SetUpStyles(imageFiles, settings, false); //保存原始gui skin _defaultGUISkin = GUI.skin; //todo zxf GUI.skin = _customGUISkin; }
void OnGUI() { //创建或者加载Assets文件 if (null == _data) { _data = AssetDatabase.LoadAssetAtPath(DataPath, typeof(ImageFilesContainer)) as ImageFilesContainer; if (null == _data) { _data = CreateInstance <ImageFilesContainer>() as ImageFilesContainer; AssetDatabase.CreateAsset(_data, DataPath); AssetDatabase.Refresh(); } } //Close if (GUILayout.Button("提交数据", GUILayout.Width(80))) { //数据提交 ScriptableObject scriptable = AssetDatabase.LoadAssetAtPath(DataPath, typeof(ScriptableObject)) as ScriptableObject; EditorUtility.SetDirty(scriptable); Close(); } //初始化数据 _data._ActiveGradient = EditorGUILayout.ObjectField("_ActiveGradient", _data._ActiveGradient, typeof(Texture2D), true) as Texture2D; _data._AssertIcon = EditorGUILayout.ObjectField("_AssertIcon", _data._AssertIcon, typeof(Texture2D), true) as Texture2D; _data._BackgroundGradient = EditorGUILayout.ObjectField("_BackgroundGradient", _data._BackgroundGradient, typeof(Texture2D), true) as Texture2D; _data._CheckboxChecked = EditorGUILayout.ObjectField("_CheckboxChecked", _data._CheckboxChecked, typeof(Texture2D), true) as Texture2D; _data._CheckboxUnchecked = EditorGUILayout.ObjectField("_CheckboxUnchecked", _data._CheckboxUnchecked, typeof(Texture2D), true) as Texture2D; _data._ClearIcon = EditorGUILayout.ObjectField("_ClearIcon", _data._ClearIcon, typeof(Texture2D), true) as Texture2D; _data._CloseButton = EditorGUILayout.ObjectField("_CloseButton", _data._CloseButton, typeof(Texture2D), true) as Texture2D; _data._CloseKeyboardIcon = EditorGUILayout.ObjectField("_CloseKeyboardIcon", _data._CloseKeyboardIcon, typeof(Texture2D), true) as Texture2D; _data._ConsoleInputIcon = EditorGUILayout.ObjectField("_ConsoleInputIcon", _data._ConsoleInputIcon, typeof(Texture2D), true) as Texture2D; _data._ErrorIcon = EditorGUILayout.ObjectField("_ErrorIcon", _data._ErrorIcon, typeof(Texture2D), true) as Texture2D; _data._ExceptionIcon = EditorGUILayout.ObjectField("_ExceptionIcon", _data._ExceptionIcon, typeof(Texture2D), true) as Texture2D; _data._FilterActiveIcon = EditorGUILayout.ObjectField("_FilterActiveIcon", _data._FilterActiveIcon, typeof(Texture2D), true) as Texture2D; _data._HelpIcon = EditorGUILayout.ObjectField("_HelpIcon", _data._HelpIcon, typeof(Texture2D), true) as Texture2D; _data._HighlightGradient = EditorGUILayout.ObjectField("_HighlightGradient", _data._HighlightGradient, typeof(Texture2D), true) as Texture2D; _data._InfoIcon = EditorGUILayout.ObjectField("_InfoIcon", _data._InfoIcon, typeof(Texture2D), true) as Texture2D; _data._MaximizeIcon = EditorGUILayout.ObjectField("_MaximizeIcon", _data._MaximizeIcon, typeof(Texture2D), true) as Texture2D; _data._MinimizeTopIcon = EditorGUILayout.ObjectField("_MinimizeTopIcon", _data._MinimizeTopIcon, typeof(Texture2D), true) as Texture2D; _data._NextHistoryItemIcon = EditorGUILayout.ObjectField("_NextHistoryItemIcon", _data._NextHistoryItemIcon, typeof(Texture2D), true) as Texture2D; _data._PreviousHistoryItemIcon = EditorGUILayout.ObjectField("_PreviousHistoryItemIcon", _data._PreviousHistoryItemIcon, typeof(Texture2D), true) as Texture2D; _data._RedBackgroundGradient = EditorGUILayout.ObjectField("_RedBackgroundGradient", _data._RedBackgroundGradient, typeof(Texture2D), true) as Texture2D; _data._RunIcon = EditorGUILayout.ObjectField("_RunIcon", _data._RunIcon, typeof(Texture2D), true) as Texture2D; _data._ScrollbarThumb = EditorGUILayout.ObjectField("_ScrollbarThumb", _data._ScrollbarThumb, typeof(Texture2D), true) as Texture2D; _data._SearchIcon = EditorGUILayout.ObjectField("_SearchIcon", _data._SearchIcon, typeof(Texture2D), true) as Texture2D; _data._SettingsIcon = EditorGUILayout.ObjectField("_SettingsIcon", _data._SettingsIcon, typeof(Texture2D), true) as Texture2D; _data._SettingsPopupBackground = EditorGUILayout.ObjectField("_SettingsPopupBackground", _data._SettingsPopupBackground, typeof(Texture2D), true) as Texture2D; _data._SuggestionButtonBackground = EditorGUILayout.ObjectField("_SuggestionButtonBackground", _data._SuggestionButtonBackground, typeof(Texture2D), true) as Texture2D; _data._WarningIcon = EditorGUILayout.ObjectField("_WarningIcon", _data._WarningIcon, typeof(Texture2D), true) as Texture2D; _data._clean = EditorGUILayout.ObjectField("_CleanIcon", _data._clean, typeof(Texture2D), true) as Texture2D; }
//初始化数据 private void Initialize() { //初始化image file _imageFiles = (Resources.Load("ConsoleController/Settings/Image_AssetEditor")) as ImageFilesContainer; _settings = (Resources.Load("ConsoleController/Settings/Setting_AssetEditor")) as Settings; if (_settings.bDontDestroy == true) { DontDestroyOnLoad(gameObject); } CommandHandlers.bIsDev = true; Instance = this; //初始化视图数据 InitUIElement(); _touchDetector = new TwoFingerTouchDetector(); CommandHandlers.CommandExecuted += new Action <CommandHandler>(UpdateRecentCommandsListAfterCommandExecuted); }
public static void SetUpStyles(ImageFilesContainer imageFiles, Settings settings, bool force = false) { if (null == _customGUISkin || force) { //todo zxf //每一栏的高度 ConsoleRowHeight = 20; TitleHeight = 15; HeaderHeight = 20; InputFieldHeight = 20; //字体高度 int otherfontsize = 18; //滚动条的宽度 int scrollbarThumbWidth = 40; _customGUISkin = ScriptableObject.CreateInstance <GUISkin>(); _customGUISkin.font = GUI.skin.font; _customGUISkin.horizontalScrollbar = new GUIStyle(GUI.skin.horizontalScrollbar); _customGUISkin.horizontalScrollbarLeftButton = new GUIStyle(GUI.skin.horizontalScrollbarLeftButton); _customGUISkin.horizontalScrollbarRightButton = new GUIStyle(GUI.skin.horizontalScrollbarRightButton); _customGUISkin.horizontalScrollbarThumb = new GUIStyle(GUI.skin.horizontalScrollbarThumb); _customGUISkin.horizontalSlider = new GUIStyle(GUI.skin.horizontalSlider); _customGUISkin.horizontalSliderThumb = new GUIStyle(GUI.skin.horizontalSliderThumb); SuggestionButtonHeight = 100; GUIStyle style2 = new GUIStyle(GUI.skin.label) { fontSize = otherfontsize }; _customGUISkin.label = style2; _customGUISkin.scrollView = new GUIStyle(GUI.skin.scrollView); GUIStyle style3 = new GUIStyle(GUI.skin.textArea) { fontSize = otherfontsize }; _customGUISkin.textArea = style3; GUIStyle style4 = new GUIStyle(GUI.skin.textField) { fontSize = otherfontsize }; _customGUISkin.textField = style4; GUIStyle style5 = new GUIStyle(GUI.skin.toggle) { fontSize = otherfontsize }; _customGUISkin.toggle = style5; GUIStyle style6 = new GUIStyle(GUI.skin.verticalScrollbar) { fixedWidth = scrollbarThumbWidth }; //HeaderHeight = ConsoleRowHeight; _customGUISkin.verticalScrollbar = style6; _customGUISkin.verticalScrollbarDownButton = new GUIStyle(GUI.skin.verticalScrollbarDownButton); _customGUISkin.verticalScrollbarThumb = new GUIStyle(GUI.skin.verticalScrollbarThumb); _customGUISkin.verticalScrollbarUpButton = new GUIStyle(GUI.skin.verticalScrollbarUpButton); _customGUISkin.verticalScrollbarThumb.fixedWidth = scrollbarThumbWidth; _customGUISkin.verticalSlider = new GUIStyle(GUI.skin.verticalSlider); _customGUISkin.verticalSliderThumb = new GUIStyle(GUI.skin.verticalSliderThumb); _customGUISkin.window = new GUIStyle(GUI.skin.window); SetBackgroundForAllStyleStates(_customGUISkin.verticalScrollbarThumb, imageFiles._ScrollbarThumb); GUIStyle other = new GUIStyle(GUI.skin.label) { padding = new RectOffset(0, 0, 0, 0), margin = new RectOffset(0, 0, 0, 0), fontSize = otherfontsize, wordWrap = false, alignment = TextAnchor.MiddleLeft }; //error GUIStyle style10 = new GUIStyle(other) { normal = { textColor = Color.red } }; ErrorLabelStyle = style10; //warning GUIStyle style11 = new GUIStyle(other) { normal = { textColor = Color.yellow } }; WarningLabelStyle = style11; //assert GUIStyle style12 = new GUIStyle(other) { normal = { textColor = Color.green } }; AssertLabelStyle = style12; //exception GUIStyle style13 = new GUIStyle(other) { normal = { textColor = new Color32(0x30, 0xa3, 0xff, 0xff) } }; ExceptionLabelStyle = style13; //info GUIStyle style14 = new GUIStyle(other) { normal = { textColor = Color.white } }; InfoLabelStyle = style14; //back ground GUIStyle style25 = new GUIStyle("box") { margin = new RectOffset(0, 0, 0, 0), padding = new RectOffset(0, 0, 0, 0), normal = { background = UIUtilities.CreateTexture(new Color(0.15f, 0.15f, 0.15f, 0.9f)) }, fontSize = otherfontsize }; ConsoleWindowBackgroundStyle = style25; GUIStyle style26 = new GUIStyle(ConsoleWindowBackgroundStyle) { padding = new RectOffset((int)(1 * 50f), (int)(1 * 50f), 0, 0), normal = { background = UIUtilities.CreateTexture(new Color(0.278f, 0.278f, 0.278f, 1f)) } }; HelpWindowBackGroundStyle = style26; GUIStyle style27 = new GUIStyle(ConsoleWindowBackgroundStyle) { padding = new RectOffset((int)(1 * 50f), (int)(1 * 50f), 0, 0), normal = { background = UIUtilities.CreateTexture(new Color(0.278f, 0.278f, 0.278f, 1f)) } }; LogModulesBackGroundStyle = style27; GUIStyle style28 = new GUIStyle { normal = { background = UIUtilities.CreateTexture(new Color(0f, 0f, 0f, 0.1f)) } }; ItemAlternateBackgroundStyle = style28; GUIStyle style31 = new GUIStyle { normal = { background = imageFiles._BackgroundGradient } }; HeaderStyle = style31; GUIStyle style38 = new GUIStyle(GUI.skin.textField) { alignment = TextAnchor.MiddleLeft, padding = new RectOffset((int)(10f * 1), (int)(10f * 1), 2, 2), fontSize = (int)(40 * 0.5f), margin = new RectOffset(5, 3, 3, 4) }; InputTextFieldStyle = style38; GUIStyle style40 = new GUIStyle(GUI.skin.label) { fontSize = (int)(16), padding = new RectOffset(), margin = new RectOffset(), richText = true, alignment = TextAnchor.MiddleLeft, hover = { background = UIUtilities.CreateTexture(new Color(0f, 0f, 0.6f, 0.4f)), textColor = Color.white } }; GUIStyle style39 = new GUIStyle(GUI.skin.textField) { alignment = TextAnchor.MiddleCenter, //padding = new RectOffset((int)(10f * 1), (int)(10f * 1), 2, 2), fontSize = (int)(20 * 0.5f), //margin = new RectOffset(5, 3, 3, 4) }; TitleBarFieldStyle = style39; LogHistoryItemTextAreaStyle = style40; GUIStyle style61 = new GUIStyle(other) { stretchHeight = true, padding = new RectOffset(5, 5, 3, 3), fontSize = (int)(HeaderHeight * 0.5f) }; HeaderButtonLabelStyle = style61; } }