diff --git a/Source/Editor/CustomEditors/Editors/ActorLayerEditor.cs b/Source/Editor/CustomEditors/Editors/ActorLayerEditor.cs
index ff00d362f..b500dd61b 100644
--- a/Source/Editor/CustomEditors/Editors/ActorLayerEditor.cs
+++ b/Source/Editor/CustomEditors/Editors/ActorLayerEditor.cs
@@ -13,7 +13,11 @@ namespace FlaxEditor.CustomEditors.Editors
///
public sealed class ActorLayerEditor : CustomEditor
{
+ private const string AddOrEditLayersOption = "Add or Edit Layers";
+
private ComboBoxElement element;
+ private int _layerCount;
+ private bool _updatingItems;
///
public override DisplayStyle Style => DisplayStyle.Inline;
@@ -22,14 +26,56 @@ namespace FlaxEditor.CustomEditors.Editors
public override void Initialize(LayoutElementsContainer layout)
{
element = layout.ComboBox();
- element.ComboBox.SetItems(LayersAndTagsSettings.GetCurrentLayers());
- element.ComboBox.SelectedIndex = (int)Values[0];
+ UpdateLayerItems((int)Values[0]);
+ element.ComboBox.PopupShowing += OnPopupShowing;
element.ComboBox.SelectedIndexChanged += OnSelectedIndexChanged;
}
+ private void OnPopupShowing(ComboBox comboBox)
+ {
+ UpdateLayerItems(HasDifferentValues ? -1 : (int)Values[0]);
+ }
+
+ private void UpdateLayerItems(int selectedIndex)
+ {
+ _updatingItems = true;
+ var layers = LayersAndTagsSettings.GetCurrentLayers();
+ _layerCount = layers.Length;
+ element.ComboBox.SetItems(layers);
+ element.ComboBox.AddItem(AddOrEditLayersOption);
+ element.ComboBox.SelectedIndex = selectedIndex >= 0 && selectedIndex < _layerCount ? selectedIndex : -1;
+ _updatingItems = false;
+ }
+
+ private void SelectCurrentLayer()
+ {
+ UpdateLayerItems(HasDifferentValues ? -1 : (int)Values[0]);
+ }
+
+ private void OpenLayersAndTagsSettings()
+ {
+ var asset = GameSettings.LoadAsset();
+ if (!asset)
+ {
+ GameSettings.Save(new LayersAndTagsSettings());
+ asset = GameSettings.LoadAsset();
+ }
+ if (asset)
+ Editor.Instance.ContentEditing.Open(asset);
+ }
+
private void OnSelectedIndexChanged(ComboBox comboBox)
{
+ if (_updatingItems)
+ return;
+
int value = comboBox.SelectedIndex;
+ if (value == _layerCount)
+ {
+ OpenLayersAndTagsSettings();
+ SelectCurrentLayer();
+ return;
+ }
if (value == -1)
value = 0;
@@ -87,7 +133,7 @@ namespace FlaxEditor.CustomEditors.Editors
}
else
{
- element.ComboBox.SelectedIndex = (int)Values[0];
+ UpdateLayerItems((int)Values[0]);
}
}
}