您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
67 行
2.0 KiB
67 行
2.0 KiB
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<TheatreEntry> entries = new List<TheatreEntry> {
|
|
new TheatreEntry{entryName = "Material App Bar", entryWidget = new MaterialAppBarWidget()},
|
|
new TheatreEntry{entryName = "Material Tab Bar" , entryWidget = new MaterialTabBarWidget()}
|
|
};
|
|
|
|
public static string[] entryKeys {
|
|
get {
|
|
List<string> ret = new List<string>();
|
|
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<Font>("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
|
|
}
|