forked from Shardstone/trail-into-darkness
changed directory structure
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Jovian.InspectorTools {
|
||||
public class SuffixAttribute : PropertyAttribute {
|
||||
public readonly string suffix;
|
||||
|
||||
public SuffixAttribute(string suffix) => this.suffix = suffix;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
namespace Jovian.InspectorTools.Internal {
|
||||
using UnityEditor;
|
||||
|
||||
[CustomPropertyDrawer(typeof(SuffixAttribute))]
|
||||
public class SuffixDrawer : PropertyDrawer {
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
|
||||
var suffix = new GUIContent(((SuffixAttribute)attribute).suffix);
|
||||
var suffixSize = GUI.skin.label.CalcSize(suffix);
|
||||
suffixSize.x += GUI.skin.label.margin.left;
|
||||
var fieldPosition = position;
|
||||
fieldPosition.width -= suffixSize.x;
|
||||
var suffixPosition = position;
|
||||
suffixPosition.x += fieldPosition.width + GUI.skin.label.margin.left;
|
||||
suffixPosition.width = suffixSize.x;
|
||||
EditorGUI.PropertyField(fieldPosition, property, label);
|
||||
var enabled = GUI.enabled;
|
||||
GUI.enabled = false;
|
||||
GUI.Label(suffixPosition, suffix);
|
||||
GUI.enabled = enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user