Skip to content

Commit d9dff45

Browse files
authored
Merge pull request #42 from marc-antoine-girard/#41-visual-RawReferenceDrawer-style
2 parents f82b6c0 + 475ed39 commit d9dff45

File tree

3 files changed

+46
-8
lines changed

3 files changed

+46
-8
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using UnityEditor;
2+
using UnityEngine;
3+
4+
namespace TNRD.Drawers
5+
{
6+
internal partial class RawReferenceDrawer
7+
{
8+
private static class Styles
9+
{
10+
public static Color LineColor
11+
{
12+
get
13+
{
14+
return EditorGUIUtility.isProSkin
15+
? new Color(0.14f, 0.14f, 0.14f, 0.5f)
16+
: new Color(0.67f, 0.67f, 0.67f);
17+
}
18+
}
19+
}
20+
}
21+
}

Editor/Drawers/RawReferenceDrawer.Styles.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Drawers/RawReferenceDrawer.cs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace TNRD.Drawers
88
{
9-
internal class RawReferenceDrawer : ReferenceDrawer, IReferenceDrawer
9+
internal partial class RawReferenceDrawer : ReferenceDrawer, IReferenceDrawer
1010
{
1111
private GUIContent label;
1212
private FieldInfo fieldInfo;
@@ -26,9 +26,7 @@ public float GetHeight()
2626
if (RawReferenceValue == null)
2727
return EditorGUIUtility.singleLineHeight;
2828

29-
return EditorGUIUtility.singleLineHeight +
30-
EditorGUIUtility.standardVerticalSpacing +
31-
EditorGUI.GetPropertyHeight(RawReferenceProperty, true);
29+
return EditorGUI.GetPropertyHeight(RawReferenceProperty, true);
3230
}
3331

3432
/// <inheritdoc />
@@ -53,16 +51,32 @@ public void OnGUI(Rect position)
5351

5452
if (rawReferenceValue == null)
5553
return;
54+
55+
DrawLine(position);
56+
DrawProperty(position);
57+
58+
previousPropertyPath = Property.propertyPath;
59+
}
5660

61+
private void DrawProperty(Rect position)
62+
{
5763
Rect objectDrawerRect = new Rect(position);
58-
objectDrawerRect.yMin += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
59-
64+
6065
EditorGUI.PropertyField(objectDrawerRect,
6166
RawReferenceProperty,
62-
new GUIContent(rawReferenceValue.GetType().Name),
67+
GUIContent.none,
6368
true);
69+
}
6470

65-
previousPropertyPath = Property.propertyPath;
71+
private void DrawLine(Rect position)
72+
{
73+
Rect line = new Rect(position)
74+
{
75+
width = 4,
76+
yMin = position.yMin + EditorGUIUtility.singleLineHeight,
77+
x = position.x + 2f
78+
};
79+
EditorGUI.DrawRect(line, Styles.LineColor);
6680
}
6781

6882
protected override void PingObject()

0 commit comments

Comments
 (0)