Unity_EditorWindow(Skin界面展示)
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace Miss
{
public class EditorStyleViewer : EditorWindow
{
static EditorStyleViewer window = null;
[MenuItem("Miss/EditorStyleViewer")]
public static void MyWindow()
{
window = GetWindow<EditorStyleViewer>();
window.Show();
}
private string m_SearchStr = string.Empty;
private Vector2 m_ScrollerPos = Vector2.zero;
private void OnGUI()
{
EditorGUILayout.BeginHorizontal("box");
{
GUILayout.Label(new GUIContent("单击左侧栏名称即可复制"), "Badge");
GUILayout.Space(20);
GUILayout.Label(new GUIContent("右侧栏名称可选择性复制"), "Badge");
GUILayout.FlexibleSpace();
GUILayout.Label(new GUIContent("搜索:"), "Badge");
m_SearchStr = EditorGUILayout.TextField(m_SearchStr, GUILayout.Width(100));
}
EditorGUILayout.EndHorizontal();
GUILayout.Space(20);
m_ScrollerPos = EditorGUILayout.BeginScrollView(m_ScrollerPos, "AnimItemBackground");
{
foreach (GUIStyle style in GUI.skin)
{
if (style.name.ToLower().Contains(m_SearchStr))
{
EditorGUILayout.BeginHorizontal();
{
if (GUILayout.Button(style.name, style))
{
EditorGUIUtility.systemCopyBuffer = style.name;
ShowNotification(new GUIContent($"已复制到粘贴板: {style.name}"));
}
GUILayout.FlexibleSpace();
EditorGUILayout.SelectableLabel(style.name);
}
EditorGUILayout.EndHorizontal();
GUILayout.Space(10);
}
}
}
EditorGUILayout.EndScrollView();
}
}
}
界面效果展示:
|