using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(S_Socket))] //需要显示在Inspector的脚本
public class S_EditorTest : Editor //继承Editor类
{
S_Socket s_Socket;
public override void OnInspectorGUI()
{
s_Socket = (S_Socket)target; // 获取当前脚本数据
GUILayout.Button("Button"+s_Socket.str);
}
}

效果:
本文介绍了一个Unity自定义编辑器的简单示例,通过继承Editor类并使用CustomEditor特性,可以在Inspector面板中添加自定义按钮。示例展示了如何在脚本中获取目标组件的数据,并利用GUILayout来创建交互元素。
OnInspectorGUI&spm=1001.2101.3001.5002&articleId=101365613&d=1&t=3&u=82a9fa9e01754d69982fff8aba894edb)
8441

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



