美文网首页Unity编辑器开发分享unity修炼之路Unity基础入门分享
Unity3D研究院编辑器之自定义默认资源的Inspector面

Unity3D研究院编辑器之自定义默认资源的Inspector面

作者: 霸俊流年 | 来源:发表于2017-09-25 21:22 被阅读24次

转自:http://www.xuanyusong.com/archives/3685
比如编辑模式下对场景或者特定文件夹有一些操作可以在这个面板里来完成。。

代码如下。

using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(UnityEditor.DefaultAsset))]
publicclassCustomInspector:Editor{
publicoverride voidOnInspectorGUI()
{
stringpath=AssetDatabase.GetAssetPath(target);
GUI.enabled=true;
if(path.EndsWith(".unity"))
{
GUILayout.Button("我是场景");
}elseif(path.EndsWith("")){;
GUILayout.Button("我是文件夹");
}
}
}

如果你是unity5.3的话, 想在场景面板上面绘制东西需要使用 UnityEditor.SceneAsset

[CustomEditor(typeof(UnityEditor.SceneAsset))]

本文固定链接: http://www.xuanyusong.com/archives/3685
转载请注明: 雨松MOMO2015年10月23日 于 雨松MOMO程序研究院 发表

相关文章

网友评论

    本文标题:Unity3D研究院编辑器之自定义默认资源的Inspector面

    本文链接:https://www.haomeiwen.com/subject/qutjextx.html