extra assets + decoration
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Boxophobic.Constants;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledBannerDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public string title;
|
||||
|
||||
public StyledBannerDrawer(string title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor materialEditor)
|
||||
{
|
||||
StyledGUI.DrawInspectorBanner(title);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 864d8c89c5d2ef240b0c51f15c5211e2
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b40d7a397aa055b46a1651ee9f9bdd03
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,126 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledCategoryDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public bool isEnabled = true;
|
||||
|
||||
public string category;
|
||||
public float top;
|
||||
public float down;
|
||||
public string colapsable;
|
||||
public string conditions = "";
|
||||
|
||||
public StyledCategoryDrawer(string category)
|
||||
{
|
||||
this.category = category;
|
||||
this.colapsable = "false";
|
||||
this.top = 10;
|
||||
this.down = 10;
|
||||
}
|
||||
|
||||
public StyledCategoryDrawer(string category, string colapsable)
|
||||
{
|
||||
this.category = category;
|
||||
this.colapsable = colapsable;
|
||||
this.top = 10;
|
||||
this.down = 10;
|
||||
}
|
||||
|
||||
public StyledCategoryDrawer(string category, float top, float down)
|
||||
{
|
||||
this.category = category;
|
||||
this.colapsable = "false";
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public StyledCategoryDrawer(string category, string colapsable, float top, float down)
|
||||
{
|
||||
this.category = category;
|
||||
this.colapsable = colapsable;
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public StyledCategoryDrawer(string category, string colapsable, string conditions, float top, float down)
|
||||
{
|
||||
this.category = category;
|
||||
this.colapsable = colapsable;
|
||||
this.conditions = conditions;
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
|
||||
{
|
||||
GUI.enabled = true;
|
||||
EditorGUI.indentLevel = 0;
|
||||
|
||||
if (conditions == "")
|
||||
{
|
||||
DrawInspector(prop);
|
||||
}
|
||||
else
|
||||
{
|
||||
Material material = materialEditor.target as Material;
|
||||
|
||||
bool showInspector = false;
|
||||
|
||||
string[] split = conditions.Split(char.Parse(" "));
|
||||
|
||||
for (int i = 0; i < split.Length; i++)
|
||||
{
|
||||
if (material.HasProperty(split[i]))
|
||||
{
|
||||
showInspector = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (showInspector)
|
||||
{
|
||||
DrawInspector(prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
void DrawInspector(MaterialProperty prop)
|
||||
{
|
||||
bool isColapsable = false;
|
||||
|
||||
if (colapsable == "true")
|
||||
{
|
||||
isColapsable = true;
|
||||
}
|
||||
|
||||
//bool isEnabled = true;
|
||||
|
||||
//if (prop.floatValue < 0.5f)
|
||||
//{
|
||||
// isEnabled = false;
|
||||
//}
|
||||
|
||||
isEnabled = StyledGUI.DrawInspectorCategory(category, isEnabled, isColapsable, top, down);
|
||||
|
||||
//if (isEnabled)
|
||||
//{
|
||||
// prop.floatValue = 1;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// prop.floatValue = 0;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b5715cd99e4a2e4c91d69653d31dad9
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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,
|
||||
// };
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f13faeb510c3cb54ba5d051ecaad26e3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,119 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
public class StyledEmissiveIntensityDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public string reference = "";
|
||||
public float top = 0;
|
||||
public float down = 0;
|
||||
|
||||
public StyledEmissiveIntensityDrawer()
|
||||
{
|
||||
this.top = 0;
|
||||
this.down = 0;
|
||||
}
|
||||
|
||||
public StyledEmissiveIntensityDrawer(string reference)
|
||||
{
|
||||
this.reference = reference;
|
||||
this.top = 0;
|
||||
this.down = 0;
|
||||
}
|
||||
|
||||
public StyledEmissiveIntensityDrawer(float top, float down)
|
||||
{
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public StyledEmissiveIntensityDrawer(string reference, float top, float down)
|
||||
{
|
||||
this.reference = reference;
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor editor)
|
||||
{
|
||||
var stylePopup = new GUIStyle(EditorStyles.popup)
|
||||
{
|
||||
fontSize = 9,
|
||||
alignment = TextAnchor.MiddleCenter,
|
||||
};
|
||||
|
||||
var internalReference = MaterialEditor.GetMaterialProperty(editor.targets, reference);
|
||||
|
||||
Vector4 propVector = prop.vectorValue;
|
||||
|
||||
GUILayout.Space(top);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUI.showMixedValue = prop.hasMixedValue;
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(-1);
|
||||
GUILayout.Label(label, GUILayout.Width(EditorGUIUtility.labelWidth - 1));
|
||||
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Space(3);
|
||||
|
||||
if (propVector.w == 0)
|
||||
{
|
||||
propVector.y = EditorGUILayout.FloatField(propVector.y, GUILayout.Height(17));
|
||||
}
|
||||
else if (propVector.w == 1)
|
||||
{
|
||||
propVector.z = EditorGUILayout.FloatField(propVector.z, GUILayout.Height(17));
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.Space(2);
|
||||
|
||||
propVector.w = (float)EditorGUILayout.Popup((int)propVector.w, new string[] { "Nits", "EV100" }, stylePopup, GUILayout.Width(50));
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
EditorGUI.showMixedValue = false;
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
if (propVector.w == 0)
|
||||
{
|
||||
propVector.x = propVector.y;
|
||||
}
|
||||
else if (propVector.w == 1)
|
||||
{
|
||||
propVector.x = ConvertEvToLuminance(propVector.z);
|
||||
}
|
||||
|
||||
if (internalReference.displayName != null)
|
||||
{
|
||||
internalReference.floatValue = propVector.x;
|
||||
}
|
||||
|
||||
prop.vectorValue = propVector;
|
||||
}
|
||||
|
||||
GUILayout.Space(down);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
//public float ConvertLuminanceToEv(float luminance)
|
||||
//{
|
||||
// return (float)Math.Log((luminance * 100f) / 12.5f, 2);
|
||||
//}
|
||||
|
||||
public float ConvertEvToLuminance(float ev)
|
||||
{
|
||||
return (12.5f / 100.0f) * Mathf.Pow(2f, ev);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1d76466e8080c147b2fa9e3b42e8850
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,92 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledEnumDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public string file = "";
|
||||
public string options = "";
|
||||
|
||||
public float top = 0;
|
||||
public float down = 0;
|
||||
|
||||
public StyledEnumDrawer(string file, string options, float top, float down)
|
||||
{
|
||||
this.file = file;
|
||||
this.options = options;
|
||||
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
|
||||
{
|
||||
GUIStyle styleLabel = new GUIStyle(EditorStyles.label)
|
||||
{
|
||||
richText = true,
|
||||
alignment = TextAnchor.MiddleCenter,
|
||||
wordWrap = true
|
||||
};
|
||||
|
||||
if (Resources.Load<TextAsset>(file) != null)
|
||||
{
|
||||
var layersPath = AssetDatabase.GetAssetPath(Resources.Load<TextAsset>(file));
|
||||
|
||||
StreamReader reader = new StreamReader(layersPath);
|
||||
|
||||
options = reader.ReadLine();
|
||||
|
||||
reader.Close();
|
||||
}
|
||||
|
||||
string[] enumSplit = options.Split(char.Parse(" "));
|
||||
List<string> enumOptions = new List<string>(enumSplit.Length / 2);
|
||||
List<int> enumIndices = new List<int>(enumSplit.Length / 2);
|
||||
|
||||
for (int i = 0; i < enumSplit.Length; i++)
|
||||
{
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
enumOptions.Add(enumSplit[i].Replace("_", " "));
|
||||
}
|
||||
else
|
||||
{
|
||||
enumIndices.Add(int.Parse(enumSplit[i]));
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(top);
|
||||
|
||||
int index = (int)prop.floatValue;
|
||||
int realIndex = enumIndices[0];
|
||||
|
||||
for (int i = 0; i < enumIndices.Count; i++)
|
||||
{
|
||||
if (enumIndices[i] == index)
|
||||
{
|
||||
realIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
realIndex = EditorGUILayout.Popup(prop.displayName, realIndex, enumOptions.ToArray());
|
||||
|
||||
//Debug Value
|
||||
//EditorGUILayout.LabelField(enumIndices[realIndex].ToString());
|
||||
|
||||
prop.floatValue = enumIndices[realIndex];
|
||||
|
||||
GUILayout.Space(down);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5dbd5cf6c68f1d4ebd1369f8795ee3a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae4fb3d8081065c47860724ea515c97c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledInteractiveDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public StyledInteractiveDrawer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
|
||||
{
|
||||
if (prop.floatValue > 0.5f)
|
||||
{
|
||||
GUI.enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cc33d297d20daa40a9b09fbb8e59502
|
||||
timeCreated: 1544039105
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,74 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledLayersDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public float top = 0;
|
||||
public float down = 0;
|
||||
|
||||
public StyledLayersDrawer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public StyledLayersDrawer(float top, float down)
|
||||
{
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
|
||||
{
|
||||
GUIStyle styleLabel = new GUIStyle(EditorStyles.label)
|
||||
{
|
||||
richText = true,
|
||||
alignment = TextAnchor.MiddleCenter,
|
||||
wordWrap = true
|
||||
};
|
||||
|
||||
int index = (int)prop.floatValue;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(top);
|
||||
|
||||
index = EditorGUILayout.MaskField(prop.displayName, index, allLayers);
|
||||
|
||||
//if (index < 0)
|
||||
//{
|
||||
// index = -1;
|
||||
//}
|
||||
|
||||
//Debug Value
|
||||
//EditorGUILayout.LabelField(index.ToString());
|
||||
|
||||
prop.floatValue = index;
|
||||
|
||||
GUILayout.Space(down);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c837d89f6f4cd574595a810c5fcc15f8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,83 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledMaskDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public string file = "";
|
||||
public string options = "";
|
||||
|
||||
public float top = 0;
|
||||
public float down = 0;
|
||||
|
||||
public StyledMaskDrawer(string file, string options, float top, float down)
|
||||
{
|
||||
this.file = file;
|
||||
this.options = options;
|
||||
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
|
||||
{
|
||||
GUIStyle styleLabel = new GUIStyle(EditorStyles.label)
|
||||
{
|
||||
richText = true,
|
||||
alignment = TextAnchor.MiddleCenter,
|
||||
wordWrap = true
|
||||
};
|
||||
|
||||
if (Resources.Load<TextAsset>(file) != null)
|
||||
{
|
||||
var layersPath = AssetDatabase.GetAssetPath(Resources.Load<TextAsset>(file));
|
||||
|
||||
StreamReader reader = new StreamReader(layersPath);
|
||||
|
||||
options = reader.ReadLine();
|
||||
|
||||
reader.Close();
|
||||
}
|
||||
|
||||
string[] enumSplit = options.Split(char.Parse(" "));
|
||||
List<string> enumOptions = new List<string>(enumSplit.Length / 2);
|
||||
|
||||
for (int i = 0; i < enumSplit.Length; i++)
|
||||
{
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
enumOptions.Add(enumSplit[i].Replace("_", " "));
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(top);
|
||||
|
||||
int index = (int)prop.floatValue;
|
||||
|
||||
index = EditorGUILayout.MaskField(prop.displayName, index, enumOptions.ToArray());
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
index = -1;
|
||||
}
|
||||
|
||||
//Debug Value
|
||||
//EditorGUILayout.LabelField(index.ToString());
|
||||
|
||||
prop.floatValue = index;
|
||||
|
||||
GUILayout.Space(down);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd2d7ee86763017438ae71ea6a9800f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,102 @@
|
||||
// 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)
|
||||
{
|
||||
type = t;
|
||||
message = m;
|
||||
keyword = null;
|
||||
|
||||
this.top = 0;
|
||||
this.down = 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
message = message.Replace("__", ",");
|
||||
|
||||
if (keyword != null)
|
||||
{
|
||||
if (material.HasProperty(keyword))
|
||||
{
|
||||
if (material.GetFloat(keyword) == value)
|
||||
{
|
||||
GUILayout.Space(top);
|
||||
|
||||
EditorGUILayout.HelpBox(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d01ce91280120de49b931b40f9e16f6b
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,184 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
public class StyledOptionsSliderDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public string nameMin = "";
|
||||
public string nameMax = "";
|
||||
public string nameVal = "";
|
||||
public float min = 0;
|
||||
public float max = 0;
|
||||
public float val = 0;
|
||||
public float top = 0;
|
||||
public float down = 0;
|
||||
|
||||
bool showAdvancedOptions = false;
|
||||
|
||||
public StyledOptionsSliderDrawer(string nameMin, string nameMax, string nameVal, float min, float max, float val)
|
||||
{
|
||||
this.nameMin = nameMin;
|
||||
this.nameMax = nameMax;
|
||||
this.nameVal = nameVal;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.val = val;
|
||||
this.top = 0;
|
||||
this.down = 0;
|
||||
}
|
||||
|
||||
public StyledOptionsSliderDrawer(string nameMin, string nameMax, string nameVal, float min, float max, float val, float top, float down)
|
||||
{
|
||||
this.nameMin = nameMin;
|
||||
this.nameMax = nameMax;
|
||||
this.nameVal = nameVal;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.val = val;
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor editor)
|
||||
{
|
||||
var internalPropMin = MaterialEditor.GetMaterialProperty(editor.targets, nameMin);
|
||||
var internalPropMax = MaterialEditor.GetMaterialProperty(editor.targets, nameMax);
|
||||
var internalPropVal = MaterialEditor.GetMaterialProperty(editor.targets, nameVal);
|
||||
|
||||
if (internalPropMin.displayName != null && internalPropMax.displayName != null && internalPropVal.displayName != null)
|
||||
{
|
||||
var stylePopup = new GUIStyle(EditorStyles.popup)
|
||||
{
|
||||
fontSize = 9,
|
||||
};
|
||||
|
||||
var styleButton = new GUIStyle(EditorStyles.label)
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
var internalValueMin = internalPropMin.floatValue;
|
||||
var internalValueMax = internalPropMax.floatValue;
|
||||
var internalValueVal = internalPropVal.floatValue;
|
||||
Vector4 propVector = prop.vectorValue;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
if (propVector.w == 2)
|
||||
{
|
||||
propVector.x = min;
|
||||
propVector.y = max;
|
||||
propVector.z = internalValueVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (internalValueMin <= internalValueMax)
|
||||
{
|
||||
propVector.w = 0;
|
||||
}
|
||||
else if (internalValueMin > internalValueMax)
|
||||
{
|
||||
propVector.w = 1;
|
||||
}
|
||||
|
||||
if (propVector.w == 0)
|
||||
{
|
||||
propVector.x = internalValueMin;
|
||||
propVector.y = internalValueMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
propVector.x = internalValueMax;
|
||||
propVector.y = internalValueMin;
|
||||
}
|
||||
|
||||
propVector.z = val;
|
||||
}
|
||||
|
||||
GUILayout.Space(top);
|
||||
|
||||
EditorGUI.showMixedValue = prop.hasMixedValue;
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(label, styleButton, GUILayout.Width(EditorGUIUtility.labelWidth), GUILayout.Height(18)))
|
||||
{
|
||||
showAdvancedOptions = !showAdvancedOptions;
|
||||
}
|
||||
|
||||
if (propVector.w == 2)
|
||||
{
|
||||
propVector.z = GUILayout.HorizontalSlider(propVector.z, min, max);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.MinMaxSlider(ref propVector.x, ref propVector.y, min, max);
|
||||
}
|
||||
|
||||
GUILayout.Space(2);
|
||||
|
||||
propVector.w = (float)EditorGUILayout.Popup((int)propVector.w, new string[] { "Remap", "Invert", "Simple"}, stylePopup, GUILayout.Width(50));
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
if (showAdvancedOptions)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(-1);
|
||||
GUILayout.Label(" Remap Min", GUILayout.Width(EditorGUIUtility.labelWidth));
|
||||
propVector.x = EditorGUILayout.Slider(propVector.x, min, max);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(-1);
|
||||
GUILayout.Label(" Remap Max", GUILayout.Width(EditorGUIUtility.labelWidth));
|
||||
propVector.y = EditorGUILayout.Slider(propVector.y, min, max);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(-1);
|
||||
GUILayout.Label(" Simple Value", GUILayout.Width(EditorGUIUtility.labelWidth));
|
||||
propVector.z = EditorGUILayout.Slider(propVector.z, min, max);
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
if (propVector.w == 0f)
|
||||
{
|
||||
internalValueMin = propVector.x;
|
||||
internalValueMax = propVector.y;
|
||||
internalValueVal = val;
|
||||
}
|
||||
else if (propVector.w == 1f)
|
||||
{
|
||||
internalValueMin = propVector.y;
|
||||
internalValueMax = propVector.x;
|
||||
internalValueVal = val;
|
||||
}
|
||||
else if (propVector.w == 2f)
|
||||
{
|
||||
internalValueMin = min;
|
||||
internalValueMax = max;
|
||||
internalValueVal = propVector.z;
|
||||
}
|
||||
|
||||
EditorGUI.showMixedValue = false;
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
prop.vectorValue = propVector;
|
||||
internalPropMin.floatValue = internalValueMin;
|
||||
internalPropMax.floatValue = internalValueMax;
|
||||
internalPropVal.floatValue = internalValueVal;
|
||||
}
|
||||
|
||||
GUILayout.Space(down);
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d4bc1ff93a8a28e42954d7469249a7a0
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,143 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
public class StyledRemapSliderDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public string nameMin = "";
|
||||
public string nameMax = "";
|
||||
public float min = 0;
|
||||
public float max = 0;
|
||||
public float top = 0;
|
||||
public float down = 0;
|
||||
|
||||
bool showAdvancedOptions = false;
|
||||
|
||||
public StyledRemapSliderDrawer(string nameMin, string nameMax, float min, float max)
|
||||
{
|
||||
this.nameMin = nameMin;
|
||||
this.nameMax = nameMax;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.top = 0;
|
||||
this.down = 0;
|
||||
}
|
||||
|
||||
public StyledRemapSliderDrawer(string nameMin, string nameMax, float min, float max, float top, float down)
|
||||
{
|
||||
this.nameMin = nameMin;
|
||||
this.nameMax = nameMax;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor editor)
|
||||
{
|
||||
var internalPropMin = MaterialEditor.GetMaterialProperty(editor.targets, nameMin);
|
||||
var internalPropMax = MaterialEditor.GetMaterialProperty(editor.targets, nameMax);
|
||||
|
||||
if (internalPropMin.displayName != null && internalPropMax.displayName != null)
|
||||
{
|
||||
var stylePopup = new GUIStyle(EditorStyles.popup)
|
||||
{
|
||||
fontSize = 9,
|
||||
};
|
||||
|
||||
var styleButton = new GUIStyle(EditorStyles.label)
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
var internalValueMin = internalPropMin.floatValue;
|
||||
var internalValueMax = internalPropMax.floatValue;
|
||||
Vector4 propVector = prop.vectorValue;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
if (internalValueMin <= internalValueMax)
|
||||
{
|
||||
propVector.w = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
propVector.w = 1;
|
||||
}
|
||||
|
||||
if (propVector.w == 0)
|
||||
{
|
||||
propVector.x = internalValueMin;
|
||||
propVector.y = internalValueMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
propVector.x = internalValueMax;
|
||||
propVector.y = internalValueMin;
|
||||
}
|
||||
|
||||
GUILayout.Space(top);
|
||||
|
||||
EditorGUI.showMixedValue = prop.hasMixedValue;
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(label, styleButton, GUILayout.Width(EditorGUIUtility.labelWidth), GUILayout.Height(18)))
|
||||
{
|
||||
showAdvancedOptions = !showAdvancedOptions;
|
||||
}
|
||||
|
||||
EditorGUILayout.MinMaxSlider(ref propVector.x, ref propVector.y, min, max);
|
||||
|
||||
GUILayout.Space(2);
|
||||
|
||||
propVector.w = (float)EditorGUILayout.Popup((int)propVector.w, new string[] { "Remap", "Invert" }, stylePopup, GUILayout.Width(50));
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
if (showAdvancedOptions)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(-1);
|
||||
GUILayout.Label(" Remap Min", GUILayout.Width(EditorGUIUtility.labelWidth));
|
||||
propVector.x = EditorGUILayout.Slider(propVector.x, min, max);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(-1);
|
||||
GUILayout.Label(" Remap Max", GUILayout.Width(EditorGUIUtility.labelWidth));
|
||||
propVector.y = EditorGUILayout.Slider(propVector.y, min, max);
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
if (propVector.w == 0f)
|
||||
{
|
||||
internalValueMin = propVector.x;
|
||||
internalValueMax = propVector.y;
|
||||
}
|
||||
else if (propVector.w == 1f)
|
||||
{
|
||||
internalValueMin = propVector.y;
|
||||
internalValueMax = propVector.x;
|
||||
}
|
||||
|
||||
EditorGUI.showMixedValue = false;
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
prop.vectorValue = propVector;
|
||||
internalPropMin.floatValue = internalValueMin;
|
||||
internalPropMax.floatValue = internalValueMax;
|
||||
}
|
||||
|
||||
GUILayout.Space(down);
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 364f1df7c922ba84fa6fc52fd3900332
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,60 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledSpaceDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public float space;
|
||||
public string conditions = "";
|
||||
|
||||
public StyledSpaceDrawer(float space)
|
||||
{
|
||||
this.space = space;
|
||||
}
|
||||
|
||||
public StyledSpaceDrawer(float space, string conditions)
|
||||
{
|
||||
this.space = space;
|
||||
this.conditions = conditions;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor materialEditor)
|
||||
{
|
||||
if (conditions == "")
|
||||
{
|
||||
GUILayout.Space(space);
|
||||
}
|
||||
else
|
||||
{
|
||||
Material material = materialEditor.target as Material;
|
||||
|
||||
bool showInspector = false;
|
||||
|
||||
string[] split = conditions.Split(char.Parse(" "));
|
||||
|
||||
for (int i = 0; i < split.Length; i++)
|
||||
{
|
||||
if (material.HasProperty(split[i]))
|
||||
{
|
||||
showInspector = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (showInspector)
|
||||
{
|
||||
GUILayout.Space(space);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f2f57e67392e5b41af1a4cecc3a6c04
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,97 @@
|
||||
// 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 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, float size)
|
||||
{
|
||||
this.text = text;
|
||||
this.alignment = alignment;
|
||||
this.font = font;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public StyledTextDrawer(string text, string alignment, string font, float size, float top, float down)
|
||||
{
|
||||
this.text = text;
|
||||
this.alignment = alignment;
|
||||
this.font = font;
|
||||
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.MiddleLeft;
|
||||
}
|
||||
else if (alignment == "Right")
|
||||
{
|
||||
styleLabel.alignment = TextAnchor.MiddleRight;
|
||||
}
|
||||
|
||||
if (font == "Normal")
|
||||
{
|
||||
styleLabel.fontStyle = FontStyle.Normal;
|
||||
}
|
||||
else if (font == "Bold")
|
||||
{
|
||||
styleLabel.fontStyle = FontStyle.Bold;
|
||||
}
|
||||
else if (font == "Italic")
|
||||
{
|
||||
styleLabel.fontStyle = FontStyle.Italic;
|
||||
}
|
||||
else if (font == "BoldAndItalic")
|
||||
{
|
||||
styleLabel.fontStyle = FontStyle.BoldAndItalic;
|
||||
}
|
||||
|
||||
styleLabel.fontSize = (int)size;
|
||||
|
||||
GUILayout.Label(text, styleLabel);
|
||||
|
||||
GUILayout.Space(down);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e137daebc2f7e0c4aa0ee5c5b140e8fd
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,70 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledTextureDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public float size;
|
||||
public float top;
|
||||
public float down;
|
||||
|
||||
public StyledTextureDrawer()
|
||||
{
|
||||
this.size = 50;
|
||||
this.top = 0;
|
||||
this.down = 0;
|
||||
}
|
||||
|
||||
public StyledTextureDrawer(float size)
|
||||
{
|
||||
this.size = size;
|
||||
this.top = 0;
|
||||
this.down = 0;
|
||||
}
|
||||
|
||||
public StyledTextureDrawer(float size, float top, float down)
|
||||
{
|
||||
this.size = size;
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor materialEditor)
|
||||
{
|
||||
GUILayout.Space(top);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUI.showMixedValue = prop.hasMixedValue;
|
||||
|
||||
Texture tex = null;
|
||||
|
||||
if (prop.textureDimension == UnityEngine.Rendering.TextureDimension.Tex2D)
|
||||
{
|
||||
tex = (Texture2D)EditorGUILayout.ObjectField(prop.displayName, prop.textureValue, typeof(Texture2D), false, GUILayout.Height(50));
|
||||
}
|
||||
|
||||
if (prop.textureDimension == UnityEngine.Rendering.TextureDimension.Cube)
|
||||
{
|
||||
tex = (Cubemap)EditorGUILayout.ObjectField(prop.displayName, prop.textureValue, typeof(Cubemap), false, GUILayout.Height(50));
|
||||
}
|
||||
|
||||
EditorGUI.showMixedValue = false;
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
prop.textureValue = tex;
|
||||
}
|
||||
|
||||
GUILayout.Space(down);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab83955dedb2aed428447d90cf62c81b
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledTextureSingleLineDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public float top;
|
||||
public float down;
|
||||
|
||||
public StyledTextureSingleLineDrawer()
|
||||
{
|
||||
this.top = 0;
|
||||
this.down = 0;
|
||||
}
|
||||
|
||||
public StyledTextureSingleLineDrawer(float top, float down)
|
||||
{
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor materialEditor)
|
||||
{
|
||||
GUILayout.Space(top);
|
||||
|
||||
materialEditor.TexturePropertySingleLine(new GUIContent(prop.displayName), prop);
|
||||
|
||||
GUILayout.Space(down);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 561b67406eee81948baf13ee752ae801
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,94 @@
|
||||
// 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;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUI.showMixedValue = prop.hasMixedValue;
|
||||
|
||||
if (width == 0)
|
||||
{
|
||||
bool toggle = false;
|
||||
|
||||
if (prop.floatValue > 0.5f)
|
||||
{
|
||||
toggle = true;
|
||||
}
|
||||
|
||||
toggle = EditorGUILayout.Toggle(label, toggle);
|
||||
|
||||
EditorGUI.showMixedValue = false;
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
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));
|
||||
|
||||
EditorGUI.showMixedValue = false;
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
if (toggle)
|
||||
{
|
||||
prop.floatValue = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
prop.floatValue = 0;
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5699c954b5c9184199293b4ede31d57
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledVectorDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public float space = 0;
|
||||
public float top = 0;
|
||||
public float down = 0;
|
||||
|
||||
public StyledVectorDrawer(float space)
|
||||
{
|
||||
this.space = space;
|
||||
}
|
||||
|
||||
public StyledVectorDrawer(float space, float top, float down)
|
||||
{
|
||||
this.space = space;
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
|
||||
{
|
||||
GUILayout.Space(top);
|
||||
|
||||
if (EditorGUIUtility.currentViewWidth > 344)
|
||||
{
|
||||
materialEditor.VectorProperty(prop, label);
|
||||
GUILayout.Space(-space);
|
||||
}
|
||||
else
|
||||
{
|
||||
materialEditor.VectorProperty(prop, label);
|
||||
GUILayout.Space(2);
|
||||
}
|
||||
|
||||
GUILayout.Space(down);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebb397dcd33e7cb48a6c3c5b9d928c05
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user