Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Editor/Elements/TriListElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class TriListElement : TriElement
private readonly ReorderableList _reorderableListGui;
private readonly bool _alwaysExpanded;
private readonly bool _showElementLabels;
private readonly bool _fixDefaultValue;

private float _lastContentWidth;

Expand All @@ -30,6 +31,7 @@ public TriListElement(TriProperty property)

_property = property;
_alwaysExpanded = settings?.AlwaysExpanded ?? false;
_fixDefaultValue = settings?.FixDefaultValue ?? false;
_showElementLabels = settings?.ShowElementLabels ?? false;
_reorderableListGui = new ReorderableList(null, _property.ArrayElementType)
{
Expand Down Expand Up @@ -134,6 +136,12 @@ private void AddElementCallback(ReorderableList reorderableList, Object addedRef
if (_property.TryGetSerializedProperty(out _))
{
ReorderableListProxy.DoAddButton(reorderableList, addedReferenceValue);

if (_fixDefaultValue)
{
reorderableList.serializedProperty.GetArrayElementAtIndex(reorderableList.index).boxedValue = Activator.CreateInstance(_property.ArrayElementType);
}

_property.NotifyValueChanged();
return;
}
Expand Down
1 change: 1 addition & 0 deletions Runtime/Attributes/ListDrawerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public class ListDrawerSettingsAttribute : Attribute
public bool HideRemoveButton { get; set; }
public bool AlwaysExpanded { get; set; }
public bool ShowElementLabels { get; set; }
public bool FixDefaultValue { get; set; } = false;
}
}