优质中文开源软件代码项目资源技术共享平台
传播开源的理念,推广开源项目
学习是对自己最棒的投资!与君共勉!

网站首页 > 游戏开发 正文

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

longtao100 2021-09-04 20:46:34 游戏开发 489 ℃ 0 评论

比如编辑模式下对场景或者特定文件夹有一些操作可以在这个面板里来完成。。


代码如下。

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
using  UnityEngine ;      
using  System . Collections ;      
using  UnityEditor ;      
 
 
[ CustomEditor ( typeof ( UnityEditor . DefaultAsset ) ) ]      
 
public   class   CustomInspector   :   Editor   {      
 
public   override  void   OnInspectorGUI   ( )      
{      
string   path   =   AssetDatabase . GetAssetPath ( target ) ;      
 
GUI . enabled   =   true ;      
if ( path . EndsWith ( ".unity" ) )      
{      
GUILayout . Button ( "我是场景" ) ;      
 
} else   if ( path . EndsWith ( "" ) ) { ;      
 
GUILayout . Button ( "我是文件夹" ) ;      
 
}      
}      
}      
 

 

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

 
1
2
3
 
[ CustomEditor ( typeof ( UnityEditor . SceneAsset ) ) ]      
 

 


Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

请填写验证码
开源分类
最近发表
开源网标签
开源网归档