diff options
Diffstat (limited to 'Assets/BOXOPHOBIC/Utils/Editor')
70 files changed, 2219 insertions, 0 deletions
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/Boxophobic.Utils.Editor.asmdef b/Assets/BOXOPHOBIC/Utils/Editor/Boxophobic.Utils.Editor.asmdef new file mode 100644 index 00000000..a15acddb --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/Boxophobic.Utils.Editor.asmdef @@ -0,0 +1,16 @@ +{ + "name": "Boxophobic.Utils.Editor", + "references": [ + "Boxophobic.Utils.Scripts" + ], + "optionalUnityReferences": [], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [] +}
\ No newline at end of file diff --git a/Assets/BOXOPHOBIC/Utils/Editor/Boxophobic.Utils.Editor.asmdef.meta b/Assets/BOXOPHOBIC/Utils/Editor/Boxophobic.Utils.Editor.asmdef.meta new file mode 100644 index 00000000..90e25f0e --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/Boxophobic.Utils.Editor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 10f1dd4cfd6afb54da274d7d818bd8f6 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BOXOPHOBIC/Utils/Editor/Constants.meta b/Assets/BOXOPHOBIC/Utils/Editor/Constants.meta new file mode 100644 index 00000000..a5ee5a64 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/Constants.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4c9d2f06234e7e643b2118057d8e0673 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BOXOPHOBIC/Utils/Editor/Constants/Constants.cs b/Assets/BOXOPHOBIC/Utils/Editor/Constants/Constants.cs new file mode 100644 index 00000000..7580a347 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/Constants/Constants.cs @@ -0,0 +1,138 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+
+namespace Boxophobic.Constants
+{
+ public static class CONSTANT
+ {
+ public static Texture2D LogoImage
+ {
+ get
+ {
+ return Resources.Load("Boxophobic - Logo") as Texture2D;
+ }
+ }
+
+ public static Texture2D BannerImageBegin
+ {
+ get
+ {
+ return Resources.Load("Boxophobic - BannerBegin") as Texture2D;
+ }
+ }
+
+ public static Texture2D BannerImageMiddle
+ {
+ get
+ {
+ return Resources.Load("Boxophobic - BannerMiddle") as Texture2D;
+ }
+ }
+
+ public static Texture2D BannerImageEnd
+ {
+ get
+ {
+ return Resources.Load("Boxophobic - BannerEnd") as Texture2D;
+ }
+ }
+
+ public static Texture2D CategoryImageBegin
+ {
+ get
+ {
+ return Resources.Load("Boxophobic - CategoryBegin") as Texture2D;
+ }
+ }
+
+ public static Texture2D CategoryImageMiddle
+ {
+ get
+ {
+ return Resources.Load("Boxophobic - CategoryMiddle") as Texture2D;
+ }
+ }
+
+ public static Texture2D CategoryImageEnd
+ {
+ get
+ {
+ return Resources.Load("Boxophobic - CategoryEnd") as Texture2D;
+ }
+ }
+
+ public static Texture2D IconEdit
+ {
+ get
+ {
+ return Resources.Load("Boxophobic - IconEdit") as Texture2D;
+ }
+ }
+
+ public static Texture2D IconHelp
+ {
+ get
+ {
+ return Resources.Load("Boxophobic - IconHelp") as Texture2D;
+ }
+ }
+
+ public static Color ColorDarkGray
+ {
+ get
+ {
+ return new Color(0.27f, 0.27f, 0.27f);
+ }
+ }
+
+ public static Color ColorLightGray
+ {
+ get
+ {
+ return new Color(0.83f, 0.83f, 0.83f);
+ }
+ }
+
+ public static GUIStyle TitleStyle
+ {
+ get
+ {
+ GUIStyle guiStyle = new GUIStyle
+ {
+ richText = true,
+ alignment = TextAnchor.MiddleCenter
+ };
+
+ return guiStyle;
+ }
+ }
+
+ public static GUIStyle BoldTextStyle
+ {
+ get
+ {
+ GUIStyle guiStyle = new GUIStyle();
+
+ Color color;
+
+ if (EditorGUIUtility.isProSkin)
+ {
+ color = new Color(0.87f, 0.87f, 0.87f);
+ }
+ else
+ {
+ color = new Color(0.27f, 0.27f, 0.27f);
+ }
+
+ guiStyle.normal.textColor = color;
+ guiStyle.alignment = TextAnchor.MiddleCenter;
+ guiStyle.fontStyle = FontStyle.Bold;
+
+ return guiStyle;
+ }
+ }
+ }
+}
+
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/Constants/Constants.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/Constants/Constants.cs.meta new file mode 100644 index 00000000..578f0665 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/Constants/Constants.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: e0cf8ff3bbc97374f88272f686fb80e5
+timeCreated: 1541442079
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/SettingsUtils.meta b/Assets/BOXOPHOBIC/Utils/Editor/SettingsUtils.meta new file mode 100644 index 00000000..3fdad1c4 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/SettingsUtils.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6fcf51a07e84ca941a62046a0b693a19 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BOXOPHOBIC/Utils/Editor/SettingsUtils/LoadSettingsData.cs b/Assets/BOXOPHOBIC/Utils/Editor/SettingsUtils/LoadSettingsData.cs new file mode 100644 index 00000000..fb1c3b85 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/SettingsUtils/LoadSettingsData.cs @@ -0,0 +1,71 @@ +// Cristian Pop - https://boxophobic.com/
+
+using System.Globalization;
+using UnityEditor;
+
+namespace Boxophobic.Utils
+{
+ public partial class SettingsUtils
+ {
+ public static string LoadSettingsData(string settingsPath, string defaultData)
+ {
+ var settings = AssetDatabase.LoadAssetAtPath<SettingsData>(settingsPath);
+
+ if (settings != null)
+ {
+ return settings.data;
+ }
+ else
+ {
+ return defaultData;
+ }
+ }
+
+ public static int LoadSettingsData(string settingsPath, int defaultData)
+ {
+ var settings = AssetDatabase.LoadAssetAtPath<SettingsData>(settingsPath);
+
+ if (settings != null)
+ {
+ int value;
+
+ if (int.TryParse(settings.data, out value))
+ {
+ return value;
+ }
+ else
+ {
+ return defaultData;
+ }
+ }
+ else
+ {
+ return defaultData;
+ }
+ }
+
+ public static float LoadSettingsData(string settingsPath, float defaultData)
+ {
+ var settings = AssetDatabase.LoadAssetAtPath<SettingsData>(settingsPath);
+
+ if (settings != null)
+ {
+ float value;
+
+ if (float.TryParse(settings.data, out value))
+ {
+ return float.Parse(settings.data, CultureInfo.InvariantCulture);
+ }
+ else
+ {
+ return defaultData;
+ }
+ }
+ else
+ {
+ return defaultData;
+ }
+ }
+ }
+}
+
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/SettingsUtils/LoadSettingsData.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/SettingsUtils/LoadSettingsData.cs.meta new file mode 100644 index 00000000..41d9fe28 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/SettingsUtils/LoadSettingsData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 90057ce590a8bd148ab59e018f35d9cb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BOXOPHOBIC/Utils/Editor/SettingsUtils/SaveSettingsData.cs b/Assets/BOXOPHOBIC/Utils/Editor/SettingsUtils/SaveSettingsData.cs new file mode 100644 index 00000000..5e9dcf7f --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/SettingsUtils/SaveSettingsData.cs @@ -0,0 +1,71 @@ +// Cristian Pop - https://boxophobic.com/
+
+using System.IO;
+using UnityEditor;
+using UnityEngine;
+
+namespace Boxophobic.Utils
+{
+ public partial class SettingsUtils
+ {
+ public static void SaveSettingsData(string settingsPath, string data)
+ {
+ CreateFileIfMissing(settingsPath);
+
+ var settings = AssetDatabase.LoadAssetAtPath<SettingsData>(settingsPath);
+
+ settings.data = data;
+
+ SaveFile(settingsPath);
+ }
+
+ public static void SaveSettingsData(string settingsPath, int data)
+ {
+ CreateFileIfMissing(settingsPath);
+
+ var settings = AssetDatabase.LoadAssetAtPath<SettingsData>(settingsPath);
+
+ settings.data = data.ToString();
+
+ SaveFile(settingsPath);
+ }
+
+ public static void SaveSettingsData(string settingsPath, float data)
+ {
+ CreateFileIfMissing(settingsPath);
+
+ var settings = AssetDatabase.LoadAssetAtPath<SettingsData>(settingsPath);
+
+ settings.data = data.ToString();
+
+ SaveFile(settingsPath);
+ }
+
+ private static void CreateFileIfMissing(string settingsPath)
+ {
+ if (File.Exists(settingsPath) == false)
+ {
+ var directory = Path.GetDirectoryName(settingsPath);
+
+ if (Directory.Exists(directory) == false)
+ {
+ Directory.CreateDirectory(directory);
+ AssetDatabase.Refresh();
+ }
+
+ AssetDatabase.CreateAsset(ScriptableObject.CreateInstance<SettingsData>(), settingsPath);
+ AssetDatabase.Refresh();
+ }
+ }
+
+ private static void SaveFile(string settingsPath)
+ {
+ var file = AssetDatabase.LoadAssetAtPath<SettingsData>(settingsPath);
+
+ EditorUtility.SetDirty(file);
+ AssetDatabase.SaveAssets();
+ AssetDatabase.Refresh();
+ }
+ }
+}
+
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/SettingsUtils/SaveSettingsData.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/SettingsUtils/SaveSettingsData.cs.meta new file mode 100644 index 00000000..753e92ed --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/SettingsUtils/SaveSettingsData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7afe5a6ac49829c408df7e64761e822d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI.meta new file mode 100644 index 00000000..94757653 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledGUI.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 28d59ef8b8ebe8d48a3a27e990a2d7e9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: 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, "<size=14><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + ">" + bannerText + "</color></size>", CONSTANT.TitleStyle);
+#else
+ GUI.Label(bannerFullRect, "<size=14><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + "><b>" + bannerText + "</b></color></size>", 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, "<size=16><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + ">" + bannerText + "</color></size>", CONSTANT.TitleStyle);
+#else
+ GUI.Label(bannerFullRect, "<size=14><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + "><b>" + bannerText + "</b></color></size>", 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:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector.meta new file mode 100644 index 00000000..d2c0b7b4 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: edc7fbbe770e693488770a7aaeae2aa6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledBannerDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledBannerDrawer.cs new file mode 100644 index 00000000..133574e8 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledBannerDrawer.cs @@ -0,0 +1,83 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+using Boxophobic.Constants;
+
+namespace Boxophobic.StyledGUI
+{
+ [CustomPropertyDrawer(typeof(StyledBanner))]
+ public class StyledBannerAttributeDrawer : PropertyDrawer
+ {
+ StyledBanner a;
+
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+ {
+ a = (StyledBanner)attribute;
+
+ DrawBanner();
+ }
+
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
+ {
+ return -2;
+ }
+
+ void DrawBanner()
+ {
+ GUILayout.Space(a.spaceTop);
+
+ 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 bannerColor;
+ Color guiColor;
+
+ if (EditorGUIUtility.isProSkin)
+ {
+ if (a.colorR < 0)
+ {
+ bannerColor = CONSTANT.ColorDarkGray;
+ guiColor = CONSTANT.ColorLightGray;
+
+ }
+ else
+ {
+ bannerColor = new Color(a.colorR, a.colorG, a.colorB, 1f);
+ guiColor = CONSTANT.ColorDarkGray;
+ }
+ }
+ else
+ {
+ bannerColor = CONSTANT.ColorLightGray;
+ 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, "<size=16><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + ">" + a.title + " " + a.subtitle + "</color></size>", CONSTANT.TitleStyle);
+#else
+ GUI.Label(bannerFullRect, "<size=14><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + "><b>" + a.title + "</b> " + a.subtitle + "</color></size>", CONSTANT.TitleStyle);
+#endif
+ GUI.color = guiColor;
+
+ if (GUI.Button(iconRect, CONSTANT.IconHelp, new GUIStyle { alignment = TextAnchor.MiddleCenter }))
+ {
+ Application.OpenURL(a.helpURL);
+ }
+
+ GUI.color = Color.white;
+
+ GUILayout.Space(a.spaceBottom);
+ }
+ }
+
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledBannerDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledBannerDrawer.cs.meta new file mode 100644 index 00000000..f856a02b --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledBannerDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: a832b9f47ccef214e81c89efe6bf31dd
+timeCreated: 1544998323
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledButtonDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledButtonDrawer.cs new file mode 100644 index 00000000..7814d2cc --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledButtonDrawer.cs @@ -0,0 +1,33 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+
+namespace Boxophobic.StyledGUI
+{
+ [CustomPropertyDrawer(typeof(StyledButton))]
+ public class StyledButtonAttributeDrawer : PropertyDrawer
+ {
+ StyledButton a;
+
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+ {
+ a = (StyledButton)attribute;
+
+ GUILayout.Space(a.Top);
+
+ if (GUILayout.Button(a.Text))
+ {
+ property.boolValue = true;
+ }
+
+ GUILayout.Space(a.Down);
+ }
+
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
+ {
+ return -2;
+ }
+ }
+}
+
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledButtonDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledButtonDrawer.cs.meta new file mode 100644 index 00000000..c78a77d0 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledButtonDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: b1d35dbbb9b6c214aa892d7b240de3df
+timeCreated: 1544998323
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledCategoryDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledCategoryDrawer.cs new file mode 100644 index 00000000..96516911 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledCategoryDrawer.cs @@ -0,0 +1,28 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+using Boxophobic.Constants;
+
+namespace Boxophobic.StyledGUI
+{
+ [CustomPropertyDrawer(typeof(StyledCategory))]
+ public class StyledCategoryAttributeDrawer : PropertyDrawer
+ {
+ StyledCategory a;
+
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+ {
+ a = (StyledCategory)attribute;
+
+ GUI.enabled = true;
+
+ StyledGUI.DrawInspectorCategory(position, a.category);
+ }
+
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
+ {
+ return 40;
+ }
+ }
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledCategoryDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledCategoryDrawer.cs.meta new file mode 100644 index 00000000..ac2a05e9 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledCategoryDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: fb59d41716ab6114cb7cf03a5695083b
+timeCreated: 1544998323
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledIndentDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledIndentDrawer.cs new file mode 100644 index 00000000..1f1d2e40 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledIndentDrawer.cs @@ -0,0 +1,25 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+
+namespace Boxophobic.StyledGUI
+{
+ [CustomPropertyDrawer(typeof(StyledIndent))]
+ public class StyledIndentAttributeDrawer : PropertyDrawer
+ {
+ StyledIndent a;
+
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+ {
+ a = (StyledIndent)attribute;
+
+ EditorGUI.indentLevel = a.indent;
+ }
+
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
+ {
+ return -2;
+ }
+ }
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledIndentDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledIndentDrawer.cs.meta new file mode 100644 index 00000000..04574795 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledIndentDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: ea3f7407f69f900468d4b60de570e49d
+timeCreated: 1544998323
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledInteractiveDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledInteractiveDrawer.cs new file mode 100644 index 00000000..1f31e352 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledInteractiveDrawer.cs @@ -0,0 +1,55 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+
+namespace Boxophobic.StyledGUI
+{
+ [CustomPropertyDrawer(typeof(StyledInteractive))]
+ public class StyledInteractiveAttributeDrawer : PropertyDrawer
+ {
+ StyledInteractive a;
+
+ private int Value;
+ private string Keywork;
+ public int Type;
+
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+ {
+ a = (StyledInteractive)attribute;
+
+ Value = a.value;
+ Keywork = a.keyword;
+ Type = a.type;
+
+ if (Type == 0)
+ {
+ if (property.intValue == Value)
+ {
+ GUI.enabled = true;
+ }
+ else
+ {
+ GUI.enabled = false;
+ }
+ }
+ else if (Type == 1)
+ {
+ if (Keywork == "ON")
+ {
+ GUI.enabled = true;
+ }
+ else if (Keywork == "OFF")
+ {
+ GUI.enabled = false;
+ }
+ }
+
+ }
+
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
+ {
+ return -2;
+ }
+ }
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledInteractiveDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledInteractiveDrawer.cs.meta new file mode 100644 index 00000000..e9262191 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledInteractiveDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: 80229de18cd73624b8181a9db49a304f
+timeCreated: 1544998323
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledMessageDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledMessageDrawer.cs new file mode 100644 index 00000000..c2b02d6c --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledMessageDrawer.cs @@ -0,0 +1,52 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+
+namespace Boxophobic.StyledGUI
+{
+ [CustomPropertyDrawer(typeof(StyledMessage))]
+ public class StyledMessageAttributeDrawer : PropertyDrawer
+ {
+ StyledMessage a;
+
+ bool show;
+ MessageType messageType;
+
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+ {
+ show = property.boolValue;
+
+ if (show)
+ {
+ a = (StyledMessage)attribute;
+
+ if (a.Type == "None")
+ {
+ messageType = MessageType.None;
+ }
+ else if (a.Type == "Info")
+ {
+ messageType = MessageType.Info;
+ }
+ else if (a.Type == "Warning")
+ {
+ messageType = MessageType.Warning;
+ }
+ else if (a.Type == "Error")
+ {
+ messageType = MessageType.Error;
+ }
+
+ GUILayout.Space(a.Top);
+ EditorGUILayout.HelpBox(a.Message, messageType);
+ GUILayout.Space(a.Down);
+ }
+ }
+
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
+ {
+ return -2;
+ }
+ }
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledMessageDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledMessageDrawer.cs.meta new file mode 100644 index 00000000..f207a760 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledMessageDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: 2734a300c1fbfb8499fe8a71e9b109e7
+timeCreated: 1544998323
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledPopupArrayDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledPopupArrayDrawer.cs new file mode 100644 index 00000000..bcf8bbdb --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledPopupArrayDrawer.cs @@ -0,0 +1,36 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+
+namespace Boxophobic.StyledGUI
+{
+ [CustomPropertyDrawer(typeof(StyledPopupArray))]
+ public class StyledPopupArrayAttributeDrawer : PropertyDrawer
+ {
+ StyledPopupArray a;
+ private int index = 0;
+
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+ {
+ a = (StyledPopupArray)attribute;
+
+ var arrProp = property.serializedObject.FindProperty(a.array);
+
+ var arr = new string[arrProp.arraySize];
+
+ for (int i = 0; i < arrProp.arraySize; i++)
+ {
+ arr[i] = arrProp.GetArrayElementAtIndex(i).stringValue;
+ }
+
+ index = EditorGUILayout.Popup(property.displayName, index, arr);
+ property.intValue = index;
+ }
+
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
+ {
+ return -2;
+ }
+ }
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledPopupArrayDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledPopupArrayDrawer.cs.meta new file mode 100644 index 00000000..d7549d51 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledPopupArrayDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: bf9745e7c3c176c4395dbd644b463703
+timeCreated: 1544998323
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledPopupLayersDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledPopupLayersDrawer.cs new file mode 100644 index 00000000..0b2d4d4a --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledPopupLayersDrawer.cs @@ -0,0 +1,40 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+
+namespace Boxophobic.StyledGUI
+{
+ [CustomPropertyDrawer(typeof(StyledPopupLayers))]
+ public class StyledPopupLayersAttributeDrawer : PropertyDrawer
+ {
+ private int index;
+
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+ {
+ index = property.intValue;
+
+ string[] allLayers = new string[32];
+
+ for (int i = 0; i < 32; i++)
+ {
+ if (LayerMask.LayerToName(i).Length < 1)
+ {
+ allLayers[i] = "Missing";
+ }
+ else
+ {
+ allLayers[i] = LayerMask.LayerToName(i);
+ }
+ }
+
+ index = EditorGUILayout.Popup(property.displayName, index, allLayers);
+ property.intValue = index;
+ }
+
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
+ {
+ return -2;
+ }
+ }
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledPopupLayersDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledPopupLayersDrawer.cs.meta new file mode 100644 index 00000000..cf036463 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledPopupLayersDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: b351b243374f2d948a9e9943abe174bf
+timeCreated: 1544998323
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledRangeOptionsDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledRangeOptionsDrawer.cs new file mode 100644 index 00000000..9af9807b --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledRangeOptionsDrawer.cs @@ -0,0 +1,71 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+
+namespace Boxophobic.StyledGUI
+{
+ [CustomPropertyDrawer(typeof(StyledRangeOptions))]
+ public class StyledRangeOptionsAttributeDrawer : PropertyDrawer
+ {
+ StyledRangeOptions a;
+
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+ {
+ a = (StyledRangeOptions)attribute;
+
+ GUIStyle styleMid = new GUIStyle();
+ styleMid.alignment = TextAnchor.MiddleCenter;
+ styleMid.normal.textColor = Color.gray;
+ styleMid.fontSize = 7;
+
+ if (a.displayLabel.Length > 0)
+ {
+ EditorGUI.PropertyField(position, property, label, true);
+ GUILayout.Space(5);
+ }
+
+ GUILayout.BeginHorizontal();
+ GUILayout.Space(8);
+ property.floatValue = GUILayout.HorizontalSlider(property.floatValue, a.min, a.max);
+ property.floatValue = Mathf.Clamp(property.floatValue, a.min, a.max);
+ property.floatValue = Mathf.Round(property.floatValue * 1000f) / 1000f;
+ GUILayout.Space(8);
+ GUILayout.EndHorizontal();
+
+#if UNITY_2019_3_OR_NEWER
+ GUILayout.Space(15);
+#endif
+ GUILayout.BeginHorizontal();
+
+ int maxWidth = 20;
+
+#if UNITY_2019_3_OR_NEWER
+ maxWidth = 28;
+#endif
+ for (int i = 0; i < a.options.Length - 1; i++)
+ {
+ GUILayout.Label(a.options[i], styleMid, GUILayout.Width(maxWidth));
+ GUILayout.Label("", styleMid);
+ }
+
+ GUILayout.Label(a.options[a.options.Length - 1], styleMid, GUILayout.Width(maxWidth));
+ GUILayout.EndHorizontal();
+
+ }
+
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
+ {
+ a = (StyledRangeOptions)attribute;
+
+ if (a.displayLabel.Length > 0)
+ {
+ return 18;
+ }
+ else
+ {
+ return -2;
+ }
+ }
+ }
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledRangeOptionsDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledRangeOptionsDrawer.cs.meta new file mode 100644 index 00000000..c76f9c35 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledRangeOptionsDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: a5681c6e5862ae545ba9b00a5b813250
+timeCreated: 1544998323
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledSpaceDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledSpaceDrawer.cs new file mode 100644 index 00000000..267fe54f --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledSpaceDrawer.cs @@ -0,0 +1,25 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+
+namespace Boxophobic.StyledGUI
+{
+ [CustomPropertyDrawer(typeof(StyledSpace))]
+ public class StyledSpaceAttributeDrawer : PropertyDrawer
+ {
+ StyledSpace a;
+
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+ {
+ a = (StyledSpace)attribute;
+
+ GUILayout.Space(a.space);
+ }
+
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
+ {
+ return -2;
+ }
+ }
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledSpaceDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledSpaceDrawer.cs.meta new file mode 100644 index 00000000..b5e5c875 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledSpaceDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: db0457065a494f34aa3b619f240d8bda
+timeCreated: 1544998323
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTextDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTextDrawer.cs new file mode 100644 index 00000000..3850da2e --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTextDrawer.cs @@ -0,0 +1,45 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+
+namespace Boxophobic.StyledGUI
+{
+ [CustomPropertyDrawer(typeof(StyledText))]
+ public class StyledTextAttributeDrawer : PropertyDrawer
+ {
+ StyledText a;
+
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+ {
+ a = (StyledText)attribute;
+
+ GUIStyle styleLabel = new GUIStyle(EditorStyles.label)
+ {
+ richText = true,
+ wordWrap = true
+ };
+
+ styleLabel.alignment = a.alignment;
+
+ GUILayout.Space(a.top);
+
+ if (a.disabled == true)
+ {
+ GUI.enabled = false;
+ }
+
+ GUILayout.Label(property.stringValue, styleLabel);
+
+ GUI.enabled = true;
+
+ GUILayout.Space(a.down);
+ }
+
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
+ {
+ return -2;
+ }
+ }
+}
+
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTextDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTextDrawer.cs.meta new file mode 100644 index 00000000..9aa5faee --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTextDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: aeec2ac650d2d8f40aa3b9e0cb807db5
+timeCreated: 1544998323
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTexturePreviewDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTexturePreviewDrawer.cs new file mode 100644 index 00000000..b95184aa --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTexturePreviewDrawer.cs @@ -0,0 +1,22 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+
+namespace Boxophobic.StyledGUI
+{
+ [CustomPropertyDrawer(typeof(StyledTexturePreview))]
+ public class StyledTexturePreviewAttributeDrawer : PropertyDrawer
+ {
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+ {
+ var rect = GUILayoutUtility.GetRect(0, 0, Screen.width, 0);
+ GUI.DrawTexture(rect, (Texture)property.objectReferenceValue, ScaleMode.StretchToFill, false);
+ }
+
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
+ {
+ return -2;
+ }
+ }
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTexturePreviewDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTexturePreviewDrawer.cs.meta new file mode 100644 index 00000000..75c7f333 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTexturePreviewDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: c8daad1bc4051084ca6204e12dc0890d
+timeCreated: 1544998323
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial.meta new file mode 100644 index 00000000..069be515 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8ed975ceb335a144c93320e22ae1780a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledBannerDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledBannerDrawer.cs new file mode 100644 index 00000000..fe4e53d6 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledBannerDrawer.cs @@ -0,0 +1,95 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+using Boxophobic.Constants;
+
+namespace Boxophobic.StyledGUI
+{
+ public class StyledBannerDrawer : MaterialPropertyDrawer
+ {
+ public string title;
+ public string subtitle;
+
+ public StyledBannerDrawer(string title, string subtitle)
+ {
+ this.title = title;
+ this.subtitle = subtitle;
+ }
+
+ public StyledBannerDrawer(string title)
+ {
+ this.title = title;
+ this.subtitle = "";
+ }
+
+ public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor materialEditor)
+ {
+ //EditorGUI.DrawRect(position, new Color(0, 1, 0, 0.05f));
+
+ Material material = materialEditor.target as Material;
+
+ DrawBanner(material.shader);
+ }
+
+ public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
+ {
+ return -2;
+ }
+
+ void DrawBanner(Shader shader)
+ {
+ GUILayout.Space(10);
+
+ 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 bannerColor;
+ Color guiColor;
+
+ if (EditorGUIUtility.isProSkin)
+ {
+ bannerColor = CONSTANT.ColorDarkGray;
+ guiColor = CONSTANT.ColorLightGray;
+ }
+ else
+ {
+ bannerColor = CONSTANT.ColorLightGray;
+ 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, "<color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + "><size=16>" + title + "</size><size=14>" + " " + subtitle + "</size></color>", CONSTANT.TitleStyle);
+#else
+ GUI.Label(bannerFullRect, "<size=14><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + "><b>" + title + "</b> " + subtitle + "</color></size>", CONSTANT.TitleStyle);
+#endif
+
+// GUI.color = guiColor;
+
+//#if AMPLIFY_SHADER_EDITOR
+// if (GUI.Button(iconRect, CONSTANT.IconEdit, new GUIStyle { alignment = TextAnchor.MiddleCenter }))
+// {
+// AmplifyShaderEditor.AmplifyShaderEditorWindow.ConvertShaderToASE(Shader.Find(shader.name));
+// }
+//#else
+// if (GUI.Button(iconRect, CONSTANT.IconEdit, new GUIStyle { alignment = TextAnchor.MiddleCenter }))
+// {
+// AssetDatabase.OpenAsset(Shader.Find(shader.name), 1);
+// }
+//#endif
+
+ GUI.color = Color.white;
+
+ GUILayout.Space(10);
+ }
+ }
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledBannerDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledBannerDrawer.cs.meta new file mode 100644 index 00000000..636d5946 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledBannerDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: 864d8c89c5d2ef240b0c51f15c5211e2
+timeCreated: 1544998323
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledButtonDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledButtonDrawer.cs new file mode 100644 index 00000000..4c1a46ae --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledButtonDrawer.cs @@ -0,0 +1,71 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+using System;
+
+namespace Boxophobic.StyledGUI
+{
+ public class StyledButtonDrawer : MaterialPropertyDrawer
+ {
+ public string text;
+ public string target = "";
+ public float value = 1;
+ public float top;
+ public float down;
+
+ public StyledButtonDrawer(string text)
+ {
+ this.text = text;
+ this.value = 1;
+ this.top = 0;
+ this.down = 0;
+ }
+
+ public StyledButtonDrawer(string text, float value, float top, float down)
+ {
+ this.text = text;
+ this.value = value;
+ this.top = top;
+ this.down = down;
+ }
+
+ public StyledButtonDrawer(string text, string target, float value, float top, float down)
+ {
+ this.text = text;
+ this.target = target;
+ this.value = value;
+ this.top = top;
+ this.down = down;
+ }
+
+ public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
+ {
+ Material material = materialEditor.target as Material;
+
+ GUILayout.Space(top);
+
+ if (GUILayout.Button(text))
+ {
+ if (target == "")
+ {
+ prop.floatValue = value;
+ }
+ else
+ {
+ if (material.HasProperty(target))
+ {
+ material.SetFloat(target, value);
+ }
+ }
+ }
+
+ GUILayout.Space(down);
+ }
+
+ public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
+ {
+ return -2;
+ }
+ }
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledButtonDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledButtonDrawer.cs.meta new file mode 100644 index 00000000..20f8fd51 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledButtonDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: b40d7a397aa055b46a1651ee9f9bdd03
+timeCreated: 1542224092
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledCategoryDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledCategoryDrawer.cs new file mode 100644 index 00000000..640cfed7 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledCategoryDrawer.cs @@ -0,0 +1,45 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+using System;
+
+namespace Boxophobic.StyledGUI
+{
+ public class StyledCategoryDrawer : MaterialPropertyDrawer
+ {
+ public string category;
+
+ public StyledCategoryDrawer(string category)
+ {
+ this.category = category;
+ }
+
+ public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materiaEditor)
+ {
+ if (prop.floatValue < 0)
+ {
+ GUI.enabled = true;
+ EditorGUI.indentLevel = 0;
+ }
+ else
+ {
+ GUI.enabled = true;
+ EditorGUI.indentLevel = 0;
+ StyledGUI.DrawInspectorCategory(position, category);
+ }
+ }
+
+ public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
+ {
+ if (prop.floatValue < 0)
+ {
+ return -2;
+ }
+ else
+ {
+ return 40;
+ }
+ }
+ }
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledCategoryDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledCategoryDrawer.cs.meta new file mode 100644 index 00000000..e853f827 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledCategoryDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: 1b5715cd99e4a2e4c91d69653d31dad9
+timeCreated: 1542224092
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledDiffusionMaterialDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledDiffusionMaterialDrawer.cs new file mode 100644 index 00000000..c3b6afeb --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledDiffusionMaterialDrawer.cs @@ -0,0 +1,93 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+using System;
+
+namespace Boxophobic.StyledGUI
+{
+ public class StyledDiffusionMaterialDrawer : MaterialPropertyDrawer
+ {
+ public string propName;
+ //GUIStyle styleCenteredHelpBox;
+
+ public StyledDiffusionMaterialDrawer(string propName)
+ {
+ this.propName = propName;
+ }
+
+ public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
+ {
+ //SetGUIStyles();
+
+ Material material = materialEditor.target as Material;
+
+ UnityEngine.Object materialAsset = null;
+
+ GUILayout.Space(5);
+
+ if (material.GetInt(propName) == 0)
+ {
+ EditorGUILayout.HelpBox("Diffusion profile values not set! Due to the current HDRP architecture the diffusion profiles are not directly supported. You will need to create an HDRP Lit material and assign a Diffusion Profile to it, drag this HDRP material to the " + label + " slot to allow the profile values to be copied to the material. The HDRP material will not be saved to the property field! Please refer to the documentation for more information.", MessageType.Warning);
+ }
+ else
+ {
+ EditorGUILayout.HelpBox("Diffusion profile values set! Due to the current HDRP architecture the diffusion profiles are not directly supported. You will need to create an HDRP Lit material and assign a Diffusion Profile to it, drag this HDRP material to the " + label + " slot to allow the profile values to be copied to the material. The HDRP material will not be saved to the property field! Please refer to the documentation for more information.", MessageType.Info);
+ }
+
+ GUILayout.Space(10);
+
+ materialAsset = (Material)EditorGUILayout.ObjectField(label, materialAsset, typeof(Material), false);
+
+ Material materialObject = AssetDatabase.LoadAssetAtPath<Material>(AssetDatabase.GetAssetPath(materialAsset));
+
+ if (materialAsset != null)
+ {
+ if (materialObject.HasProperty("_DiffusionProfileAsset") && materialObject.HasProperty("_DiffusionProfileHash"))
+ {
+ var diffusionProfileAsset = materialObject.GetVector("_DiffusionProfileAsset");
+ var diffusionProfileHash = materialObject.GetFloat("_DiffusionProfileHash");
+
+ if (diffusionProfileAsset.x != 0 && diffusionProfileHash != 0)
+ {
+ material.SetVector(propName + "_asset", diffusionProfileAsset);
+ material.SetFloat(propName, diffusionProfileHash);
+
+ Debug.Log("Diffusion Profile settings copied from " + materialObject.name + "!");
+
+ materialAsset = null;
+ }
+ else
+ {
+ material.SetVector(propName + "_asset", Vector4.zero);
+ material.SetFloat(propName, 0.0f);
+
+ Debug.Log("Diffusion Profile settings set to None because " + materialObject.name + " has no Diffusion Profile asset!");
+
+ materialAsset = null;
+ }
+ }
+ else
+ {
+ Debug.Log("The Material used to copy the Diffusion Profile does not a valid Diffusion Profile!");
+ }
+ }
+
+ //EditorGUI.HelpBox(new Rect(position.x, position.y + top, position.width, position.height), message, mType);
+ }
+
+ public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
+ {
+ return -2;
+ }
+
+ //void SetGUIStyles()
+ //{
+ // styleCenteredHelpBox = new GUIStyle(GUI.skin.GetStyle("HelpBox"))
+ // {
+ // alignment = TextAnchor.MiddleCenter,
+ // };
+
+ //}
+ }
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledDiffusionMaterialDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledDiffusionMaterialDrawer.cs.meta new file mode 100644 index 00000000..d01d4c28 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledDiffusionMaterialDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f13faeb510c3cb54ba5d051ecaad26e3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledIndentDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledIndentDrawer.cs new file mode 100644 index 00000000..0905c5a0 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledIndentDrawer.cs @@ -0,0 +1,30 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+using System;
+
+namespace Boxophobic.StyledGUI
+{
+ public class StyledIndentDrawer : MaterialPropertyDrawer
+ {
+ public float indent;
+
+ public StyledIndentDrawer(float indent)
+ {
+ this.indent = indent;
+ }
+
+ public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
+ {
+ //Material material = materialEditor.target as Material;
+
+ EditorGUI.indentLevel = (int)indent;
+ }
+
+ public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
+ {
+ return -2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledIndentDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledIndentDrawer.cs.meta new file mode 100644 index 00000000..2b9a0ba3 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledIndentDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ae4fb3d8081065c47860724ea515c97c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledInteractiveDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledInteractiveDrawer.cs new file mode 100644 index 00000000..3f321cbe --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledInteractiveDrawer.cs @@ -0,0 +1,92 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+using System;
+
+namespace Boxophobic.StyledGUI
+{
+ public class StyledInteractiveDrawer : MaterialPropertyDrawer
+ {
+ public string keyword;
+ public float value1 = -1f;
+ public float value2 = -1f;
+ public float value3 = -1f;
+
+ protected int type;
+
+ public StyledInteractiveDrawer(string k)
+ {
+ type = 0;
+ keyword = k;
+ }
+
+ public StyledInteractiveDrawer(string k, float v1)
+ {
+ type = 1;
+ keyword = k;
+ value1 = v1;
+ }
+
+ public StyledInteractiveDrawer(string k, float v1, float v2)
+ {
+ type = 1;
+ keyword = k;
+ value1 = v1;
+ value2 = v2;
+ }
+
+ public StyledInteractiveDrawer(string k, float v1, float v2, float v3)
+ {
+ type = 1;
+ keyword = k;
+ value1 = v1;
+ value2 = v2;
+ value3 = v3;
+ }
+
+ public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
+ {
+ Material material = materialEditor.target as Material;
+
+ if (type == 1)
+ {
+ if (material.HasProperty(keyword))
+ {
+ if (value1 == material.GetFloat(keyword) || value2 == material.GetFloat(keyword) || value3 == material.GetFloat(keyword))
+ {
+ GUI.enabled = true;
+ }
+ else
+ {
+ GUI.enabled = false;
+ }
+ }
+ }
+ else if (type == 0)
+ {
+ if (keyword == "ON")
+ {
+ GUI.enabled = true;
+ }
+ else if (keyword == "OFF")
+ {
+ GUI.enabled = false;
+ }
+ else if (material.IsKeywordEnabled(keyword))
+ {
+ GUI.enabled = true;
+ }
+ else
+ {
+ GUI.enabled = false;
+ }
+ }
+ }
+
+ public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
+ {
+ return -2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledInteractiveDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledInteractiveDrawer.cs.meta new file mode 100644 index 00000000..c0f32f8b --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledInteractiveDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: 7cc33d297d20daa40a9b09fbb8e59502
+timeCreated: 1544039105
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledMessageDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledMessageDrawer.cs new file mode 100644 index 00000000..de9414a4 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledMessageDrawer.cs @@ -0,0 +1,90 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+using System;
+
+namespace Boxophobic.StyledGUI
+{
+ public class StyledMessageDrawer : MaterialPropertyDrawer
+ {
+ public string type;
+ public string message;
+ public string keyword;
+ public float value;
+ public float top;
+ public float down;
+
+ MessageType mType;
+
+ public StyledMessageDrawer(string t, string m, float top, float down)
+ {
+ type = t;
+ message = m;
+ keyword = null;
+
+ this.top = top;
+ this.down = down;
+ }
+
+ public StyledMessageDrawer(string t, string m, string k, float v, float top, float down)
+ {
+ type = t;
+ message = m;
+ keyword = k;
+ value = v;
+
+ this.top = top;
+ this.down = down;
+ }
+
+ public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
+ {
+ Material material = materialEditor.target as Material;
+
+ if (type == "None")
+ {
+ mType = MessageType.None;
+ }
+ else if (type == "Info")
+ {
+ mType = MessageType.Info;
+ }
+ else if (type == "Warning")
+ {
+ mType = MessageType.Warning;
+ }
+ else if (type == "Error")
+ {
+ mType = MessageType.Error;
+ }
+
+ if (keyword != null)
+ {
+ if (material.HasProperty(keyword))
+ {
+ if (material.GetFloat(keyword) == value)
+ {
+ GUILayout.Space(top);
+ //EditorGUI.DrawRect(new Rect(position.x, position.y + Top, position.width, position.height), new Color(1,0,0,0.3f));
+ EditorGUILayout.HelpBox(message, mType);
+ //EditorGUI.HelpBox(new Rect(position.x, position.y + top, position.width, position.height), message, mType);
+ GUILayout.Space(down);
+
+ }
+ }
+ }
+ else
+ {
+ GUILayout.Space(top);
+ EditorGUILayout.HelpBox(message, mType);
+ GUILayout.Space(down);
+ }
+ }
+
+ public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
+ {
+ return -2;
+ }
+ }
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledMessageDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledMessageDrawer.cs.meta new file mode 100644 index 00000000..74e720bc --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledMessageDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: d01ce91280120de49b931b40f9e16f6b
+timeCreated: 1542224092
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledSpaceDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledSpaceDrawer.cs new file mode 100644 index 00000000..24a38b3c --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledSpaceDrawer.cs @@ -0,0 +1,31 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+
+namespace Boxophobic.StyledGUI
+{
+ public class StyledSpaceDrawer : MaterialPropertyDrawer
+ {
+ public float space;
+
+ public StyledSpaceDrawer(float space)
+ {
+ this.space = space;
+ }
+
+ public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor materialEditor)
+ {
+ //EditorGUI.DrawRect(position, new Color(0, 1, 0, 0.05f));
+
+ //Material material = materialEditor.target as Material;
+
+ GUILayout.Space(space);
+ }
+
+ public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
+ {
+ return -2;
+ }
+ }
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledSpaceDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledSpaceDrawer.cs.meta new file mode 100644 index 00000000..05335608 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledSpaceDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: 1f2f57e67392e5b41af1a4cecc3a6c04
+timeCreated: 1544998323
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextDrawer.cs new file mode 100644 index 00000000..88e07a48 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextDrawer.cs @@ -0,0 +1,99 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+using System;
+
+namespace Boxophobic.StyledGUI
+{
+ public class StyledTextDrawer : MaterialPropertyDrawer
+ {
+ public string text = "";
+ public string alignment = "Center";
+ public string font = "Normal";
+ public string disabled = "";
+ public float size = 11;
+ public float top = 0;
+ public float down = 0;
+
+ public StyledTextDrawer(string text)
+ {
+ this.text = text;
+ }
+
+ public StyledTextDrawer(string text, string alignment, string font, string disabled, float size)
+ {
+ this.text = text;
+ this.alignment = alignment;
+ this.font = font;
+ this.disabled = disabled;
+ this.size = size;
+ }
+
+ public StyledTextDrawer(string text, string alignment, string font, string disabled, float size, float top, float down)
+ {
+ this.text = text;
+ this.alignment = alignment;
+ this.font = font;
+ this.disabled = disabled;
+ this.size = size;
+ this.top = top;
+ this.down = down;
+ }
+
+ public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
+ {
+ //Material material = materialEditor.target as Material;
+
+ GUIStyle styleLabel = new GUIStyle(EditorStyles.label)
+ {
+ richText = true,
+ alignment = TextAnchor.MiddleCenter,
+ wordWrap = true
+ };
+
+ GUILayout.Space(top);
+
+ if (alignment == "Center")
+ {
+ styleLabel.alignment = TextAnchor.MiddleCenter;
+
+ }
+ else if (alignment == "Left")
+ {
+ styleLabel.alignment = TextAnchor.MiddleCenter;
+ }
+ else if (alignment == "Left")
+ {
+ styleLabel.alignment = TextAnchor.MiddleCenter;
+ }
+
+ if (font == "Bold")
+ {
+ styleLabel.fontStyle = FontStyle.Bold;
+ }
+ else
+ {
+ styleLabel.fontStyle = FontStyle.Normal;
+ }
+
+ styleLabel.fontSize = (int)size;
+
+ if (disabled == "Disabled")
+ {
+ GUI.enabled = false;
+ }
+
+ GUILayout.Label(text, styleLabel);
+
+ GUI.enabled = true;
+
+ GUILayout.Space(down);
+ }
+
+ public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
+ {
+ return -2;
+ }
+ }
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextDrawer.cs.meta new file mode 100644 index 00000000..35f119db --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: e137daebc2f7e0c4aa0ee5c5b140e8fd
+timeCreated: 1542224092
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledToggleDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledToggleDrawer.cs new file mode 100644 index 00000000..79fb4543 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledToggleDrawer.cs @@ -0,0 +1,80 @@ +// Cristian Pop - https://boxophobic.com/
+
+using UnityEngine;
+using UnityEditor;
+using System;
+
+namespace Boxophobic.StyledGUI
+{
+ public class StyledToggleDrawer : MaterialPropertyDrawer
+ {
+ public float width = 0;
+
+ public StyledToggleDrawer()
+ {
+
+ }
+
+ public StyledToggleDrawer(float width)
+ {
+ this.width = width;
+ }
+
+ public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
+ {
+ Material material = materialEditor.target as Material;
+
+ if (width == 0)
+ {
+ bool toggle = false;
+
+ if (prop.floatValue > 0.5f)
+ {
+ toggle = true;
+ }
+
+ toggle = EditorGUILayout.Toggle(label, toggle);
+
+ if (toggle)
+ {
+ prop.floatValue = 1;
+ }
+ else
+ {
+ prop.floatValue = 0;
+ }
+ }
+ else
+ {
+ GUILayout.BeginHorizontal();
+
+ GUILayout.Label(label);
+
+ bool toggle = false;
+
+ if (prop.floatValue > 0.5f)
+ {
+ toggle = true;
+ }
+
+ toggle = GUILayout.Toggle(toggle, "", GUILayout.Width(width));
+
+ if (toggle)
+ {
+ prop.floatValue = 1;
+ }
+ else
+ {
+ prop.floatValue = 0;
+ }
+
+ GUILayout.EndHorizontal();
+ }
+ }
+
+ public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
+ {
+ return -2;
+ }
+ }
+}
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledToggleDrawer.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledToggleDrawer.cs.meta new file mode 100644 index 00000000..33897f35 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledToggleDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: d5699c954b5c9184199293b4ede31d57
+timeCreated: 1542224092
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMono.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledMono.meta new file mode 100644 index 00000000..7ea21e4b --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMono.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5a3babbb69c72f8419243020c0dfb70b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMono/StyledMonoBehaviourEditor.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledMono/StyledMonoBehaviourEditor.cs new file mode 100644 index 00000000..db30921f --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMono/StyledMonoBehaviourEditor.cs @@ -0,0 +1,20 @@ +//#if UNITY_EDITOR
+using UnityEditor;
+
+namespace Boxophobic.StyledGUI
+{
+ [CustomEditor(typeof(StyledMonoBehaviour), true)]
+ [CanEditMultipleObjects]
+ public class StyledMonoBehaviourEditor : Editor
+ {
+ public override void OnInspectorGUI()
+ {
+ serializedObject.Update();
+ EditorGUI.BeginChangeCheck();
+ DrawPropertiesExcluding(serializedObject, "m_Script");
+ if (EditorGUI.EndChangeCheck())
+ serializedObject.ApplyModifiedProperties();
+ }
+ }
+}
+//#endif
\ No newline at end of file diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMono/StyledMonoBehaviourEditor.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledMono/StyledMonoBehaviourEditor.cs.meta new file mode 100644 index 00000000..f60827ff --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMono/StyledMonoBehaviourEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 29c1ac24df072a744a4bdc6a209772bf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMono/StyledScriptableObjectEditor.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledMono/StyledScriptableObjectEditor.cs new file mode 100644 index 00000000..accb83f3 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMono/StyledScriptableObjectEditor.cs @@ -0,0 +1,20 @@ +//#if UNITY_EDITOR
+using UnityEditor;
+
+namespace Boxophobic.StyledGUI
+{
+ [CustomEditor(typeof(StyledScriptableObject), true)]
+ [CanEditMultipleObjects]
+ public class StyledScriptableObjectEditor : Editor
+ {
+ public override void OnInspectorGUI()
+ {
+ serializedObject.Update();
+ EditorGUI.BeginChangeCheck();
+ DrawPropertiesExcluding(serializedObject, "m_Script");
+ if (EditorGUI.EndChangeCheck())
+ serializedObject.ApplyModifiedProperties();
+ }
+ }
+}
+//#endif
\ No newline at end of file diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMono/StyledScriptableObjectEditor.cs.meta b/Assets/BOXOPHOBIC/Utils/Editor/StyledMono/StyledScriptableObjectEditor.cs.meta new file mode 100644 index 00000000..cfff437a --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMono/StyledScriptableObjectEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7a0e1a0aaab33f341b20d7d940fe0a06 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |