studycase2

This commit is contained in:
2025-11-24 21:29:46 +08:00
parent 749719e862
commit 173fe7574b
608 changed files with 52537 additions and 39 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 17c61e81bc9b25442bdd16825f44add1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
{
"name": "Boxophobic.Utils.Editor",
"references": [
"GUID:825ad574da7360d4e8aea558f272972e"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": []
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 10f1dd4cfd6afb54da274d7d818bd8f6
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 932574ec8bf7a48448cb86e6841b1580
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,86 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
namespace Boxophobic.Constants
{
public static class Constant
{
public static Color CategoryColor
{
get
{
if (EditorGUIUtility.isProSkin)
{
return Constant.ColorDarkGray;
}
else
{
return Constant.ColorLightGray;
}
}
}
public static Color LineColor
{
get
{
if (EditorGUIUtility.isProSkin)
{
return new Color(0.15f, 0.15f, 0.15f, 1.0f);
}
else
{
return new Color(0.65f, 0.65f, 0.65f, 1.0f);
}
}
}
public static Color ColorDarkGray
{
get
{
return new Color(0.2f, 0.2f, 0.2f, 1.0f);
}
}
public static Color ColorLightGray
{
get
{
return new Color(0.82f, 0.82f, 0.82f, 1.0f);
}
}
public static GUIStyle TitleStyle
{
get
{
GUIStyle guiStyle = new GUIStyle("label")
{
richText = true,
alignment = TextAnchor.MiddleCenter
};
return guiStyle;
}
}
public static GUIStyle HeaderStyle
{
get
{
GUIStyle guiStyle = new GUIStyle("label")
{
richText = true,
fontStyle = FontStyle.Bold,
alignment = TextAnchor.MiddleLeft
};
return guiStyle;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e0cf8ff3bbc97374f88272f686fb80e5
timeCreated: 1541442079
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d02f240a6cbf4e649ad428220a062c3a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
using UnityEngine;
using UnityEditor;
namespace Boxophobic.Utility
{
[CustomEditor(typeof(Notebox))]
[CanEditMultipleObjects]
public class NoteBoxInspector : Editor
{
const int MIN_SIZE = 11;
const int MAX_SIZE = 25;
SerializedProperty size;
SerializedProperty color;
SerializedProperty text;
void OnEnable()
{
size = serializedObject.FindProperty("noteSize");
color = serializedObject.FindProperty("noteColor");
text = serializedObject.FindProperty("noteText");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
GUIStyle textStyle = new GUIStyle();
textStyle.normal.textColor = color.colorValue;
textStyle.fontSize = size.intValue;
textStyle.wordWrap = true;
GUILayout.BeginHorizontal();
GUILayout.Label("");
color.colorValue = EditorGUILayout.ColorField("", color.colorValue, GUILayout.Width(35));
GUILayout.EndHorizontal();
text.stringValue = EditorGUILayout.TextArea(text.stringValue, textStyle);
GUILayout.BeginHorizontal();
GUILayout.Label("");
size.intValue = Mathf.RoundToInt(GUILayout.HorizontalSlider(Mathf.RoundToInt(size.intValue), MIN_SIZE, MAX_SIZE, GUILayout.Width(35)));
GUILayout.EndHorizontal();
serializedObject.ApplyModifiedProperties();
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0e001eb24a06011408df25d4fcad5120
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2c2983420122f454d878948cbfa6b285
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,71 @@
// Cristian Pop - https://boxophobic.com/
using System.Globalization;
using UnityEditor;
namespace Boxophobic.Utility
{
public partial class SettingsUtils
{
public static string LoadSettingsData(string settingsPath, string defaultData)
{
var settings = AssetDatabase.LoadAssetAtPath<SettingsData>(settingsPath);
if (settings != null)
{
return settings.data;
}
else
{
return defaultData;
}
}
public static int LoadSettingsData(string settingsPath, int defaultData)
{
var settings = AssetDatabase.LoadAssetAtPath<SettingsData>(settingsPath);
if (settings != null)
{
int value;
if (int.TryParse(settings.data, out value))
{
return value;
}
else
{
return defaultData;
}
}
else
{
return defaultData;
}
}
public static float LoadSettingsData(string settingsPath, float defaultData)
{
var settings = AssetDatabase.LoadAssetAtPath<SettingsData>(settingsPath);
if (settings != null)
{
float value;
if (float.TryParse(settings.data, out value))
{
return float.Parse(settings.data, CultureInfo.InvariantCulture);
}
else
{
return defaultData;
}
}
else
{
return defaultData;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 90057ce590a8bd148ab59e018f35d9cb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,71 @@
// Cristian Pop - https://boxophobic.com/
using System.IO;
using UnityEditor;
using UnityEngine;
namespace Boxophobic.Utility
{
public partial class SettingsUtils
{
public static void SaveSettingsData(string settingsPath, string data)
{
CreateFileIfMissing(settingsPath);
var settings = AssetDatabase.LoadAssetAtPath<SettingsData>(settingsPath);
settings.data = data;
SaveFile(settingsPath);
}
public static void SaveSettingsData(string settingsPath, int data)
{
CreateFileIfMissing(settingsPath);
var settings = AssetDatabase.LoadAssetAtPath<SettingsData>(settingsPath);
settings.data = data.ToString();
SaveFile(settingsPath);
}
public static void SaveSettingsData(string settingsPath, float data)
{
CreateFileIfMissing(settingsPath);
var settings = AssetDatabase.LoadAssetAtPath<SettingsData>(settingsPath);
settings.data = data.ToString();
SaveFile(settingsPath);
}
private static void CreateFileIfMissing(string settingsPath)
{
if (File.Exists(settingsPath) == false)
{
var directory = Path.GetDirectoryName(settingsPath);
if (Directory.Exists(directory) == false)
{
Directory.CreateDirectory(directory);
AssetDatabase.Refresh();
}
AssetDatabase.CreateAsset(ScriptableObject.CreateInstance<SettingsData>(), settingsPath);
AssetDatabase.Refresh();
}
}
private static void SaveFile(string settingsPath)
{
var file = AssetDatabase.LoadAssetAtPath<SettingsData>(settingsPath);
EditorUtility.SetDirty(file);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7afe5a6ac49829c408df7e64761e822d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9881ed9cbc1fe56418afdd5f11ee4759
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,154 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
using Boxophobic.Constants;
namespace Boxophobic.StyledGUI
{
public partial class StyledGUI
{
public static void DrawInspectorBanner(Color color, string title)
{
GUILayout.Space(10);
var fullRect = GUILayoutUtility.GetRect(0, 0, 36, 0);
var fillRect = new Rect(0, fullRect.position.y, fullRect.xMax + 3, 36);
var lineRect = new Rect(0, fullRect.position.y, fullRect.xMax + 3, 1);
if (EditorGUIUtility.isProSkin)
{
color = new Color(color.r, color.g, color.b, 1f);
}
else
{
color = Constant.ColorLightGray;
}
EditorGUI.DrawRect(fillRect, color);
EditorGUI.DrawRect(lineRect, Constant.LineColor);
Color guiColor = Constant.ColorDarkGray;
GUI.Label(fullRect, "<size=16><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + ">" + title + "</color></size>", Constant.TitleStyle);
GUILayout.Space(10);
}
public static void DrawInspectorBanner(string title)
{
GUILayout.Space(10);
var fullRect = GUILayoutUtility.GetRect(0, 0, 36, 0);
var fillRect = new Rect(0, fullRect.position.y, fullRect.xMax + 3, 36);
var lineRect = new Rect(0, fullRect.position.y, fullRect.xMax + 3, 1);
Color color;
Color guiColor;
if (EditorGUIUtility.isProSkin)
{
color = Constant.ColorDarkGray;
guiColor = Constant.ColorLightGray;
}
else
{
color = Constant.ColorLightGray;
guiColor = Constant.ColorDarkGray;
}
EditorGUI.DrawRect(fillRect, color);
EditorGUI.DrawRect(lineRect, Constant.LineColor);
GUI.Label(fullRect, "<size=16><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + ">" + title + "</color></size>", Constant.TitleStyle);
GUILayout.Space(10);
}
public static void DrawInspectorBanner(Color color, string title, string subtitle)
{
GUIStyle titleStyle = new GUIStyle("label")
{
richText = true,
alignment = TextAnchor.MiddleCenter
};
GUIStyle subTitleStyle = new GUIStyle("label")
{
richText = true,
alignment = TextAnchor.MiddleRight
};
GUILayout.Space(10);
var fullRect = GUILayoutUtility.GetRect(0, 0, 36, 0);
var fillRect = new Rect(0, fullRect.position.y, fullRect.xMax + 3, 36);
var subRect = new Rect(0, fullRect.position.y, fullRect.xMax - 5, 36);
var lineRect = new Rect(0, fullRect.position.y, fullRect.xMax + 3, 1);
if (EditorGUIUtility.isProSkin)
{
color = new Color(color.r, color.g, color.b, 1f);
}
else
{
color = Constant.ColorLightGray;
}
EditorGUI.DrawRect(fillRect, color);
EditorGUI.DrawRect(lineRect, Constant.LineColor);
Color guiColor = Constant.ColorDarkGray;
GUI.Label(fullRect, "<size=16><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + ">" + title + "</color></size>", titleStyle);
GUI.Label(subRect, "<b><size=11><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + ">" + subtitle + "</color></size></b>", subTitleStyle);
GUILayout.Space(10);
}
public static void DrawInspectorBanner(string title, string subtitle)
{
GUIStyle titleStyle = new GUIStyle("label")
{
richText = true,
alignment = TextAnchor.MiddleCenter
};
GUIStyle subTitleStyle = new GUIStyle("label")
{
richText = true,
alignment = TextAnchor.MiddleRight
};
GUILayout.Space(10);
var fullRect = GUILayoutUtility.GetRect(0, 0, 36, 0);
var fillRect = new Rect(0, fullRect.position.y, fullRect.xMax + 3, 36);
var subRect = new Rect(0, fullRect.position.y, fullRect.xMax - 5, 36);
var lineRect = new Rect(0, fullRect.position.y, fullRect.xMax + 3, 1);
Color color;
Color guiColor;
if (EditorGUIUtility.isProSkin)
{
color = Constant.ColorDarkGray;
guiColor = Constant.ColorLightGray;
}
else
{
color = Constant.ColorLightGray;
guiColor = Constant.ColorDarkGray;
}
EditorGUI.DrawRect(fillRect, color);
EditorGUI.DrawRect(lineRect, Constant.LineColor);
GUI.Label(fullRect, "<size=16><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + ">" + title + "</color></size>", titleStyle);
GUI.Label(subRect, "<b><size=11><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + ">" + subtitle + "</color></size></b>", subTitleStyle);
GUILayout.Space(10);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1525d4228f26951498e86e425363f3f0
timeCreated: 1542661236
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,274 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
using Boxophobic.Constants;
namespace Boxophobic.StyledGUI
{
public partial class StyledGUI
{
public static void DrawInspectorCategory(string bannerText)
{
GUI.contentColor = Color.white;
GUI.color = new Color(1, 1, 1, 0.9f);
var fullRect = GUILayoutUtility.GetRect(0, 0, 18, 0);
var fillRect = new Rect(0, fullRect.y, fullRect.xMax + 10, 18);
var lineRect = new Rect(0, fullRect.y, fullRect.xMax + 10, 1);
var titleRect = new Rect(fullRect.position.x - 1, fullRect.position.y, fullRect.width, 18);
EditorGUI.DrawRect(fillRect, Constant.CategoryColor);
EditorGUI.DrawRect(lineRect, Constant.LineColor);
bannerText = ShowBannerText(bannerText);
GUI.Label(titleRect, bannerText, Constant.HeaderStyle);
GUI.color = Color.white;
}
public static bool DrawInspectorCategory(string bannerText, bool enabled, bool colapsable, float top, float down)
{
GUI.contentColor = Color.white;
GUI.color = new Color(1, 1, 1, 0.9f);
if (colapsable)
{
if (enabled)
{
GUILayout.Space(top);
}
else
{
GUILayout.Space(0);
}
}
else
{
GUILayout.Space(top);
}
var fullRect = GUILayoutUtility.GetRect(0, 0, 18, 0);
var fillRect = new Rect(0, fullRect.y, fullRect.xMax + 10, 18);
var lineRect = new Rect(0, fullRect.y - 1, fullRect.xMax + 10, 1);
var titleRect = new Rect(fullRect.position.x - 1, fullRect.position.y, fullRect.width, 18);
var arrowRect = new Rect(fullRect.position.x - 15, fullRect.position.y - 1, fullRect.width, 18);
if (colapsable)
{
if (GUI.Button(arrowRect, "", GUIStyle.none))
{
enabled = !enabled;
}
}
else
{
enabled = true;
}
EditorGUI.DrawRect(fillRect, Constant.CategoryColor);
EditorGUI.DrawRect(lineRect, Constant.LineColor);
bannerText = ShowBannerText(bannerText);
GUI.Label(titleRect, bannerText, Constant.HeaderStyle);
GUI.color = new Color(1, 1, 1, 0.39f);
if (colapsable)
{
if (enabled)
{
GUI.Label(arrowRect, "<size=10>▼</size>", Constant.HeaderStyle);
GUILayout.Space(down);
}
else
{
GUI.Label(arrowRect, "<size=10>►</size>", Constant.HeaderStyle);
GUILayout.Space(0);
}
}
else
{
GUILayout.Space(down);
}
GUI.color = Color.white;
return enabled;
}
public static bool DrawInspectorCategory(string bannerText, bool enabled, bool colapsable, string infoText, float top, float down)
{
GUI.contentColor = Color.white;
GUI.color = new Color(1, 1, 1, 0.9f);
if (colapsable)
{
if (enabled)
{
GUILayout.Space(top);
}
else
{
GUILayout.Space(0);
}
}
else
{
GUILayout.Space(top);
}
var fullRect = GUILayoutUtility.GetRect(0, 0, 18, 0);
var fillRect = new Rect(0, fullRect.y, fullRect.xMax + 10, 18);
var lineRect = new Rect(0, fullRect.y - 1, fullRect.xMax + 10, 1);
var titleRect = new Rect(fullRect.position.x - 1, fullRect.position.y, fullRect.width, 18);
var arrowRect = new Rect(fullRect.position.x - 15, fullRect.position.y - 1, fullRect.width, 18);
if (colapsable)
{
if (GUI.Button(arrowRect, "", GUIStyle.none))
{
enabled = !enabled;
}
}
else
{
enabled = true;
}
EditorGUI.DrawRect(fillRect, Constant.CategoryColor);
EditorGUI.DrawRect(lineRect, Constant.LineColor);
bannerText = ShowBannerText(bannerText);
var bannerContext = new GUIContent(bannerText, infoText);
GUI.Label(titleRect, bannerContext, Constant.HeaderStyle);
GUI.color = new Color(1, 1, 1, 0.39f);
if (colapsable)
{
if (enabled)
{
GUI.Label(arrowRect, "<size=10>▼</size>", Constant.HeaderStyle);
GUILayout.Space(down);
}
else
{
GUI.Label(arrowRect, "<size=10>►</size>", Constant.HeaderStyle);
GUILayout.Space(0);
}
}
else
{
GUILayout.Space(down);
}
GUI.color = Color.white;
return enabled;
}
public static bool DrawInspectorCategory(string bannerText, bool enabled, bool colapsable, string dotColor, string infoText, float top, float down)
{
GUI.contentColor = Color.white;
GUI.color = new Color(1, 1, 1, 0.9f);
if (colapsable)
{
if (enabled)
{
GUILayout.Space(top);
}
else
{
GUILayout.Space(0);
}
}
else
{
GUILayout.Space(top);
}
var fullRect = GUILayoutUtility.GetRect(0, 0, 18, 0);
var fillRect = new Rect(0, fullRect.y, fullRect.xMax + 10, 18);
var lineRect = new Rect(0, fullRect.y - 1, fullRect.xMax + 10, 1);
var titleRect = new Rect(fullRect.position.x - 1, fullRect.position.y, fullRect.width, 18);
var arrowRect = new Rect(fullRect.position.x - 15, fullRect.position.y - 1, fullRect.width, 18);
var dotRect = new Rect(fullRect.xMax - 18, fullRect.y - 1, 18, 18);
if (colapsable)
{
if (GUI.Button(arrowRect, "", GUIStyle.none))
{
enabled = !enabled;
}
}
else
{
enabled = true;
}
EditorGUI.DrawRect(fillRect, Constant.CategoryColor);
EditorGUI.DrawRect(lineRect, Constant.LineColor);
bannerText = ShowBannerText(bannerText);
var bannerContext = new GUIContent(bannerText, infoText);
GUI.Label(titleRect, bannerContext, Constant.HeaderStyle);
GUI.color = new Color(1, 1, 1, 0.39f);
if (colapsable)
{
if (enabled)
{
GUI.Label(arrowRect, "<size=10>▼</size>", Constant.HeaderStyle);
GUILayout.Space(down);
}
else
{
GUI.Label(arrowRect, "<size=10>►</size>", Constant.HeaderStyle);
GUILayout.Space(0);
}
}
else
{
GUILayout.Space(down);
}
GUI.color = Color.white;
if (dotColor != "NONE")
{
string subtitle;
if (EditorGUIUtility.isProSkin)
{
subtitle = "<color=#" + dotColor + ">●</color>";
}
else
{
subtitle = "●";
}
GUI.Label(dotRect, "<size=9>" + subtitle + "</size>", Constant.TitleStyle);
}
return enabled;
}
static string ShowBannerText(string bannerText)
{
if (bannerText.Contains("_"))
{
var splitBanner = bannerText.Split("_");
bannerText = splitBanner[0] + " (" + splitBanner[1] + ")";
}
return bannerText;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 87b94a9c1333f074e8c24cd5a2fe1d73
timeCreated: 1542661236
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,169 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using Boxophobic.Constants;
namespace Boxophobic.StyledGUI
{
public partial class StyledGUI
{
public static void DrawInspectorHeader(string bannerText)
{
GUI.contentColor = Color.white;
GUI.color = new Color(1, 1, 1, 0.9f);
var fullRect = GUILayoutUtility.GetRect(0, 0, 18, 0);
var titleRect = new Rect(fullRect.position.x - 1, fullRect.position.y, fullRect.width, 18);
bannerText = DrawHeaderText(bannerText);
GUI.Label(titleRect, bannerText, Constant.HeaderStyle);
GUI.color = Color.white;
}
public static bool DrawInspectorHeader(string bannerText, bool enabled, bool colapsable, float top, float down)
{
GUI.contentColor = Color.white;
GUI.color = new Color(1, 1, 1, 0.9f);
if (colapsable)
{
if (enabled)
{
GUILayout.Space(top);
}
else
{
GUILayout.Space(0);
}
}
else
{
GUILayout.Space(top);
}
var fullRect = GUILayoutUtility.GetRect(0, 0, 18, 0);
var titleRect = new Rect(fullRect.position.x - 1, fullRect.position.y, fullRect.width, 18);
var arrowRect = new Rect(fullRect.position.x - 15, fullRect.position.y - 1, fullRect.width, 18);
if (colapsable)
{
if (GUI.Button(arrowRect, "", GUIStyle.none))
{
enabled = !enabled;
}
}
else
{
enabled = true;
}
bannerText = DrawHeaderText(bannerText);
GUI.Label(titleRect, bannerText, Constant.HeaderStyle);
GUI.color = new Color(1, 1, 1, 0.39f);
if (colapsable)
{
if (enabled)
{
GUI.Label(arrowRect, "<size=10>▼</size>", Constant.HeaderStyle);
GUILayout.Space(down);
}
else
{
GUI.Label(arrowRect, "<size=10>►</size>", Constant.HeaderStyle);
GUILayout.Space(0);
}
}
else
{
GUILayout.Space(down);
}
GUI.color = Color.white;
return enabled;
}
public static bool DrawInspectorHeader(string bannerText, bool enabled, bool colapsable, string infoText, float top, float down)
{
GUI.contentColor = Color.white;
GUI.color = new Color(1, 1, 1, 0.9f);
if (colapsable)
{
if (enabled)
{
GUILayout.Space(top);
}
else
{
GUILayout.Space(0);
}
}
else
{
GUILayout.Space(top);
}
var fullRect = GUILayoutUtility.GetRect(0, 0, 18, 0);
var titleRect = new Rect(fullRect.position.x - 1, fullRect.position.y, fullRect.width, 18);
var arrowRect = new Rect(fullRect.position.x - 15, fullRect.position.y - 1, fullRect.width, 18);
if (colapsable)
{
if (GUI.Button(arrowRect, "", GUIStyle.none))
{
enabled = !enabled;
}
}
else
{
enabled = true;
}
bannerText = DrawHeaderText(bannerText);
var bannerContext = new GUIContent(bannerText, infoText);
GUI.Label(titleRect, bannerContext, Constant.HeaderStyle);
GUI.color = new Color(1, 1, 1, 0.39f);
if (colapsable)
{
if (enabled)
{
GUI.Label(arrowRect, "<size=10>▼</size>", Constant.HeaderStyle);
GUILayout.Space(down);
}
else
{
GUI.Label(arrowRect, "<size=10>►</size>", Constant.HeaderStyle);
GUILayout.Space(0);
}
}
else
{
GUILayout.Space(down);
}
GUI.color = Color.white;
return enabled;
}
static string DrawHeaderText(string bannerText)
{
if (bannerText.Contains("_"))
{
var splitBanner = bannerText.Split("_");
bannerText = splitBanner[0] + " (" + splitBanner[1] + ")";
}
return bannerText;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bef1390ad3d0330479ab886ebf22bce5
timeCreated: 1542661236
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,80 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
using UnityEngine.Rendering;
namespace Boxophobic.StyledGUI
{
public partial class StyledGUI
{
public static int DrawTexturePreview(Texture texture, Material previewMaterial, int previewChannel)
{
GUILayout.Space(10);
var styledText = new GUIStyle(EditorStyles.toolbarButton)
{
alignment = TextAnchor.MiddleCenter,
fontStyle = FontStyle.Normal,
fontSize = 10,
};
var styledPopup = new GUIStyle(EditorStyles.toolbarPopup)
{
alignment = TextAnchor.MiddleCenter,
fontSize = 10,
};
previewMaterial.SetTexture("_PreviewTex", texture);
previewMaterial.SetInt("_PreviewChannel", previewChannel);
#if UNITY_2022_3_OR_NEWER
if (texture.isDataSRGB)
{
previewMaterial.SetInt("_PreviewLinear", 0);
}
else
{
previewMaterial.SetInt("_PreviewLinear", 1);
}
#endif
var rect = GUILayoutUtility.GetRect(0, 0, Screen.width, 0);
EditorGUI.DrawPreviewTexture(rect, texture, previewMaterial, ScaleMode.ScaleAndCrop, 1, 0);
GUILayout.Space(2);
GUILayout.BeginHorizontal();
GUILayout.Label((UnityEngine.Profiling.Profiler.GetRuntimeMemorySizeLong(texture) / 1024f / 1024f).ToString("F2") + " mb", styledText);
GUILayout.Space(-1);
GUILayout.Label(texture.width.ToString() + " px", styledText);
GUILayout.Space(-1);
GUILayout.Label(texture.graphicsFormat.ToString(), styledText);
GUILayout.Space(-1);
#if UNITY_2022_3_OR_NEWER
if (texture.isDataSRGB)
{
GUILayout.Label("sRGB", styledText);
}
else
{
GUILayout.Label("Linear", styledText);
}
#endif
GUILayout.Space(-1);
previewChannel = EditorGUILayout.Popup(previewChannel, new string[] { "RGB", "R", "G", "B", "A", "Split" }, styledPopup, GUILayout.MaxWidth(60));
GUILayout.EndHorizontal();
GUILayout.Space(10);
return previewChannel;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3f10ca89b5b74e04d97daa49dad86981
timeCreated: 1542661236
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,151 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
using Boxophobic.Constants;
namespace Boxophobic.StyledGUI
{
public partial class StyledGUI
{
public static void DrawWindowBanner(Color color, string title)
{
GUILayout.Space(15);
var fullRect = GUILayoutUtility.GetRect(0, 0, 36, 0);
var fillRect = new Rect(0, fullRect.y, fullRect.xMax + 10, 36);
var lineRect = new Rect(0, fullRect.y, fullRect.xMax + 10, 1);
if (EditorGUIUtility.isProSkin)
{
color = new Color(color.r, color.g, color.b, 1f);
}
else
{
color = Constant.ColorLightGray;
}
EditorGUI.DrawRect(fillRect, color);
EditorGUI.DrawRect(lineRect, Constant.LineColor);
Color guiColor = Constant.ColorDarkGray;
GUI.Label(fullRect, "<size=16><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + ">" + title + "</color></size>", Constant.TitleStyle);
GUILayout.Space(15);
}
public static void DrawWindowBanner(string title)
{
GUILayout.Space(15);
var fullRect = GUILayoutUtility.GetRect(0, 0, 36, 0);
var fillRect = new Rect(0, fullRect.y, fullRect.xMax + 10, 36);
var lineRect = new Rect(0, fullRect.y, fullRect.xMax + 10, 1);
Color color;
Color guiColor;
if (EditorGUIUtility.isProSkin)
{
color = Constant.ColorDarkGray;
guiColor = Constant.ColorLightGray;
}
else
{
color = Constant.ColorLightGray;
guiColor = Constant.ColorDarkGray;
}
EditorGUI.DrawRect(fillRect, color);
EditorGUI.DrawRect(lineRect, Constant.LineColor);
GUI.Label(fullRect, "<size=16><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + ">" + title + "</color></size>", Constant.TitleStyle);
GUILayout.Space(15);
}
public static void DrawWindowBanner(Color color, string title, string subtitle)
{
GUIStyle titleStyle = new GUIStyle("label")
{
richText = true,
alignment = TextAnchor.MiddleCenter
};
GUIStyle subTitleStyle = new GUIStyle("label")
{
richText = true,
alignment = TextAnchor.MiddleRight
};
GUILayout.Space(15);
var fullRect = GUILayoutUtility.GetRect(0, 0, 36, 0);
var fillRect = new Rect(0, fullRect.y, fullRect.xMax + 10, 36);
var subRect = new Rect(0, fullRect.y, fullRect.xMax - 14, 36);
var lineRect = new Rect(0, fullRect.y, fullRect.xMax + 10, 1);
if (EditorGUIUtility.isProSkin)
{
color = new Color(color.r, color.g, color.b, 1f);
}
else
{
color = Constant.ColorLightGray;
}
EditorGUI.DrawRect(fillRect, color);
EditorGUI.DrawRect(lineRect, Constant.LineColor);
Color guiColor = Constant.ColorDarkGray;
GUI.Label(fullRect, "<size=16><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + ">" + title + "</color></size>", titleStyle);
GUI.Label(subRect, "<b><size=11><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + ">" + subtitle + "</color></size></b>", subTitleStyle);
GUILayout.Space(15);
}
public static void DrawWindowBanner(string title, string subtitle)
{
GUIStyle titleStyle = new GUIStyle("label")
{
richText = true,
alignment = TextAnchor.MiddleCenter
};
GUIStyle subTitleStyle = new GUIStyle("label")
{
richText = true,
alignment = TextAnchor.MiddleRight
};
GUILayout.Space(15);
var fullRect = GUILayoutUtility.GetRect(0, 0, 36, 0);
var subRect = new Rect(0, fullRect.y, fullRect.xMax - 18, 36);
var fillRect = new Rect(0, fullRect.y, fullRect.xMax + 10, 36);
Color color;
Color guiColor;
if (EditorGUIUtility.isProSkin)
{
color = Constant.ColorDarkGray;
guiColor = Constant.ColorLightGray;
}
else
{
color = Constant.ColorLightGray;
guiColor = Constant.ColorDarkGray;
}
EditorGUI.DrawRect(fillRect, color);
GUI.Label(fullRect, "<size=16><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + ">" + title + "</color></size>", titleStyle);
GUI.Label(subRect, "<b><size=11><color=#" + ColorUtility.ToHtmlStringRGB(guiColor) + ">" + subtitle + "</color></size></b>", subTitleStyle);
GUILayout.Space(15);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dd0ddca94871d9a4586a143a83184806
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,97 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
using Boxophobic.Constants;
namespace Boxophobic.StyledGUI
{
public partial class StyledGUI
{
public static void DrawWindowCategory(string bannerText)
{
GUI.color = new Color(1, 1, 1, 0.9f);
var fullRect = GUILayoutUtility.GetRect(0, 0, 18, 0);
var fillRect = new Rect(0, fullRect.y, fullRect.xMax + 10, 18);
var lineRect = new Rect(0, fullRect.y, fullRect.xMax + 10, 1);
var titleRect = new Rect(fullRect.position.x + 4, fullRect.position.y, fullRect.width, 18);
EditorGUI.DrawRect(fillRect, Constant.CategoryColor);
EditorGUI.DrawRect(lineRect, Constant.LineColor);
GUI.Label(titleRect, bannerText, Constant.HeaderStyle);
GUI.color = Color.white;
}
public static bool DrawWindowCategory(string bannerText, bool enabled, float top, float down, bool colapsable)
{
GUI.color = new Color(1, 1, 1, 0.9f);
if (colapsable)
{
if (enabled)
{
GUILayout.Space(top);
}
else
{
GUILayout.Space(0);
}
}
else
{
GUILayout.Space(top);
}
var fullRect = GUILayoutUtility.GetRect(0, 0, 18, 0);
var fillRect = new Rect(0, fullRect.y, fullRect.xMax + 10, 18);
var lineRect = new Rect(0, fullRect.y, fullRect.xMax + 10, 1);
var titleRect = new Rect(fullRect.position.x + 4, fullRect.position.y, fullRect.width, 18);
if (EditorGUIUtility.isProSkin)
{
GUI.color = Constant.ColorDarkGray;
}
else
{
GUI.color = Constant.ColorLightGray;
}
if (colapsable)
{
if (GUI.Button(fullRect, "", GUIStyle.none))
{
enabled = !enabled;
}
}
EditorGUI.DrawRect(fillRect, Constant.CategoryColor);
EditorGUI.DrawRect(lineRect, Constant.LineColor);
GUI.Label(titleRect, bannerText, Constant.HeaderStyle);
if (colapsable)
{
if (enabled)
{
GUILayout.Space(down);
}
else
{
GUILayout.Space(0);
}
}
else
{
GUILayout.Space(down);
}
GUI.color = Color.white;
return enabled;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: aac99d6d81f90e54cabd822770c11875
timeCreated: 1542661236
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9ddca4237e956f84d979d850f79720e4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,34 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
namespace Boxophobic.StyledGUI
{
[CustomPropertyDrawer(typeof(StyledBanner))]
public class StyledBannerAttributeDrawer : PropertyDrawer
{
StyledBanner a;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
a = (StyledBanner)attribute;
var bannerColor = new Color(a.colorR, a.colorG, a.colorB);
if (a.colorR < 0)
{
StyledGUI.DrawInspectorBanner(a.title);
}
else
{
StyledGUI.DrawInspectorBanner(bannerColor, a.title);
}
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return -2;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a832b9f47ccef214e81c89efe6bf31dd
timeCreated: 1544998323
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
namespace Boxophobic.StyledGUI
{
[CustomPropertyDrawer(typeof(StyledButton))]
public class StyledButtonAttributeDrawer : PropertyDrawer
{
StyledButton a;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
a = (StyledButton)attribute;
GUILayout.Space(a.top);
if (GUILayout.Button(a.text))
{
property.boolValue = true;
}
GUILayout.Space(a.down);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return -2;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b1d35dbbb9b6c214aa892d7b240de3df
timeCreated: 1544998323
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
namespace Boxophobic.StyledGUI
{
[CustomPropertyDrawer(typeof(StyledCategory))]
public class StyledCategoryAttributeDrawer : PropertyDrawer
{
StyledCategory a;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
a = (StyledCategory)attribute;
property.boolValue = StyledGUI.DrawInspectorCategory(a.category, property.boolValue, a.colapsable, a.top, a.down);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return -2;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: fb59d41716ab6114cb7cf03a5695083b
timeCreated: 1544998323
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,29 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
namespace Boxophobic.StyledGUI
{
[CustomPropertyDrawer(typeof(StyledDisplay))]
public class StyledDisplayAttributeDrawer : PropertyDrawer
{
StyledDisplay a;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
a = (StyledDisplay)attribute;
// Override the default label
label.text = a.displayName;
EditorGUI.PropertyField(position, property, label, true);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, label, true);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9be3bcc691857cb488c5b42b2b83f840
timeCreated: 1544998323
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,86 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Collections.Generic;
namespace Boxophobic.StyledGUI
{
[CustomPropertyDrawer(typeof(StyledEnum))]
public class StyledEnumAttributeDrawer : PropertyDrawer
{
StyledEnum a;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
a = (StyledEnum)attribute;
GUIStyle styleLabel = new GUIStyle(EditorStyles.label)
{
richText = true,
alignment = TextAnchor.MiddleCenter,
wordWrap = true
};
if (Resources.Load<TextAsset>(a.file) != null)
{
var layersPath = AssetDatabase.GetAssetPath(Resources.Load<TextAsset>(a.file));
StreamReader reader = new StreamReader(layersPath);
a.options = reader.ReadLine();
reader.Close();
}
string[] enumSplit = a.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(a.top);
int index = property.intValue;
int realIndex = enumIndices[0];
for (int i = 0; i < enumIndices.Count; i++)
{
if (enumIndices[i] == index)
{
realIndex = i;
}
}
if (a.display == "")
{
a.display = property.displayName;
}
realIndex = EditorGUILayout.Popup(a.display, realIndex, enumOptions.ToArray());
//Debug Value
//EditorGUILayout.LabelField(enumIndices[realIndex].ToString());
property.intValue = enumIndices[realIndex];
GUILayout.Space(a.down);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return -2;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 7c3935e6d6b91844d8053d3fa7faff1b
timeCreated: 1544998323
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
namespace Boxophobic.StyledGUI
{
[CustomPropertyDrawer(typeof(StyledIndent))]
public class StyledIndentAttributeDrawer : PropertyDrawer
{
StyledIndent a;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
a = (StyledIndent)attribute;
EditorGUI.indentLevel = a.indent;
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return -2;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ea3f7407f69f900468d4b60de570e49d
timeCreated: 1544998323
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,28 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
namespace Boxophobic.StyledGUI
{
[CustomPropertyDrawer(typeof(StyledInteractive))]
public class StyledInteractiveAttributeDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
if (property.boolValue == true)
{
GUI.enabled = true;
}
else
{
GUI.enabled = false;
}
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return -2;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 80229de18cd73624b8181a9db49a304f
timeCreated: 1544998323
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
namespace Boxophobic.StyledGUI
{
[CustomPropertyDrawer(typeof(StyledLayers))]
public class StyledLayersAttributeDrawer : PropertyDrawer
{
StyledLayers a;
private int index;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
a = (StyledLayers)attribute;
index = property.intValue;
string[] allLayers = new string[32];
for (int i = 0; i < 32; i++)
{
if (LayerMask.LayerToName(i).Length < 1)
{
allLayers[i] = "Missing";
}
else
{
allLayers[i] = LayerMask.LayerToName(i);
}
}
if (a.display == "")
{
a.display = property.displayName;
}
index = EditorGUILayout.Popup(a.display, index, allLayers);
property.intValue = index;
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return -2;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b351b243374f2d948a9e9943abe174bf
timeCreated: 1544998323
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,77 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Collections.Generic;
namespace Boxophobic.StyledGUI
{
[CustomPropertyDrawer(typeof(StyledMask))]
public class StyledMaskAttributeDrawer : PropertyDrawer
{
StyledMask a;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
a = (StyledMask)attribute;
GUIStyle styleLabel = new GUIStyle(EditorStyles.label)
{
richText = true,
alignment = TextAnchor.MiddleCenter,
wordWrap = true
};
if (Resources.Load<TextAsset>(a.file) != null)
{
var layersPath = AssetDatabase.GetAssetPath(Resources.Load<TextAsset>(a.file));
StreamReader reader = new StreamReader(layersPath);
a.options = reader.ReadLine();
reader.Close();
}
string[] enumSplit = a.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(a.top);
int index = property.intValue;
if (a.display == "")
{
a.display = property.displayName;
}
index = EditorGUILayout.MaskField(a.display, index, enumOptions.ToArray());
if (Mathf.Abs(index) > 32000)
{
index = -1;
}
//Debug Value
EditorGUILayout.LabelField(index.ToString());
property.intValue = index;
GUILayout.Space(a.down);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return -2;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3ceb6b7bf0fb6a8449797ccd85dea11c
timeCreated: 1544998323
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,52 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
namespace Boxophobic.StyledGUI
{
[CustomPropertyDrawer(typeof(StyledMessage))]
public class StyledMessageAttributeDrawer : PropertyDrawer
{
StyledMessage a;
bool show;
MessageType messageType;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
show = property.boolValue;
if (show)
{
a = (StyledMessage)attribute;
if (a.type == "None")
{
messageType = MessageType.None;
}
else if (a.type == "Info")
{
messageType = MessageType.Info;
}
else if (a.type == "Warning")
{
messageType = MessageType.Warning;
}
else if (a.type == "Error")
{
messageType = MessageType.Error;
}
GUILayout.Space(a.top);
EditorGUILayout.HelpBox(a.message, messageType);
GUILayout.Space(a.down);
}
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return -2;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2734a300c1fbfb8499fe8a71e9b109e7
timeCreated: 1544998323
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,71 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
namespace Boxophobic.StyledGUI
{
[CustomPropertyDrawer(typeof(StyledRangeOptions))]
public class StyledRangeOptionsAttributeDrawer : PropertyDrawer
{
StyledRangeOptions a;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
a = (StyledRangeOptions)attribute;
GUIStyle styleMid = new GUIStyle();
styleMid.alignment = TextAnchor.MiddleCenter;
styleMid.normal.textColor = Color.gray;
styleMid.fontSize = 7;
if (a.display.Length > 0)
{
EditorGUI.PropertyField(position, property, label, true);
GUILayout.Space(5);
}
GUILayout.BeginHorizontal();
GUILayout.Space(8);
property.floatValue = GUILayout.HorizontalSlider(property.floatValue, a.min, a.max);
property.floatValue = Mathf.Clamp(property.floatValue, a.min, a.max);
property.floatValue = Mathf.Round(property.floatValue * 1000f) / 1000f;
GUILayout.Space(8);
GUILayout.EndHorizontal();
#if UNITY_2019_3_OR_NEWER
GUILayout.Space(15);
#endif
GUILayout.BeginHorizontal();
int maxWidth = 20;
#if UNITY_2019_3_OR_NEWER
maxWidth = 28;
#endif
for (int i = 0; i < a.options.Length - 1; i++)
{
GUILayout.Label(a.options[i], styleMid, GUILayout.Width(maxWidth));
GUILayout.Label("", styleMid);
}
GUILayout.Label(a.options[a.options.Length - 1], styleMid, GUILayout.Width(maxWidth));
GUILayout.EndHorizontal();
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
a = (StyledRangeOptions)attribute;
if (a.display.Length > 0)
{
return 18;
}
else
{
return -2;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a5681c6e5862ae545ba9b00a5b813250
timeCreated: 1544998323
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
namespace Boxophobic.StyledGUI
{
[CustomPropertyDrawer(typeof(StyledSpace))]
public class StyledSpaceAttributeDrawer : PropertyDrawer
{
StyledSpace a;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
a = (StyledSpace)attribute;
GUILayout.Space(a.space);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return -2;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: db0457065a494f34aa3b619f240d8bda
timeCreated: 1544998323
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
namespace Boxophobic.StyledGUI
{
[CustomPropertyDrawer(typeof(StyledText))]
public class StyledTextAttributeDrawer : PropertyDrawer
{
StyledText a;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
a = (StyledText)attribute;
GUIStyle styleLabel = new GUIStyle(EditorStyles.label)
{
richText = true,
wordWrap = true
};
styleLabel.alignment = a.alignment;
GUILayout.Space(a.top);
GUILayout.Label(property.stringValue, styleLabel);
GUILayout.Space(a.down);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return -2;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: aeec2ac650d2d8f40aa3b9e0cb807db5
timeCreated: 1544998323
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,100 @@
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
using UnityEngine.Rendering;
namespace Boxophobic.StyledGUI
{
[CustomPropertyDrawer(typeof(StyledTexturePreview))]
public class StyledTexturePreviewAttributeDrawer : PropertyDrawer
{
int channel = 0;
ColorWriteMask channelMask = ColorWriteMask.All;
StyledTexturePreview a;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
a = (StyledTexturePreview)attribute;
var tex = (Texture)property.objectReferenceValue;
if (a.displayName != "")
{
GUILayout.BeginHorizontal();
GUILayout.Space(-1);
GUILayout.Label(a.displayName, GUILayout.Width(EditorGUIUtility.labelWidth - 1));
tex = (Texture)EditorGUILayout.ObjectField(tex, typeof(Texture), false);
GUILayout.EndHorizontal();
GUILayout.Space(10);
property.objectReferenceValue = tex;
}
if (tex == null)
{
return;
}
var styledText = new GUIStyle(EditorStyles.toolbarButton)
{
alignment = TextAnchor.MiddleCenter,
fontStyle = FontStyle.Normal,
fontSize = 10,
};
var styledPopup = new GUIStyle(EditorStyles.toolbarPopup)
{
alignment = TextAnchor.MiddleCenter,
fontSize = 10,
};
var rect = GUILayoutUtility.GetRect(0, 0, Screen.width, 0);
EditorGUI.DrawPreviewTexture(rect, tex, null, ScaleMode.ScaleAndCrop, 1, 0, channelMask);
GUILayout.Space(2);
GUILayout.BeginHorizontal();
GUILayout.Label((UnityEngine.Profiling.Profiler.GetRuntimeMemorySizeLong(tex) / 1024f / 1024f).ToString("F2") + " mb", styledText);
GUILayout.Space(-1);
GUILayout.Label(tex.width.ToString(), styledText);
GUILayout.Space(-1);
GUILayout.Label(tex.graphicsFormat.ToString(), styledText);
GUILayout.Space(-1);
channel = EditorGUILayout.Popup(channel, new string[] { "RGB", "R", "G", "B", "A" }, styledPopup, GUILayout.MaxWidth(60));
GUILayout.EndHorizontal();
if (channel == 0)
{
channelMask = ColorWriteMask.All;
}
else if (channel == 1)
{
channelMask = ColorWriteMask.Red;
}
else if (channel == 2)
{
channelMask = ColorWriteMask.Green;
}
else if (channel == 3)
{
channelMask = ColorWriteMask.Blue;
}
else if (channel == 4)
{
channelMask = ColorWriteMask.Alpha;
}
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return -2;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c8daad1bc4051084ca6204e12dc0890d
timeCreated: 1544998323
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e41931242f538c94eaed04fa8e0f1314
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View 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;
}
}
}

View 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:

View 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;
}
}
}

View 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:

View 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;
}
}
}
}

View 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:

View 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;
}
}
}

View 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:

View 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,
// };
//}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f13faeb510c3cb54ba5d051ecaad26e3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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);
}
}
}

View 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:

View 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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a5dbd5cf6c68f1d4ebd1369f8795ee3a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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;
}
}
}
}

View 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:

View 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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ae4fb3d8081065c47860724ea515c97c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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;
}
}
}

View 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:

View 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);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 057520665db88c444ae3d275cb0923d2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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);
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dafdc63aa2865b04e924ffea07fde94e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c837d89f6f4cd574595a810c5fcc15f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fd2d7ee86763017438ae71ea6a9800f6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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;
}
}
}

View 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:

View 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;
}
}
}

View 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:

View 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;
}
}
}

View 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:

View 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;
}
}
}

View 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:

View 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;
}
}
}

View 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:

View 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;
}
}
}

View 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:

View 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;
}
}
}

View 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:

View 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;
}
}
}

Some files were not shown because too many files have changed in this diff Show More