Add dedicated editor for Texture Group picking
This commit is contained in:
@@ -286,6 +286,7 @@ namespace FlaxEditor.Content.Import
|
||||
/// <summary>
|
||||
/// Texture group for streaming (negative if unused). See Streaming Settings.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(CustomEditors.Dedicated.TextureGroupEditor))]
|
||||
[EditorOrder(300), Tooltip("Texture group for streaming (negative if unused). See Streaming Settings.")]
|
||||
public int TextureGroup = -1;
|
||||
|
||||
|
||||
51
Source/Editor/CustomEditors/Dedicated/TextureGroupEditor.cs
Normal file
51
Source/Editor/CustomEditors/Dedicated/TextureGroupEditor.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
||||
|
||||
using FlaxEditor.Content.Settings;
|
||||
using FlaxEditor.CustomEditors.Elements;
|
||||
using FlaxEditor.GUI;
|
||||
using FlaxEngine;
|
||||
|
||||
namespace FlaxEditor.CustomEditors.Dedicated
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom editor for <see cref="TextureGroup"/> index.
|
||||
/// </summary>
|
||||
internal class TextureGroupEditor : CustomEditor
|
||||
{
|
||||
private ComboBoxElement _element;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override DisplayStyle Style => DisplayStyle.Inline;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Initialize(LayoutElementsContainer layout)
|
||||
{
|
||||
_element = layout.ComboBox();
|
||||
_element.ComboBox.SelectedIndexChanged += OnSelectedIndexChanged;
|
||||
_element.ComboBox.AddItem("None");
|
||||
var groups = GameSettings.Load<StreamingSettings>();
|
||||
if (groups?.TextureGroups != null)
|
||||
{
|
||||
for (int i = 0; i < groups.TextureGroups.Length; i++)
|
||||
{
|
||||
_element.ComboBox.AddItem(groups.TextureGroups[i].Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSelectedIndexChanged(ComboBox comboBox)
|
||||
{
|
||||
var value = comboBox.HasSelection ? comboBox.SelectedIndex - 1 : -1;
|
||||
SetValue(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Refresh()
|
||||
{
|
||||
base.Refresh();
|
||||
|
||||
var value = (int)Values[0];
|
||||
_element.ComboBox.SelectedIndex = value + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user