36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using AlicizaX.Resource.Runtime;
|
|||
|
|
using Paps.UnityToolbarExtenderUIToolkit;
|
|||
|
|
using UnityEditor;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.UIElements;
|
|||
|
|
|
|||
|
|
namespace AlicizaX.Editor.Extension
|
|||
|
|
{
|
|||
|
|
[MainToolbarElement("ResourceModeDropdownField", alignment: ToolbarAlign.Right, order: 0)]
|
|||
|
|
public class ResourceModeDropdownField : DropdownField
|
|||
|
|
{
|
|||
|
|
private static readonly string[] _resourceModeNames =
|
|||
|
|
{
|
|||
|
|
"Editor",
|
|||
|
|
"Offline",
|
|||
|
|
"Host",
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
public void InitializeElement()
|
|||
|
|
{
|
|||
|
|
label = "";
|
|||
|
|
choices = _resourceModeNames.ToList();
|
|||
|
|
style.fontSize = 12;
|
|||
|
|
int index = EditorPrefs.GetInt(ResourceComponent.PrefsKey, 0);
|
|||
|
|
SetValueWithoutNotify(choices[index]);
|
|||
|
|
RegisterCallback<ChangeEvent<string>>(evt =>
|
|||
|
|
{
|
|||
|
|
int newIndex = _resourceModeNames.ToList().IndexOf(evt.newValue);
|
|||
|
|
EditorPrefs.SetInt(ResourceComponent.PrefsKey, newIndex);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|