关注公众号 风色年代(itfantasycc) 200G 游戏开发资料合集送上~

[Unity] 插件开发常用组件_unity

using UnityEngine;
using System.Collections;
using UnityEditor;

public class Window_T1 : EditorWindow
{
private int num = 0;
private float flo = 0;
private string str = "";
private bool bol;
private int sli = 100;
private Color col = Color.gray;
private Vector3 vec3 = Vector3.one;
private GameObject obj;
private Transform trs;
private AudioClip audic;

//绘制窗口
void OnGUI()
{
//存储num 并显示
num = EditorGUILayout.IntField("Int:", num);

//存储float并显示
flo = EditorGUILayout.FloatField("Float:", flo);

//存储string 并显示
str = EditorGUILayout.TextField("String:", str);

//存储bool值
bol = EditorGUILayout.Toggle("Toggle:", bol);

//Label 参数前面是Label1 后是Label2
EditorGUILayout.LabelField("Label1:", EditorApplication.timeSinceStartup.ToString());

//滑块
sli = EditorGUILayout.IntSlider(5, 0, 100);

// 颜色块
col = EditorGUILayout.ColorField("Color:", col);

//坐标
vec3 = EditorGUILayout.Vector3Field("Vector3:", vec3);

//对象 参数说明(对象名称、对象类型、flase-不允许选择实例化过的对象(true-可以选择实例化的对象)、强制转换
obj = EditorGUILayout.ObjectField("Obj:", obj, typeof(GameObject), true) as GameObject;

//Transform
trs = EditorGUILayout.ObjectField("Transform:", trs, typeof(Transform), true) as Transform;

//Audio
audic = EditorGUILayout.ObjectField("Audio:", audic, typeof(AudioClip), true) as AudioClip;

GUILayout.Button("点击按钮",GUILayout.Width(100),GUILayout.Height(50));

}
}