case3
This commit is contained in:
28
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledBannerDrawer.cs
vendored
Normal file
28
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledBannerDrawer.cs
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Boxophobic.Utility;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledBannerDrawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledBannerDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 864d8c89c5d2ef240b0c51f15c5211e2
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
71
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledButtonDrawer.cs
vendored
Normal file
71
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledButtonDrawer.cs
vendored
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledButtonDrawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledButtonDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b40d7a397aa055b46a1651ee9f9bdd03
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
183
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledCategoryDrawer.cs
vendored
Normal file
183
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledCategoryDrawer.cs
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledCategoryDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public bool isEnabled = true;
|
||||
public bool showDot = false;
|
||||
|
||||
public string category;
|
||||
public string colapsable;
|
||||
public string conditions = "";
|
||||
public string dotColor = "";
|
||||
public string infoText = "";
|
||||
public float top;
|
||||
public float down;
|
||||
|
||||
public StyledCategoryDrawer(string category)
|
||||
{
|
||||
this.category = category;
|
||||
this.colapsable = "false";
|
||||
this.conditions = "";
|
||||
this.dotColor = "";
|
||||
this.top = 10;
|
||||
this.down = 10;
|
||||
}
|
||||
|
||||
public StyledCategoryDrawer(string category, string colapsable)
|
||||
{
|
||||
this.category = category;
|
||||
this.colapsable = colapsable;
|
||||
this.conditions = "";
|
||||
this.dotColor = "";
|
||||
this.top = 10;
|
||||
this.down = 10;
|
||||
}
|
||||
|
||||
public StyledCategoryDrawer(string category, float top, float down)
|
||||
{
|
||||
this.category = category;
|
||||
this.colapsable = "false";
|
||||
this.conditions = "";
|
||||
this.dotColor = "";
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public StyledCategoryDrawer(string category, string colapsable, float top, float down)
|
||||
{
|
||||
this.category = category;
|
||||
this.colapsable = colapsable;
|
||||
this.conditions = "";
|
||||
this.dotColor = "";
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
public StyledCategoryDrawer(string category, string colapsable, string infoText, float top, float down)
|
||||
{
|
||||
this.category = category;
|
||||
this.colapsable = colapsable;
|
||||
this.conditions = "";
|
||||
this.dotColor = "";
|
||||
this.infoText = infoText;
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public StyledCategoryDrawer(string category, string colapsable, string conditions, string dotColor, float top, float down)
|
||||
{
|
||||
this.category = category;
|
||||
this.colapsable = colapsable;
|
||||
this.conditions = conditions;
|
||||
this.dotColor = dotColor;
|
||||
this.infoText = "";
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public StyledCategoryDrawer(string category, string colapsable, string conditions, string dotColor, string infoText, float top, float down)
|
||||
{
|
||||
this.category = category;
|
||||
this.colapsable = colapsable;
|
||||
this.conditions = conditions;
|
||||
this.dotColor = dotColor;
|
||||
this.infoText = infoText;
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
|
||||
{
|
||||
GUI.enabled = true;
|
||||
//GUI.color = Color.white;
|
||||
//GUI.contentColor = Color.white;
|
||||
EditorGUI.indentLevel = 0;
|
||||
|
||||
if (conditions != "")
|
||||
{
|
||||
showDot = false;
|
||||
|
||||
Material material = materialEditor.target as Material;
|
||||
|
||||
string[] split = conditions.Split(char.Parse(" "));
|
||||
|
||||
for (int i = 0; i < split.Length; i++)
|
||||
{
|
||||
var property = split[i];
|
||||
|
||||
if (material.HasProperty(property))
|
||||
{
|
||||
if (material.GetFloat(property) > 0)
|
||||
{
|
||||
showDot = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DrawInspector(prop);
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
isEnabled = true;
|
||||
}
|
||||
|
||||
if (showDot)
|
||||
{
|
||||
isEnabled = StyledGUI.DrawInspectorCategory(category, isEnabled, isColapsable, dotColor, infoText, top, down);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (infoText != "")
|
||||
{
|
||||
isEnabled = StyledGUI.DrawInspectorCategory(category, isEnabled, isColapsable, infoText, top, down);
|
||||
}
|
||||
else
|
||||
{
|
||||
isEnabled = StyledGUI.DrawInspectorCategory(category, isEnabled, isColapsable, top, down);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isEnabled)
|
||||
{
|
||||
prop.floatValue = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
prop.floatValue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledCategoryDrawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledCategoryDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b5715cd99e4a2e4c91d69653d31dad9
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
26
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledColoringDrawer.cs
vendored
Normal file
26
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledColoringDrawer.cs
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledColoringDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public StyledColoringDrawer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
|
||||
{
|
||||
GUI.contentColor = prop.colorValue;
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledColoringDrawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledColoringDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30afcd86dad75504ebd5516adf73ad08
|
||||
timeCreated: 1544039105
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
93
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledDiffusionMaterialDrawer.cs
vendored
Normal file
93
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledDiffusionMaterialDrawer.cs
vendored
Normal file
@@ -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,
|
||||
// };
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledDiffusionMaterialDrawer.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledDiffusionMaterialDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f13faeb510c3cb54ba5d051ecaad26e3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
122
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledEmissiveIntensityDrawer.cs
vendored
Normal file
122
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledEmissiveIntensityDrawer.cs
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledEmissiveIntensityDrawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledEmissiveIntensityDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1d76466e8080c147b2fa9e3b42e8850
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
92
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledEnumDrawer.cs
vendored
Normal file
92
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledEnumDrawer.cs
vendored
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledEnumDrawer.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledEnumDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5dbd5cf6c68f1d4ebd1369f8795ee3a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
111
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledHeaderDrawer.cs
vendored
Normal file
111
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledHeaderDrawer.cs
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledHeaderDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public bool isEnabled = true;
|
||||
|
||||
public string category;
|
||||
public string colapsable;
|
||||
public string infoText = "";
|
||||
public float top;
|
||||
public float down;
|
||||
|
||||
public StyledHeaderDrawer(string category)
|
||||
{
|
||||
this.category = category;
|
||||
this.colapsable = "false";
|
||||
this.top = 10;
|
||||
this.down = 10;
|
||||
}
|
||||
|
||||
public StyledHeaderDrawer(string category, string colapsable)
|
||||
{
|
||||
this.category = category;
|
||||
this.colapsable = colapsable;
|
||||
this.top = 10;
|
||||
this.down = 10;
|
||||
}
|
||||
|
||||
public StyledHeaderDrawer(string category, float top, float down)
|
||||
{
|
||||
this.category = category;
|
||||
this.colapsable = "false";
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public StyledHeaderDrawer(string category, string colapsable, float top, float down)
|
||||
{
|
||||
this.category = category;
|
||||
this.colapsable = colapsable;
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
public StyledHeaderDrawer(string category, string colapsable, string infoText, float top, float down)
|
||||
{
|
||||
this.category = category;
|
||||
this.colapsable = colapsable;
|
||||
this.infoText = infoText;
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
|
||||
{
|
||||
GUI.enabled = true;
|
||||
EditorGUI.indentLevel = 0;
|
||||
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
isEnabled = true;
|
||||
}
|
||||
|
||||
if (infoText != "")
|
||||
{
|
||||
isEnabled = StyledGUI.DrawInspectorHeader(category, isEnabled, isColapsable, infoText, top, down);
|
||||
}
|
||||
else
|
||||
{
|
||||
isEnabled = StyledGUI.DrawInspectorHeader(category, isEnabled, isColapsable, top, down);
|
||||
}
|
||||
|
||||
if (isEnabled)
|
||||
{
|
||||
prop.floatValue = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
prop.floatValue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledHeaderDrawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledHeaderDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61e9c4e504463ae49bb18338bbf4841d
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
30
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledIndentDrawer.cs
vendored
Normal file
30
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledIndentDrawer.cs
vendored
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledIndentDrawer.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledIndentDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae4fb3d8081065c47860724ea515c97c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledInteractiveDrawer.cs
vendored
Normal file
33
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledInteractiveDrawer.cs
vendored
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledInteractiveDrawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledInteractiveDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cc33d297d20daa40a9b09fbb8e59502
|
||||
timeCreated: 1544039105
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
390
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledKeywordDrawer.cs
vendored
Normal file
390
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledKeywordDrawer.cs
vendored
Normal file
@@ -0,0 +1,390 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledKeywordDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public string allParentOnStr = "false";
|
||||
public string parentsStr = "";
|
||||
public string propertiesStr = "";
|
||||
public string keywordsStr = "";
|
||||
|
||||
public StyledKeywordDrawer(string allParentOnStr, string propertiesStr, string keywordsStr)
|
||||
{
|
||||
this.allParentOnStr = allParentOnStr;
|
||||
this.propertiesStr = propertiesStr;
|
||||
this.keywordsStr = keywordsStr;
|
||||
}
|
||||
|
||||
public StyledKeywordDrawer(string allParentOnStr, string parentsStr, string propertiesStr, string keywordsStr)
|
||||
{
|
||||
this.allParentOnStr = allParentOnStr;
|
||||
this.propertiesStr = propertiesStr;
|
||||
this.keywordsStr = keywordsStr;
|
||||
this.parentsStr = parentsStr;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
|
||||
{
|
||||
Material material = materialEditor.target as Material;
|
||||
|
||||
var parents = parentsStr.Split(" ");
|
||||
var properties = propertiesStr.Split(" ");
|
||||
var keywords = keywordsStr.Split(" ");
|
||||
|
||||
var parentCount = parents.Length;
|
||||
var propertiesCount = properties.Length;
|
||||
var keywordsCount = keywords.Length;
|
||||
|
||||
bool allParentsOn = false;
|
||||
|
||||
if (allParentOnStr == "true")
|
||||
{
|
||||
allParentsOn = true;
|
||||
}
|
||||
|
||||
if (parentCount == 0)
|
||||
{
|
||||
if (propertiesCount == 0)
|
||||
{
|
||||
if (keywordsCount == 0)
|
||||
{
|
||||
SetMaterialKeyword(material, properties[0], keywords[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetMaterialKeyword(material, properties[0], keywords);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetMaterialKeyword(material, allParentsOn, properties, keywords[0]);
|
||||
}
|
||||
}
|
||||
else if (parentCount == 1)
|
||||
{
|
||||
if (propertiesCount == 0)
|
||||
{
|
||||
if (keywordsCount == 0)
|
||||
{
|
||||
SetMaterialKeyword(material, parents[0], properties[0], keywords[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetMaterialKeyword(material, parents[0], properties[0], keywords);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (propertiesCount == 0)
|
||||
{
|
||||
if (keywordsCount == 0)
|
||||
{
|
||||
SetMaterialKeyword(material, allParentsOn, parents, properties[0], keywords[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetMaterialKeyword(material, allParentsOn, parents, properties[0], keywords);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
void SetMaterialKeyword(Material material, string property, string keyword)
|
||||
{
|
||||
if (material.HasFloat(property))
|
||||
{
|
||||
var mode = material.GetFloat(property);
|
||||
|
||||
if (mode == 0)
|
||||
{
|
||||
material.DisableKeyword(keyword);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.EnableKeyword(keyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetMaterialKeyword(Material material, string property, string[] keywords)
|
||||
{
|
||||
if (material.HasFloat(property))
|
||||
{
|
||||
var mode = material.GetFloat(property);
|
||||
|
||||
for (int i = 0; i < keywords.Length; i++)
|
||||
{
|
||||
if (i == mode)
|
||||
{
|
||||
material.EnableKeyword(keywords[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword(keywords[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetMaterialKeyword(Material material, string parent, string property, string keyword)
|
||||
{
|
||||
if (material.HasFloat(parent) && material.HasFloat(property))
|
||||
{
|
||||
var parentMode = material.GetFloat(parent);
|
||||
|
||||
if (parentMode > 0)
|
||||
{
|
||||
var propertyMode = material.GetFloat(property);
|
||||
|
||||
if (propertyMode == 0)
|
||||
{
|
||||
material.DisableKeyword(keyword);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.EnableKeyword(keyword);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword(keyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetMaterialKeyword(Material material, string parent, string property, string[] keywords)
|
||||
{
|
||||
if (material.HasFloat(parent) && material.HasFloat(property))
|
||||
{
|
||||
var parentMode = material.GetFloat(parent);
|
||||
|
||||
if (parentMode > 0)
|
||||
{
|
||||
var propertyMode = material.GetFloat(property);
|
||||
|
||||
for (int i = 0; i < keywords.Length; i++)
|
||||
{
|
||||
if (i == propertyMode)
|
||||
{
|
||||
material.EnableKeyword(keywords[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword(keywords[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < keywords.Length; i++)
|
||||
{
|
||||
material.DisableKeyword(keywords[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetMaterialKeyword(Material material, bool allParentsOn, string[] parents, string property, string keyword)
|
||||
{
|
||||
bool parentMode = false;
|
||||
float propertyMode = 0;
|
||||
|
||||
if (allParentsOn)
|
||||
{
|
||||
int enableCount = 0;
|
||||
|
||||
for (int i = 0; i < parents.Length; i++)
|
||||
{
|
||||
var parent = parents[i];
|
||||
|
||||
if (material.HasProperty(parent))
|
||||
{
|
||||
if (material.GetFloat(parent) > 0)
|
||||
{
|
||||
enableCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (parents.Length == enableCount)
|
||||
{
|
||||
parentMode = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float enableFloat = 0;
|
||||
|
||||
for (int i = 0; i < parents.Length; i++)
|
||||
{
|
||||
var parent = parents[i];
|
||||
|
||||
if (material.HasProperty(parent))
|
||||
{
|
||||
enableFloat += material.GetFloat(parent);
|
||||
}
|
||||
}
|
||||
|
||||
if (enableFloat > 0)
|
||||
{
|
||||
parentMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (material.HasProperty(property))
|
||||
{
|
||||
propertyMode = material.GetFloat(property);
|
||||
}
|
||||
|
||||
if (parentMode && propertyMode > 0)
|
||||
{
|
||||
material.EnableKeyword(keyword);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword(keyword);
|
||||
}
|
||||
}
|
||||
|
||||
void SetMaterialKeyword(Material material, bool allParentsOn, string[] parents, string property, string[] keywords)
|
||||
{
|
||||
bool parentsMode = false;
|
||||
|
||||
if (allParentsOn)
|
||||
{
|
||||
int enableCount = 0;
|
||||
|
||||
for (int i = 0; i < parents.Length; i++)
|
||||
{
|
||||
var parent = parents[i];
|
||||
|
||||
if (material.HasProperty(parent))
|
||||
{
|
||||
if (material.GetFloat(parent) > 0)
|
||||
{
|
||||
enableCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (parents.Length == enableCount)
|
||||
{
|
||||
parentsMode = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float enableFloat = 0;
|
||||
|
||||
for (int i = 0; i < parents.Length; i++)
|
||||
{
|
||||
var parent = parents[i];
|
||||
|
||||
if (material.HasProperty(parent))
|
||||
{
|
||||
enableFloat += material.GetFloat(parent);
|
||||
}
|
||||
}
|
||||
|
||||
if (enableFloat > 0)
|
||||
{
|
||||
parentsMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (material.HasFloat(property))
|
||||
{
|
||||
if (parentsMode)
|
||||
{
|
||||
var propertyMode = material.GetInt(property);
|
||||
|
||||
for (int i = 0; i < keywords.Length; i++)
|
||||
{
|
||||
if (i == propertyMode)
|
||||
{
|
||||
material.EnableKeyword(keywords[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword(keywords[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < keywords.Length; i++)
|
||||
{
|
||||
material.DisableKeyword(keywords[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetMaterialKeyword(Material material, bool allParentsOn, string[] properties, string keyword)
|
||||
{
|
||||
bool parentMode = false;
|
||||
|
||||
if (allParentsOn)
|
||||
{
|
||||
int enableCount = 0;
|
||||
|
||||
for (int i = 0; i < properties.Length; i++)
|
||||
{
|
||||
var property = properties[i];
|
||||
|
||||
if (material.HasProperty(property))
|
||||
{
|
||||
if (material.GetFloat(property) > 0)
|
||||
{
|
||||
enableCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (properties.Length == enableCount)
|
||||
{
|
||||
parentMode = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float enableFloat = 0;
|
||||
|
||||
for (int i = 0; i < properties.Length; i++)
|
||||
{
|
||||
var property = properties[i];
|
||||
|
||||
if (material.HasProperty(property))
|
||||
{
|
||||
enableFloat += material.GetFloat(property);
|
||||
}
|
||||
}
|
||||
|
||||
if (enableFloat > 0)
|
||||
{
|
||||
parentMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (parentMode)
|
||||
{
|
||||
material.EnableKeyword(keyword);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword(keyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledKeywordDrawer.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledKeywordDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 057520665db88c444ae3d275cb0923d2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
75
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledKeywordInvertedDrawer.cs
vendored
Normal file
75
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledKeywordInvertedDrawer.cs
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledKeywordInvertedDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public string parentsStr = "";
|
||||
public string propertiesStr = "";
|
||||
public string keywordsStr = "";
|
||||
|
||||
public StyledKeywordInvertedDrawer(string propertiesStr, string keywordsStr)
|
||||
{
|
||||
this.propertiesStr = propertiesStr;
|
||||
this.keywordsStr = keywordsStr;
|
||||
}
|
||||
|
||||
public StyledKeywordInvertedDrawer(string parentsStr, string propertiesStr, string keywordsStr)
|
||||
{
|
||||
this.propertiesStr = propertiesStr;
|
||||
this.keywordsStr = keywordsStr;
|
||||
this.parentsStr = parentsStr;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
|
||||
{
|
||||
Material material = materialEditor.target as Material;
|
||||
|
||||
var parents = keywordsStr.Split(" ");
|
||||
var properties = propertiesStr.Split(" ");
|
||||
var keywords = keywordsStr.Split(" ");
|
||||
|
||||
var parentCount = parents.Length;
|
||||
var propertiesCount = properties.Length;
|
||||
var keywordsCount = keywords.Length;
|
||||
|
||||
if (parentCount == 0)
|
||||
{
|
||||
if (propertiesCount == 0)
|
||||
{
|
||||
if (keywordsCount == 0)
|
||||
{
|
||||
SetMaterialKeywordInverted(material, properties[0], keywords[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
void SetMaterialKeywordInverted(Material material, string property, string keyword)
|
||||
{
|
||||
if (material.HasFloat(property))
|
||||
{
|
||||
var mode = material.GetFloat(property);
|
||||
|
||||
if (mode == 0)
|
||||
{
|
||||
material.EnableKeyword(keyword);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.DisableKeyword(keyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledKeywordInvertedDrawer.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledKeywordInvertedDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dafdc63aa2865b04e924ffea07fde94e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
74
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledLayersDrawer.cs
vendored
Normal file
74
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledLayersDrawer.cs
vendored
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledLayersDrawer.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledLayersDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c837d89f6f4cd574595a810c5fcc15f8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
83
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledMaskDrawer.cs
vendored
Normal file
83
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledMaskDrawer.cs
vendored
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledMaskDrawer.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledMaskDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd2d7ee86763017438ae71ea6a9800f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
102
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledMessageDrawer.cs
vendored
Normal file
102
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledMessageDrawer.cs
vendored
Normal file
@@ -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 type, string message)
|
||||
{
|
||||
this.type = type;
|
||||
this.message = message;
|
||||
keyword = null;
|
||||
|
||||
this.top = 0;
|
||||
this.down = 0;
|
||||
}
|
||||
|
||||
public StyledMessageDrawer(string type, string message, float top, float down)
|
||||
{
|
||||
this.type = type;
|
||||
this.message = message;
|
||||
keyword = null;
|
||||
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public StyledMessageDrawer(string type, string message, string keyword, float value, float top, float down)
|
||||
{
|
||||
this.type = type;
|
||||
this.message = message;
|
||||
this.keyword = keyword;
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledMessageDrawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledMessageDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d01ce91280120de49b931b40f9e16f6b
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
187
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledOptionsSliderDrawer.cs
vendored
Normal file
187
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledOptionsSliderDrawer.cs
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledOptionsSliderDrawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledOptionsSliderDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d4bc1ff93a8a28e42954d7469249a7a0
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
171
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledRemapSliderDrawer.cs
vendored
Normal file
171
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledRemapSliderDrawer.cs
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
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;
|
||||
|
||||
float internalValueMin;
|
||||
float internalValueMax;
|
||||
|
||||
bool showAdvancedSettings = 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 StyledRemapSliderDrawer()
|
||||
{
|
||||
this.nameMin = null;
|
||||
this.nameMax = null;
|
||||
this.min = 0;
|
||||
this.max = 1;
|
||||
this.top = 0;
|
||||
this.down = 0;
|
||||
}
|
||||
|
||||
public StyledRemapSliderDrawer(float min, float max)
|
||||
{
|
||||
this.nameMin = null;
|
||||
this.nameMax = null;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.top = 0;
|
||||
this.down = 0;
|
||||
}
|
||||
|
||||
public StyledRemapSliderDrawer(float min, float max, float top, float down)
|
||||
{
|
||||
this.nameMin = null;
|
||||
this.nameMax = null;
|
||||
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);
|
||||
|
||||
var stylePopupMini = new GUIStyle(EditorStyles.popup)
|
||||
{
|
||||
fontSize = 9,
|
||||
};
|
||||
|
||||
var styleButton = new GUIStyle(EditorStyles.label)
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
Vector4 propVector = prop.vectorValue;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
if (propVector.w == 0)
|
||||
{
|
||||
internalValueMin = propVector.x;
|
||||
internalValueMax = propVector.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
internalValueMin = propVector.y;
|
||||
internalValueMax = propVector.x;
|
||||
}
|
||||
|
||||
GUILayout.Space(top);
|
||||
|
||||
EditorGUI.showMixedValue = prop.hasMixedValue;
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(label, styleButton, GUILayout.Width(EditorGUIUtility.labelWidth), GUILayout.Height(18)))
|
||||
{
|
||||
showAdvancedSettings = !showAdvancedSettings;
|
||||
}
|
||||
|
||||
EditorGUILayout.MinMaxSlider(ref internalValueMin, ref internalValueMax, min, max);
|
||||
|
||||
GUILayout.Space(2);
|
||||
|
||||
propVector.w = (float)EditorGUILayout.Popup((int)propVector.w, new string[] { "Remap", "Invert" }, stylePopupMini, GUILayout.Width(50));
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
if (showAdvancedSettings)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(-1);
|
||||
GUILayout.Label(" Remap Min", GUILayout.Width(EditorGUIUtility.labelWidth));
|
||||
internalValueMin = Mathf.Clamp(EditorGUILayout.Slider(internalValueMin, min, max), min, internalValueMax);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(-1);
|
||||
GUILayout.Label(" Remap Max", GUILayout.Width(EditorGUIUtility.labelWidth));
|
||||
internalValueMax = Mathf.Clamp(EditorGUILayout.Slider(internalValueMax, min, max), internalValueMin, max);
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
EditorGUI.showMixedValue = false;
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
if (propVector.w == 0)
|
||||
{
|
||||
propVector.x = internalValueMin;
|
||||
propVector.y = internalValueMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
propVector.y = internalValueMin;
|
||||
propVector.x = internalValueMax;
|
||||
}
|
||||
|
||||
propVector.z = 1 / (propVector.y - propVector.x);
|
||||
|
||||
prop.vectorValue = propVector;
|
||||
|
||||
if (internalPropMin.displayName != null && internalPropMax.displayName != null)
|
||||
{
|
||||
internalPropMin.floatValue = internalValueMin;
|
||||
internalPropMax.floatValue = internalValueMax;
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(down);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledRemapSliderDrawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledRemapSliderDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 364f1df7c922ba84fa6fc52fd3900332
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
60
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledSpaceDrawer.cs
vendored
Normal file
60
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledSpaceDrawer.cs
vendored
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledSpaceDrawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledSpaceDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f2f57e67392e5b41af1a4cecc3a6c04
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
97
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextDrawer.cs
vendored
Normal file
97
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextDrawer.cs
vendored
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextDrawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e137daebc2f7e0c4aa0ee5c5b140e8fd
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
87
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextureDrawer.cs
vendored
Normal file
87
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextureDrawer.cs
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
// 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 string tooltip = "";
|
||||
|
||||
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, string tooltip)
|
||||
{
|
||||
this.size = size;
|
||||
this.top = 0;
|
||||
this.down = 0;
|
||||
this.tooltip = tooltip;
|
||||
}
|
||||
|
||||
public StyledTextureDrawer(float size, float top, float down)
|
||||
{
|
||||
this.size = size;
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public StyledTextureDrawer(float size, string tooltip, float top, float down)
|
||||
{
|
||||
this.size = size;
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
this.tooltip = tooltip;
|
||||
}
|
||||
|
||||
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(new GUIContent(prop.displayName, tooltip), prop.textureValue, typeof(Texture2D), false, GUILayout.Height(50));
|
||||
}
|
||||
|
||||
if (prop.textureDimension == UnityEngine.Rendering.TextureDimension.Cube)
|
||||
{
|
||||
tex = (Cubemap)EditorGUILayout.ObjectField(new GUIContent(prop.displayName, tooltip), 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextureDrawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextureDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab83955dedb2aed428447d90cf62c81b
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
81
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextureSingleLineDrawer.cs
vendored
Normal file
81
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextureSingleLineDrawer.cs
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledTextureSingleLineDrawer : MaterialPropertyDrawer
|
||||
{
|
||||
public float top;
|
||||
public float down;
|
||||
public string tooltip;
|
||||
|
||||
int previewChannel = 0;
|
||||
Material previewMaterial;
|
||||
|
||||
bool showAdvancedSettings = false;
|
||||
|
||||
public StyledTextureSingleLineDrawer()
|
||||
{
|
||||
this.top = 0;
|
||||
this.down = 0;
|
||||
this.tooltip = "";
|
||||
}
|
||||
|
||||
public StyledTextureSingleLineDrawer(string tooltip)
|
||||
{
|
||||
this.top = 0;
|
||||
this.down = 0;
|
||||
this.tooltip = tooltip;
|
||||
}
|
||||
|
||||
public StyledTextureSingleLineDrawer(float top, float down)
|
||||
{
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
this.tooltip = "";
|
||||
}
|
||||
|
||||
public StyledTextureSingleLineDrawer(string tooltip, float top, float down)
|
||||
{
|
||||
this.top = top;
|
||||
this.down = down;
|
||||
this.tooltip = tooltip;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor materialEditor)
|
||||
{
|
||||
GUILayout.Space(top);
|
||||
|
||||
materialEditor.TexturePropertySingleLine(new GUIContent(prop.displayName, tooltip), prop);
|
||||
|
||||
if (prop.textureValue != null && prop.textureValue.dimension == UnityEngine.Rendering.TextureDimension.Tex2D)
|
||||
{
|
||||
var lastRect = GUILayoutUtility.GetLastRect();
|
||||
|
||||
if (GUI.Button(lastRect, "", GUIStyle.none))
|
||||
{
|
||||
showAdvancedSettings = !showAdvancedSettings;
|
||||
}
|
||||
|
||||
if (showAdvancedSettings)
|
||||
{
|
||||
if (previewMaterial == null)
|
||||
{
|
||||
previewMaterial = new Material(Shader.Find("Hidden/BOXOPHOBIC/Helpers/Channel Preview"));
|
||||
}
|
||||
|
||||
previewChannel = StyledGUI.DrawTexturePreview(prop.textureValue, previewMaterial, previewChannel);
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(down);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextureSingleLineDrawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledTextureSingleLineDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 561b67406eee81948baf13ee752ae801
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
94
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledToggleDrawer.cs
vendored
Normal file
94
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledToggleDrawer.cs
vendored
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledToggleDrawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledToggleDrawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5699c954b5c9184199293b4ede31d57
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
90
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledVector2Drawer.cs
vendored
Normal file
90
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledVector2Drawer.cs
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledVector2Drawer : MaterialPropertyDrawer
|
||||
{
|
||||
public float space = 0;
|
||||
public float top = 0;
|
||||
public float down = 0;
|
||||
|
||||
public StyledVector2Drawer()
|
||||
{
|
||||
this.space = 0;
|
||||
}
|
||||
|
||||
public StyledVector2Drawer(float space)
|
||||
{
|
||||
this.space = space;
|
||||
}
|
||||
|
||||
public StyledVector2Drawer(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 > 330)
|
||||
{
|
||||
DrawVectorProperty(prop, label);
|
||||
GUILayout.Space(-space);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawVectorPropertyNextLine(prop, label);
|
||||
GUILayout.Space(2);
|
||||
}
|
||||
|
||||
GUILayout.Space(down);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
void DrawVectorProperty(MaterialProperty prop, string label)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUI.showMixedValue = prop.hasMixedValue;
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(-1);
|
||||
GUILayout.Label(label, GUILayout.Width(EditorGUIUtility.labelWidth - 1));
|
||||
Vector4 vec = EditorGUILayout.Vector2Field("", prop.vectorValue);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
prop.vectorValue = vec;
|
||||
}
|
||||
}
|
||||
|
||||
void DrawVectorPropertyNextLine(MaterialProperty prop, string label)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUI.showMixedValue = prop.hasMixedValue;
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(-1);
|
||||
GUILayout.Label(label, GUILayout.Width(EditorGUIUtility.labelWidth));
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
Vector4 vec = EditorGUILayout.Vector2Field("", prop.vectorValue);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
prop.vectorValue = vec;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledVector2Drawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledVector2Drawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 856f0b63ea2072047bbd2aaa41d2c72e
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
90
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledVector3Drawer.cs
vendored
Normal file
90
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledVector3Drawer.cs
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledVector3Drawer : MaterialPropertyDrawer
|
||||
{
|
||||
public float space = 0;
|
||||
public float top = 0;
|
||||
public float down = 0;
|
||||
|
||||
public StyledVector3Drawer()
|
||||
{
|
||||
this.space = 0;
|
||||
}
|
||||
|
||||
public StyledVector3Drawer(float space)
|
||||
{
|
||||
this.space = space;
|
||||
}
|
||||
|
||||
public StyledVector3Drawer(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 > 330)
|
||||
{
|
||||
DrawVectorProperty(prop, label);
|
||||
GUILayout.Space(-space);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawVectorPropertyNextLine(prop, label);
|
||||
GUILayout.Space(2);
|
||||
}
|
||||
|
||||
GUILayout.Space(down);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
void DrawVectorProperty(MaterialProperty prop, string label)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUI.showMixedValue = prop.hasMixedValue;
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(-1);
|
||||
GUILayout.Label(label, GUILayout.Width(EditorGUIUtility.labelWidth - 1));
|
||||
Vector4 vec = EditorGUILayout.Vector3Field("", prop.vectorValue);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
prop.vectorValue = vec;
|
||||
}
|
||||
}
|
||||
|
||||
void DrawVectorPropertyNextLine(MaterialProperty prop, string label)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUI.showMixedValue = prop.hasMixedValue;
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(-1);
|
||||
GUILayout.Label(label, GUILayout.Width(EditorGUIUtility.labelWidth));
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
Vector4 vec = EditorGUILayout.Vector3Field("", prop.vectorValue);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
prop.vectorValue = vec;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledVector3Drawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledVector3Drawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21a212bac1cb81f449faa837b54c1fca
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
90
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledVector4Drawer.cs
vendored
Normal file
90
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledVector4Drawer.cs
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace Boxophobic.StyledGUI
|
||||
{
|
||||
public class StyledVector4Drawer : MaterialPropertyDrawer
|
||||
{
|
||||
public float space = 0;
|
||||
public float top = 0;
|
||||
public float down = 0;
|
||||
|
||||
public StyledVector4Drawer()
|
||||
{
|
||||
this.space = 0;
|
||||
}
|
||||
|
||||
public StyledVector4Drawer(float space)
|
||||
{
|
||||
this.space = space;
|
||||
}
|
||||
|
||||
public StyledVector4Drawer(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 > 330)
|
||||
{
|
||||
DrawVectorProperty(prop, label);
|
||||
GUILayout.Space(-space);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawVectorPropertyNextLine(prop, label);
|
||||
GUILayout.Space(2);
|
||||
}
|
||||
|
||||
GUILayout.Space(down);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
void DrawVectorProperty(MaterialProperty prop, string label)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUI.showMixedValue = prop.hasMixedValue;
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(-1);
|
||||
GUILayout.Label(label, GUILayout.Width(EditorGUIUtility.labelWidth - 1));
|
||||
Vector4 vec = EditorGUILayout.Vector4Field("", prop.vectorValue);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
prop.vectorValue = vec;
|
||||
}
|
||||
}
|
||||
|
||||
void DrawVectorPropertyNextLine(MaterialProperty prop, string label)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUI.showMixedValue = prop.hasMixedValue;
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(-1);
|
||||
GUILayout.Label(label, GUILayout.Width(EditorGUIUtility.labelWidth));
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
Vector4 vec = EditorGUILayout.Vector4Field("", prop.vectorValue);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
prop.vectorValue = vec;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledVector4Drawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledVector4Drawer.cs.meta
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf20e876ed7bf344281b4cf5baca6ca8
|
||||
timeCreated: 1542224092
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledVectorDrawer.cs
vendored
Normal file
50
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledVectorDrawer.cs
vendored
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledVectorDrawer.cs.meta
vendored
Normal file
12
Assets/ThirdParty/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledVectorDrawer.cs.meta
vendored
Normal file
@@ -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