diff options
Diffstat (limited to 'Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial')
20 files changed, 844 insertions, 0 deletions
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:
|