using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class myeditor:EditorWindow {
[MenuItem("my/myname")]//编辑窗口路径
static public void my()//回调函数
{
EditorWindow edit = EditorWindow.GetWindow
edit.minSize = new Vector2(200,300);//创建窗口大小
edit.maxSize = new Vector2(200, 600);
edit.Show();
}
bool isshow = false;
private void OnGUI()
{
Debug.LogError("OnGUIOnGUIOnGUIOnGUI");
if (isshow)
{
//根据字符串搜索project资源库中匹配的资源列表
string[] sTRSTR = AssetDatabase.FindAssets("i t:Shader");
for (int i = 0; i < sTRSTR.Length; i++)
{
GameObject obj=AssetDatabase.LoadAssetAtPath
(AssetDatabase.GUIDToAssetPath(sTRSTR[i]))); //把每个资源guild转换为对应的路径
EditorGUILayout.ObjectField(// 把加载出来的文件放到编辑窗口中
AssetDatabase.LoadAssetAtPath
(AssetDatabase.GUIDToAssetPath(sTRSTR[i])), typeof(Object), true);
}
}
GUILayout.Label("myname:");//对于text文本设置
GUILayout.BeginHorizontal();//水平布局
GUILayout.Label("anniu");
GUILayout.Button("setimage");//对于按钮的设置
GUILayout.EndHorizontal();//结束水平布局
if (GUILayout.Button("setimage") == true)//如果点击了按钮
{
isshow = !isshow;//设置水平布局是否显示
}
}
}