diff options
author | chai <chaifix@163.com> | 2020-11-26 20:52:34 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-11-26 20:52:34 +0800 |
commit | 5b158af90739dcbb89c1538a6cb8c65a875dce80 (patch) | |
tree | f0437fff6efaab91ac850152a08aef288d572aab /Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledButtonDrawer.cs | |
parent | bc4d5201fc537f70cdcb576b57aaeb5d96527112 (diff) |
*misc
Diffstat (limited to 'Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledButtonDrawer.cs')
-rw-r--r-- | Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledButtonDrawer.cs | 71 |
1 files changed, 71 insertions, 0 deletions
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;
+ }
+ }
+}
|