写编辑器时,不为别的,就为排版漂亮点。
参考NGUI的编辑器工具,修改了下,实现如下效果:

控件代码如下:
YZSettings.cs
using UnityEngine;
using UnityEditor;
public class YZSettings
{
#region Generic Get and Set methods
/// <summary>
/// Save the specified boolean value in settings.
/// </summary>
static public void SetBool(string name, bool val) { EditorPrefs.SetBool(name, val); }
/// <summary>
/// Save the specified integer value in settings.
/// </summary>
static public void SetInt(string name, int val) { EditorPrefs.SetInt(name, val); }
/// <summary>
/// Save the specified float value in settings.
/// </summary>
static public void SetFloat(string name, float val) { EditorPrefs.SetFloat(name, val); }
/// <summary>
/// Save the specified string value in settings.
/// </summary>
static public void SetString(string name, string val) { EditorPrefs.SetString(name, val); }
/// <summary>
/// Save the specified color value in settings.
/// </summary>
static public void SetColor(string name, Color c) { SetString(name, c.r + " " + c.g + " " + c.b + " " + c.a); }
/// <summary>
/// Save the specified enum value to settings.
/// </summary>
static public void SetEnum(string name, System.Enum val) { SetString(name, val.ToString()); }
/// <summary>
/// Save the specified object in settings.
/// </summary>
static public void Set(string name, Object obj)
{
if (obj == null)
{
EditorPrefs.DeleteKey(name);
}
else
{
if (obj != null)
{
string path = AssetDatabase.GetAssetPath(obj);
if (!string.IsNullOrEmpty(path))
{

本文介绍了一种基于Unity编辑器的界面美化方案,通过自定义控件实现更美观的排版效果。文中提供了YZSettings和YZEditorTools两个核心类的具体实现,并展示了如何使用这些工具来创建个性化的编辑器界面。
最低0.47元/天 解锁文章
7万+

被折叠的 条评论
为什么被折叠?



