using UnityEngine;
using UnityEditor;
public class EditorStyleViewer : EditorWindow
{
private Vector2 scrollPosition = Vector2.zero;
private string search = string.Empty;
[MenuItem("Tools/GUI样式查看器")]
public static void Init()
{
EditorWindow.GetWindow(typeof(EditorStyleViewer));
}
void OnGUI()
{
GUILayout.BeginHorizontal("HelpBox");
GUILayout.Label("单击示例将复制其名到剪贴板", "label");
GUILayout.FlexibleSpace();
GUILayout.Label("查找:");
search = EditorGUILayout.TextField(search);
GUILayout.EndHorizontal();
scrollPosition = GUILayout.BeginScrollView(scrollPosition);
foreach (GUIStyle style in GUI.skin)
{
if (style.name.ToLower().Contains(search.ToLower()))
{
GUILayout.BeginHorizontal("PopupCurveSwatchBackground");
GUILayout.Space(7);
if (GUILayout.Button(style.name, style))
{
EditorGUIUtility.systemCopyBuffer = "\"" + style.name + "\"";
}
GUILayout.FlexibleSpace();
EditorGUILayout.SelectableLabel("\"" + style.name + "\"");
GUILayout.EndHorizontal();
GUILayout.Space(11);
}
}
GUILayout.EndScrollView();
}
}
GUI样式查看器
最新推荐文章于 2022-08-25 16:06:16 发布
本文介绍了一个Unity编辑器的扩展工具——GUI样式查看器。该工具允许开发者在Unity编辑器中查看并复制GUI皮肤样式名称,方便进行自定义GUI设计。通过搜索功能,可以快速定位所需样式,并一键复制其名称到剪贴板,提高开发效率。
摘要由CSDN通过智能技术生成