13.EditorGUIUtility-EditorGUIUtility是什么
13.1 知识点
EditorGUIUtility公共类是用来做什么的
Utility 表示实用的意思。EditorGUIUtility 是与 EditorGUI / EditorGUILayout 配套的静态工具类(独立类型,不是 EditorGUI 的内嵌类),提供一些资源加载、坐标转换、对象选择器等辅助 API。我们只需掌握其中较常用的部分。
官方文档:EditorGUIUtility
准备工作
创建一个自定义编辑器窗口用于之后学习 EditorGUIUtility 相关的知识。
using System;
using UnityEditor;
public class MyEditorGUIUtilityLearnWindow : EditorWindow
{
[MenuItem("编辑器拓展教程/MyEditorGUIUtilityLearnWindow")]
private static void OpenMyEditorGUIUtilityLearnWindow()
{
MyEditorGUIUtilityLearnWindow win = EditorWindow.GetWindow<MyEditorGUIUtilityLearnWindow>("EditorGUIUtility学习面板");
//win.titleContent = new GUIContent("EditorGUIUtility学习面板");
win.Show();
}
private void OnGUI()
{
}
}
13.2 知识点代码
Lesson13_EditorGUIUtility_EditorGUIUtility是什么
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Lesson13_EditorGUIUtility_EditorGUIUtility是什么 : MonoBehaviour
{
void Start()
{
#region 知识点一 EditorGUIUtility公共类是用来做什么的?
// Utility 表示实用;EditorGUIUtility 是与 EditorGUI / EditorGUILayout 配套的静态工具类(独立类型)
// 提供了一些 EditorGUI 相关的其他辅助API
// 我们只需要学习其中的相对常用的内容
// 官方文档:https://docs.unity3d.com/ScriptReference/EditorGUIUtility.html
#endregion
#region 知识点二 准备工作
//创建一个自定义编辑器窗口 用于之后学习EditorGUIUtility相关的知识
#endregion
}
}
MyEditorGUIUtilityLearnWindow
using System;
using UnityEditor;
public class MyEditorGUIUtilityLearnWindow : EditorWindow
{
[MenuItem("编辑器拓展教程/MyEditorGUIUtilityLearnWindow")]
private static void OpenMyEditorGUIUtilityLearnWindow()
{
MyEditorGUIUtilityLearnWindow win = EditorWindow.GetWindow<MyEditorGUIUtilityLearnWindow>("EditorGUIUtility学习面板");
//win.titleContent = new GUIContent("EditorGUIUtility学习面板");
win.Show();
}
private void OnGUI()
{
}
}
转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 785293209@qq.com