From 5b158af90739dcbb89c1538a6cb8c65a875dce80 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 26 Nov 2020 20:52:34 +0800 Subject: *misc --- .../Utils/Editor/StyledGUI/DrawInspectorBanner.cs | 64 ++++++++++++++++++++++ .../Editor/StyledGUI/DrawInspectorBanner.cs.meta | 12 ++++ .../Editor/StyledGUI/DrawInspectorCategory.cs | 46 ++++++++++++++++ .../Editor/StyledGUI/DrawInspectorCategory.cs.meta | 12 ++++ .../Utils/Editor/StyledGUI/DrawWindowBanner.cs | 64 ++++++++++++++++++++++ .../Editor/StyledGUI/DrawWindowBanner.cs.meta | 11 ++++ .../Utils/Editor/StyledGUI/DrawWindowCategory.cs | 48 ++++++++++++++++ .../Editor/StyledGUI/DrawWindowCategory.cs.meta | 12 ++++ 8 files changed, 269 insertions(+) create mode 100644 Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawInspectorBanner.cs create mode 100644 Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawInspectorBanner.cs.meta create mode 100644 Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawInspectorCategory.cs create mode 100644 Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawInspectorCategory.cs.meta create mode 100644 Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawWindowBanner.cs create mode 100644 Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawWindowBanner.cs.meta create mode 100644 Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawWindowCategory.cs create mode 100644 Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawWindowCategory.cs.meta (limited to 'Assets/BOXOPHOBIC/Utils/Editor/StyledGUI') diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawInspectorBanner.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawInspectorBanner.cs new file mode 100644 index 00000000..0d3476c5 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawInspectorBanner.cs @@ -0,0 +1,64 @@ +// Cristian Pop - https://boxophobic.com/ + +using UnityEngine; +using UnityEditor; +using Boxophobic.Constants; + +namespace Boxophobic.StyledGUI +{ + public partial class StyledGUI + { + public static void DrawInspectorBanner(Color bannerColor, string bannerText, string helpURL) + { + GUILayout.Space(20); + + var bannerFullRect = GUILayoutUtility.GetRect(0, 0, 40, 0); + var bannerBeginRect = new Rect(bannerFullRect.position.x, bannerFullRect.position.y, 20, 40); + var bannerMiddleRect = new Rect(bannerFullRect.position.x + 20, bannerFullRect.position.y, bannerFullRect.xMax - 54, 40); + var bannerEndRect = new Rect(bannerFullRect.xMax - 20, bannerFullRect.position.y, 20, 40); + var iconRect = new Rect(bannerFullRect.xMax - 36, bannerFullRect.position.y + 5, 30, 30); + + Color guiColor; + + if (EditorGUIUtility.isProSkin) + { + bannerColor = new Color(bannerColor.r, bannerColor.g, bannerColor.b, 1f); + } + else + { + bannerColor = CONSTANT.ColorLightGray; + } + + if (bannerColor.r + bannerColor.g + bannerColor.b <= 1.5f) + { + guiColor = CONSTANT.ColorLightGray; + } + else + { + guiColor = CONSTANT.ColorDarkGray; + } + + GUI.color = bannerColor; + + GUI.DrawTexture(bannerBeginRect, CONSTANT.BannerImageBegin, ScaleMode.StretchToFill, true); + GUI.DrawTexture(bannerMiddleRect, CONSTANT.BannerImageMiddle, ScaleMode.StretchToFill, true); + GUI.DrawTexture(bannerEndRect, CONSTANT.BannerImageEnd, ScaleMode.StretchToFill, true); + +#if UNITY_2019_3_OR_NEWER + GUI.Label(bannerFullRect, "" + bannerText + "", CONSTANT.TitleStyle); +#else + GUI.Label(bannerFullRect, "" + bannerText + "", CONSTANT.TitleStyle); +#endif + GUI.color = guiColor; + + if (GUI.Button(iconRect, CONSTANT.IconHelp, new GUIStyle { alignment = TextAnchor.MiddleCenter })) + { + Application.OpenURL(helpURL); + } + + GUI.color = Color.white; + GUILayout.Space(10); + } + } +} + diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawInspectorBanner.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawInspectorBanner.cs.meta new file mode 100644 index 00000000..b8754bf1 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawInspectorBanner.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1525d4228f26951498e86e425363f3f0 +timeCreated: 1542661236 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawInspectorCategory.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawInspectorCategory.cs new file mode 100644 index 00000000..f0b66fe3 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawInspectorCategory.cs @@ -0,0 +1,46 @@ +// Cristian Pop - https://boxophobic.com/ + +using UnityEngine; +using UnityEditor; +using Boxophobic.Constants; + +namespace Boxophobic.StyledGUI +{ + public partial class StyledGUI + { + public static void DrawInspectorCategory(Rect position, string bannerText) + { + var categoryFullRect = new Rect(position.position.x, position.position.y + 10, position.width, position.height); + var categoryBeginRect = new Rect(categoryFullRect.position.x, categoryFullRect.position.y, 10, 20); + var categoryMiddleRect = new Rect(categoryFullRect.position.x + 10, categoryFullRect.position.y, categoryFullRect.xMax - 32, 20); + var categoryEndRect = new Rect(categoryFullRect.xMax - 10, categoryFullRect.position.y, 10, 20); + var titleRect = new Rect(categoryFullRect.position.x, categoryFullRect.position.y, categoryFullRect.width, 18); + + if (EditorGUIUtility.isProSkin) + { + GUI.color = CONSTANT.ColorDarkGray; + } + else + { + GUI.color = CONSTANT.ColorLightGray; + } + + //Workaround for flickering images in CustomInspector with Attribute + GUIStyle styleB = new GUIStyle(); + styleB.normal.background = CONSTANT.CategoryImageBegin; + EditorGUI.LabelField(categoryBeginRect, GUIContent.none, styleB); + + GUIStyle styleM = new GUIStyle(); + styleM.normal.background = CONSTANT.CategoryImageMiddle; + EditorGUI.LabelField(categoryMiddleRect, GUIContent.none, styleM); + + GUIStyle styleE = new GUIStyle(); + styleE.normal.background = CONSTANT.CategoryImageEnd; + EditorGUI.LabelField(categoryEndRect, GUIContent.none, styleE); + + GUI.color = Color.white; + GUI.Label(titleRect, bannerText, CONSTANT.BoldTextStyle); + } + } +} + diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawInspectorCategory.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawInspectorCategory.cs.meta new file mode 100644 index 00000000..567c6b15 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawInspectorCategory.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 87b94a9c1333f074e8c24cd5a2fe1d73 +timeCreated: 1542661236 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawWindowBanner.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawWindowBanner.cs new file mode 100644 index 00000000..85a50d27 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawWindowBanner.cs @@ -0,0 +1,64 @@ +// Cristian Pop - https://boxophobic.com/ + +using UnityEngine; +using UnityEditor; +using Boxophobic.Constants; + +namespace Boxophobic.StyledGUI +{ + public partial class StyledGUI + { + public static void DrawWindowBanner(Color bannerColor, string bannerText, string helpURL) + { + GUILayout.Space(20); + + var bannerFullRect = GUILayoutUtility.GetRect(0, 0, 40, 0); + var bannerBeginRect = new Rect(bannerFullRect.position.x + 20, bannerFullRect.position.y, 20, 40); + var bannerMiddleRect = new Rect(bannerFullRect.position.x + 40, bannerFullRect.position.y, bannerFullRect.xMax - 75, 40); + var bannerEndRect = new Rect(bannerFullRect.xMax - 36, bannerFullRect.position.y, 20, 40); + var iconRect = new Rect(bannerFullRect.xMax - 53, bannerFullRect.position.y + 5, 30, 30); + + Color guiColor; + + if (EditorGUIUtility.isProSkin) + { + bannerColor = new Color(bannerColor.r, bannerColor.g, bannerColor.b, 1f); + } + else + { + bannerColor = CONSTANT.ColorLightGray; + } + + if (bannerColor.r + bannerColor.g + bannerColor.b <= 1.5) + { + guiColor = CONSTANT.ColorLightGray; + } + else + { + guiColor = CONSTANT.ColorDarkGray; + } + + GUI.color = bannerColor; + + GUI.DrawTexture(bannerBeginRect, CONSTANT.BannerImageBegin, ScaleMode.StretchToFill, true); + GUI.DrawTexture(bannerMiddleRect, CONSTANT.BannerImageMiddle, ScaleMode.StretchToFill, true); + GUI.DrawTexture(bannerEndRect, CONSTANT.BannerImageEnd, ScaleMode.StretchToFill, true); + + GUI.color = guiColor; + +#if UNITY_2019_3_OR_NEWER + GUI.Label(bannerFullRect, "" + bannerText + "", CONSTANT.TitleStyle); +#else + GUI.Label(bannerFullRect, "" + bannerText + "", CONSTANT.TitleStyle); +#endif + if (GUI.Button(iconRect, CONSTANT.IconHelp, new GUIStyle { alignment = TextAnchor.MiddleCenter })) + { + Application.OpenURL(helpURL); + } + + GUI.color = Color.white; + GUILayout.Space(20); + } + } +} + diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawWindowBanner.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawWindowBanner.cs.meta new file mode 100644 index 00000000..6978d25a --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawWindowBanner.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dd0ddca94871d9a4586a143a83184806 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawWindowCategory.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawWindowCategory.cs new file mode 100644 index 00000000..8950ff7b --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawWindowCategory.cs @@ -0,0 +1,48 @@ +// Cristian Pop - https://boxophobic.com/ + +using UnityEngine; +using UnityEditor; +using Boxophobic.Constants; + +namespace Boxophobic.StyledGUI +{ + public partial class StyledGUI + { + public static void DrawWindowCategory(string bannerText) + { + var position = GUILayoutUtility.GetRect(0, 0, 40, 0); + + var categoryFullRect = new Rect(position.position.x, position.position.y + 10, position.width, position.height); + var categoryBeginRect = new Rect(categoryFullRect.position.x, categoryFullRect.position.y, 10, 20); + var categoryMiddleRect = new Rect(categoryFullRect.position.x + 10, categoryFullRect.position.y, categoryFullRect.xMax - 41, 20); + var categoryEndRect = new Rect(categoryFullRect.xMax - 13, categoryFullRect.position.y, 10, 20); + var titleRect = new Rect(categoryFullRect.position.x, categoryFullRect.position.y, categoryFullRect.width, 18); + + if (EditorGUIUtility.isProSkin) + { + GUI.color = CONSTANT.ColorDarkGray; + } + else + { + GUI.color = CONSTANT.ColorLightGray; + } + + //Workaround for flickering images in CustomInspector with Attribute + GUIStyle styleB = new GUIStyle(); + styleB.normal.background = CONSTANT.CategoryImageBegin; + EditorGUI.LabelField(categoryBeginRect, GUIContent.none, styleB); + + GUIStyle styleM = new GUIStyle(); + styleM.normal.background = CONSTANT.CategoryImageMiddle; + EditorGUI.LabelField(categoryMiddleRect, GUIContent.none, styleM); + + GUIStyle styleE = new GUIStyle(); + styleE.normal.background = CONSTANT.CategoryImageEnd; + EditorGUI.LabelField(categoryEndRect, GUIContent.none, styleE); + + GUI.color = Color.white; + GUI.Label(titleRect, bannerText, CONSTANT.BoldTextStyle); + } + } +} + diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawWindowCategory.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawWindowCategory.cs.meta new file mode 100644 index 00000000..514bf87e --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI/DrawWindowCategory.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: aac99d6d81f90e54cabd822770c11875 +timeCreated: 1542661236 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: -- cgit v1.1-26-g67d0