using System.Collections.Generic; using Unity.UIWidgets.material; using Unity.UIWidgets.ui; using Unity.UIWidgets.widgets; #if UNITY_EDITOR using UnityEditor; using UnityEditor.UI; #endif using UnityEngine; namespace UIWidgetsSample { class TheatreEntry { public string entryName; public Widget entryWidget; } class UIWidgetsTheatre : UIWidgetsSamplePanel { static readonly List entries = new List { new TheatreEntry{entryName = "Material App Bar", entryWidget = new MaterialAppBarWidget()}, new TheatreEntry{entryName = "Material Tab Bar" , entryWidget = new MaterialTabBarWidget()} }; public static string[] entryKeys { get { List ret = new List(); foreach (var entry in entries) { ret.Add(entry.entryName); } return ret.ToArray(); } } [SerializeField] public int testCaseId; protected override Widget createWidget() { return new MaterialApp( showPerformanceOverlay: false, home: entries[this.testCaseId].entryWidget); } protected override void Awake() { base.Awake(); FontManager.instance.addFont(Resources.Load("MaterialIcons-Regular"), "Material Icons"); } } #if UNITY_EDITOR [CustomEditor(typeof(UIWidgetsTheatre), true)] [CanEditMultipleObjects] public class UIWidgetTheatreEditor : RawImageEditor { int _choiceIndex; public override void OnInspectorGUI() { var materialSample = this.target as UIWidgetsTheatre; this._choiceIndex = EditorGUILayout.Popup("Test Case", materialSample.testCaseId, UIWidgetsTheatre.entryKeys); materialSample.testCaseId = this._choiceIndex; EditorUtility.SetDirty(this.target); } } #endif }