Skip to content

Commit 225fdb6

Browse files
authored
Merge pull request #173 from brunomikoski/feature/hide-label
Added the option to hide the label to make it more compact
2 parents 294eeae + 54b5e36 commit 225fdb6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Scripts/Editor/PropertyDrawers/CollectionItemPropertyDrawer.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ internal void DrawCollectionItemDrawer(
114114
{
115115
float originY = position.y;
116116
position.height = 15;
117-
Rect prefixPosition = EditorGUI.PrefixLabel(position, label);
117+
bool shouldDrawLabel = OptionsAttribute.LabelMode != LabelMode.NoLabel;
118+
Rect prefixPosition = shouldDrawLabel ? EditorGUI.PrefixLabel(position, label) : position;
119+
118120
int indent = EditorGUI.indentLevel;
119121
EditorGUI.indentLevel = 0;
120122
if (collectionItem != null)

Scripts/Runtime/Attributes/SOCItemEditorOptionsAttribute.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ public enum DrawType
99
AsReference = 1
1010
}
1111

12+
public enum LabelMode
13+
{
14+
Default = 0,
15+
NoLabel = 1,
16+
//LabelOnSeparateLine = 2, // TODO
17+
}
18+
1219
#if UNITY_2022_2_OR_NEWER
1320
[Obsolete("DrawAsSOCItemAttribute is not needed anymore, since Unity 2022 PropertyDrawers can be applied to interfaces")]
1421
#endif
@@ -34,7 +41,9 @@ public class SOCItemEditorOptionsAttribute : Attribute
3441
/// If specified, only show collection items that belong to the collection assigned to the specified field.
3542
/// </summary>
3643
public string ConstrainToCollectionField { get; set; }
37-
44+
45+
public LabelMode LabelMode { get; set; }
46+
3847
/// <summary>
3948
/// If specified, will perform this method whenever the value changes.
4049
/// Parameters of the method should be: ItemType from, ItemType to
@@ -47,4 +56,4 @@ public class SOCItemEditorOptionsAttribute : Attribute
4756
public class CollectionItemEditorOptions : SOCItemEditorOptionsAttribute
4857
{
4958
}
50-
}
59+
}

0 commit comments

Comments
 (0)