Fix [AssetReference(typeof(typeName)] not working for arrays of assets (fix for collection types)
This commit is contained in:
@@ -184,7 +184,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
var overrideEditor = overrideEditorType != null ? (CustomEditor)Activator.CreateInstance(overrideEditorType) : null;
|
||||
var property = panel.AddPropertyItem(new CollectionItemLabel(this, i));
|
||||
var itemLayout = useSharedLayout ? (LayoutElementsContainer)property : property.VerticalPanel();
|
||||
itemLayout.Object(new ListValueContainer(elementType, i, Values), overrideEditor);
|
||||
itemLayout.Object(new ListValueContainer(elementType, i, Values, attributes), overrideEditor);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -202,7 +202,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
var overrideEditor = overrideEditorType != null ? (CustomEditor)Activator.CreateInstance(overrideEditorType) : null;
|
||||
var property = panel.AddPropertyItem("Element " + i);
|
||||
var itemLayout = useSharedLayout ? (LayoutElementsContainer)property : property.VerticalPanel();
|
||||
itemLayout.Object(new ListValueContainer(elementType, i, Values), overrideEditor);
|
||||
itemLayout.Object(new ListValueContainer(elementType, i, Values, attributes), overrideEditor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace FlaxEditor.CustomEditors
|
||||
/// <seealso cref="FlaxEditor.CustomEditors.ValueContainer" />
|
||||
public class ListValueContainer : ValueContainer
|
||||
{
|
||||
private readonly object[] _attributes;
|
||||
|
||||
/// <summary>
|
||||
/// The index in the collection.
|
||||
/// </summary>
|
||||
@@ -34,9 +36,12 @@ namespace FlaxEditor.CustomEditors
|
||||
/// <param name="elementType">Type of the collection elements.</param>
|
||||
/// <param name="index">The index.</param>
|
||||
/// <param name="values">The collection values.</param>
|
||||
public ListValueContainer(ScriptType elementType, int index, ValueContainer values)
|
||||
/// <param name="attributes">The collection property attributes to inherit.</param>
|
||||
public ListValueContainer(ScriptType elementType, int index, ValueContainer values, object[] attributes = null)
|
||||
: this(elementType, index)
|
||||
{
|
||||
_attributes = attributes;
|
||||
|
||||
Capacity = values.Count;
|
||||
for (int i = 0; i < values.Count; i++)
|
||||
{
|
||||
@@ -120,5 +125,11 @@ namespace FlaxEditor.CustomEditors
|
||||
_hasReferenceValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override object[] GetAttributes()
|
||||
{
|
||||
return _attributes ?? base.GetAttributes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user