extra assets + decoration
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// 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);
|
||||
|
||||
StyledGUI.DrawInspectorBanner(bannerColor, a.title);
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a832b9f47ccef214e81c89efe6bf31dd
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1d35dbbb9b6c214aa892d7b240de3df
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb59d41716ab6114cb7cf03a5695083b
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c3935e6d6b91844d8053d3fa7faff1b
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea3f7407f69f900468d4b60de570e49d
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80229de18cd73624b8181a9db49a304f
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b351b243374f2d948a9e9943abe174bf
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ceb6b7bf0fb6a8449797ccd85dea11c
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2734a300c1fbfb8499fe8a71e9b109e7
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,71 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5681c6e5862ae545ba9b00a5b813250
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db0457065a494f34aa3b619f240d8bda
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aeec2ac650d2d8f40aa3b9e0cb807db5
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8daad1bc4051084ca6204e12dc0890d
|
||||
timeCreated: 1544998323
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user