3
3
// Copyright (c) 2018 Zhang Yang. All rights reserved.
4
4
// </copyright>
5
5
// <describe> #资源模块编辑器# </describe>
6
- // <email> yeozhang@qq .com </email>
6
+ // <email> dutifulwanderer@gmail .com </email>
7
7
// <time> #2018年12月15日 17点24分# </time>
8
8
//-----------------------------------------------------------------------
9
9
@@ -20,16 +20,16 @@ public class ResourceModuleEditor : ModuleEditorBase
20
20
private BuildTargetGroup _lastBuildTargetGroup ;
21
21
private string _lastScriptingDefineSymbols ;
22
22
//资源更新类型
23
- private const string RESOURCEUPDATETYPE = "ResourceUpdateType" ;
23
+ private const string RESOURCEUPDATETYPE = "ResourceUpdateType" ;
24
24
//资源本地路径
25
- private const string PATHTYPE = "PathType" ;
25
+ private const string PATHTYPE = "PathType" ;
26
26
//资源更新的路径
27
- private const string RESOFFICIALUPDATEPATH = "ResOfficialUpdatePath" ;
27
+ private const string RESOFFICIALUPDATEPATH = "ResOfficialUpdatePath" ;
28
28
//测试更新的路径
29
29
private const string RESTESTUPDATEPATH = "ResTestUpdatePath" ;
30
30
//默认是否需要从StreamingAsset里面拷贝到可读文件夹中
31
- private const string DEFAULTINSTREAMINGASSET = "DefaultInStreamingAsset" ;
32
-
31
+ private const string DEFAULTINSTREAMINGASSET = "DefaultInStreamingAsset" ;
32
+
33
33
public ResourceModuleEditor ( string name , Color mainColor , GameMode gameMode )
34
34
: base ( name , mainColor , gameMode )
35
35
{
@@ -41,107 +41,107 @@ public ResourceModuleEditor(string name, Color mainColor, GameMode gameMode)
41
41
public override void OnDrawGUI ( )
42
42
{
43
43
//检查配置文件
44
- if ( ! NoConfigError ( ) )
44
+ if ( ! NoConfigError ( ) )
45
45
{
46
46
47
- GUILayout . BeginVertical ( "HelpBox" ) ;
47
+ GUILayout . BeginVertical ( "HelpBox" ) ;
48
48
49
- GUILayout . BeginHorizontal ( "HelpBox" ) ;
50
- GUILayout . Label ( "Define" , GUILayout . Width ( 50 ) ) ;
51
- string scriptingDefineSymbols = PlayerSettings . GetScriptingDefineSymbolsForGroup ( _lastBuildTargetGroup ) ;
52
- _lastScriptingDefineSymbols = GUILayout . TextArea ( _lastScriptingDefineSymbols ) ;
53
- if ( GUILayout . Button ( "OK" , GUILayout . Width ( 40 ) ) && ! _lastScriptingDefineSymbols . Equals ( scriptingDefineSymbols ) )
54
- {
55
- _lastBuildTargetGroup = BuildPipeline . GetBuildTargetGroup ( EditorUserBuildSettings . activeBuildTarget ) ;
56
- PlayerSettings . SetScriptingDefineSymbolsForGroup ( _lastBuildTargetGroup , _lastScriptingDefineSymbols ) ;
57
- }
58
- GUILayout . EndHorizontal ( ) ;
49
+ GUILayout . BeginHorizontal ( "HelpBox" ) ;
50
+ GUILayout . Label ( "Define" , GUILayout . Width ( 50 ) ) ;
51
+ string scriptingDefineSymbols = PlayerSettings . GetScriptingDefineSymbolsForGroup ( _lastBuildTargetGroup ) ;
52
+ _lastScriptingDefineSymbols = GUILayout . TextArea ( _lastScriptingDefineSymbols ) ;
53
+ if ( GUILayout . Button ( "OK" , GUILayout . Width ( 40 ) ) && ! _lastScriptingDefineSymbols . Equals ( scriptingDefineSymbols ) )
54
+ {
55
+ _lastBuildTargetGroup = BuildPipeline . GetBuildTargetGroup ( EditorUserBuildSettings . activeBuildTarget ) ;
56
+ PlayerSettings . SetScriptingDefineSymbolsForGroup ( _lastBuildTargetGroup , _lastScriptingDefineSymbols ) ;
57
+ }
58
+ GUILayout . EndHorizontal ( ) ;
59
59
60
- //检查配置文件是否存在
61
- CheckConfig ( RESOURCEUPDATETYPE , 0 ) ;
62
- ResourceUpdateType gameModeResourceUpdateType = ( ResourceUpdateType ) ( int ) _gameMode . ConfigJsonData [ RESOURCEUPDATETYPE ] ;
63
- CheckConfig ( PATHTYPE , 0 ) ;
64
- PathType gameModePathType = ( PathType ) ( int ) _gameMode . ConfigJsonData [ PATHTYPE ] ;
65
- CheckConfig ( RESOFFICIALUPDATEPATH , "" ) ;
66
- string gameModeResOfficialUpdatePath = ( string ) _gameMode . ConfigJsonData [ RESOFFICIALUPDATEPATH ] ;
67
- CheckConfig ( RESTESTUPDATEPATH , "" ) ;
68
- string gameModeResTestUpdatePath = ( string ) _gameMode . ConfigJsonData [ RESTESTUPDATEPATH ] ;
69
- CheckConfig ( DEFAULTINSTREAMINGASSET , false ) ;
70
- bool gameModeDefaultInStreamingAsset = ( bool ) _gameMode . ConfigJsonData [ DEFAULTINSTREAMINGASSET ] ;
60
+ //检查配置文件是否存在
61
+ CheckConfig ( RESOURCEUPDATETYPE , 0 ) ;
62
+ ResourceUpdateType gameModeResourceUpdateType = ( ResourceUpdateType ) ( int ) _gameMode . ConfigJsonData [ RESOURCEUPDATETYPE ] ;
63
+ CheckConfig ( PATHTYPE , 0 ) ;
64
+ PathType gameModePathType = ( PathType ) ( int ) _gameMode . ConfigJsonData [ PATHTYPE ] ;
65
+ CheckConfig ( RESOFFICIALUPDATEPATH , "" ) ;
66
+ string gameModeResOfficialUpdatePath = ( string ) _gameMode . ConfigJsonData [ RESOFFICIALUPDATEPATH ] ;
67
+ CheckConfig ( RESTESTUPDATEPATH , "" ) ;
68
+ string gameModeResTestUpdatePath = ( string ) _gameMode . ConfigJsonData [ RESTESTUPDATEPATH ] ;
69
+ CheckConfig ( DEFAULTINSTREAMINGASSET , false ) ;
70
+ bool gameModeDefaultInStreamingAsset = ( bool ) _gameMode . ConfigJsonData [ DEFAULTINSTREAMINGASSET ] ;
71
71
72
- ResourceUpdateType resUpdateType = ( ResourceUpdateType ) EditorGUILayout . EnumPopup ( "Resource Update Type" , gameModeResourceUpdateType ) ;
73
- if ( resUpdateType != gameModeResourceUpdateType )
74
- {
75
- gameModeResourceUpdateType = resUpdateType ;
76
- _gameMode . ConfigJsonData [ RESOURCEUPDATETYPE ] = ( int ) resUpdateType ;
77
- //保存数据
78
- SaveConfig ( ) ;
79
- }
80
- PathType localPathType = gameModePathType ;
81
- if ( gameModeResourceUpdateType != ResourceUpdateType . Editor
82
- && gameModeResourceUpdateType != ResourceUpdateType . None )
83
- {
84
- if ( gameModeResourceUpdateType == ResourceUpdateType . Update )
72
+ ResourceUpdateType resUpdateType = ( ResourceUpdateType ) EditorGUILayout . EnumPopup ( "Resource Update Type" , gameModeResourceUpdateType ) ;
73
+ if ( resUpdateType != gameModeResourceUpdateType )
74
+ {
75
+ gameModeResourceUpdateType = resUpdateType ;
76
+ _gameMode . ConfigJsonData [ RESOURCEUPDATETYPE ] = ( int ) resUpdateType ;
77
+ //保存数据
78
+ SaveConfig ( ) ;
79
+ }
80
+ PathType localPathType = gameModePathType ;
81
+ if ( gameModeResourceUpdateType != ResourceUpdateType . Editor
82
+ && gameModeResourceUpdateType != ResourceUpdateType . None )
85
83
{
86
- string officialUpdatePath = EditorGUILayout . TextField ( "Official Update Path" , gameModeResOfficialUpdatePath ) ;
87
- if ( ! officialUpdatePath . Equals ( gameModeResOfficialUpdatePath ) )
84
+ if ( gameModeResourceUpdateType == ResourceUpdateType . Update )
88
85
{
89
- gameModeResOfficialUpdatePath = officialUpdatePath ;
90
- _gameMode . ConfigJsonData [ RESOFFICIALUPDATEPATH ] = officialUpdatePath ;
91
- //保存数据
92
- SaveConfig ( ) ;
86
+ string officialUpdatePath = EditorGUILayout . TextField ( "Official Update Path" , gameModeResOfficialUpdatePath ) ;
87
+ if ( ! officialUpdatePath . Equals ( gameModeResOfficialUpdatePath ) )
88
+ {
89
+ gameModeResOfficialUpdatePath = officialUpdatePath ;
90
+ _gameMode . ConfigJsonData [ RESOFFICIALUPDATEPATH ] = officialUpdatePath ;
91
+ //保存数据
92
+ SaveConfig ( ) ;
93
+ }
94
+ string testUpdatePath = EditorGUILayout . TextField ( "Test Update Path" , gameModeResTestUpdatePath ) ;
95
+ if ( ! testUpdatePath . Equals ( gameModeResTestUpdatePath ) )
96
+ {
97
+ gameModeResTestUpdatePath = testUpdatePath ;
98
+ _gameMode . ConfigJsonData [ RESTESTUPDATEPATH ] = testUpdatePath ;
99
+ //保存数据
100
+ SaveConfig ( ) ;
101
+ }
102
+ localPathType =
103
+ ( PathType ) EditorGUILayout . EnumPopup ( "Local Path Type" , PathType . ReadWrite ) ;
104
+ bool value = GUILayout . Toggle ( gameModeDefaultInStreamingAsset , "Default In StreamingAsset" ) ;
105
+ if ( value != gameModeDefaultInStreamingAsset )
106
+ {
107
+ gameModeDefaultInStreamingAsset = value ;
108
+ _gameMode . ConfigJsonData [ DEFAULTINSTREAMINGASSET ] = value ;
109
+ //保存数据
110
+ SaveConfig ( ) ;
111
+ }
93
112
}
94
- string testUpdatePath = EditorGUILayout . TextField ( "Test Update Path" , gameModeResTestUpdatePath ) ;
95
- if ( ! testUpdatePath . Equals ( gameModeResTestUpdatePath ) )
113
+ else
96
114
{
97
- gameModeResTestUpdatePath = testUpdatePath ;
98
- _gameMode . ConfigJsonData [ RESTESTUPDATEPATH ] = testUpdatePath ;
99
- //保存数据
100
- SaveConfig ( ) ;
115
+ localPathType =
116
+ ( PathType ) EditorGUILayout . EnumPopup ( "Local Path Type" , gameModePathType ) ;
101
117
}
102
- localPathType =
103
- ( PathType ) EditorGUILayout . EnumPopup ( "Local Path Type" , PathType . ReadWrite ) ;
104
- bool value = GUILayout . Toggle ( gameModeDefaultInStreamingAsset , "Default In StreamingAsset" ) ;
105
- if ( value != gameModeDefaultInStreamingAsset )
118
+ if ( gameModePathType != localPathType )
106
119
{
107
- gameModeDefaultInStreamingAsset = value ;
108
- _gameMode . ConfigJsonData [ DEFAULTINSTREAMINGASSET ] = value ;
109
- //保存数据
120
+ gameModePathType = localPathType ;
121
+ _gameMode . ConfigJsonData [ PATHTYPE ] = ( int ) localPathType ;
110
122
SaveConfig ( ) ;
111
123
}
112
- }
113
- else
114
- {
115
- localPathType =
116
- ( PathType ) EditorGUILayout . EnumPopup ( "Local Path Type" , gameModePathType ) ;
117
- }
118
- if ( gameModePathType != localPathType )
119
- {
120
- gameModePathType = localPathType ;
121
- _gameMode . ConfigJsonData [ PATHTYPE ] = ( int ) localPathType ;
122
- SaveConfig ( ) ;
123
- }
124
- string path = "" ;
125
- switch ( gameModePathType )
126
- {
127
- case PathType . DataPath :
128
- path = Application . dataPath ;
129
- break ;
130
- case PathType . ReadOnly :
131
- path = Application . streamingAssetsPath ;
132
- break ;
133
- case PathType . ReadWrite :
134
- path = Application . persistentDataPath ;
135
- break ;
136
- case PathType . TemporaryCache :
137
- path = Application . temporaryCachePath ;
138
- break ;
139
- }
124
+ string path = "" ;
125
+ switch ( gameModePathType )
126
+ {
127
+ case PathType . DataPath :
128
+ path = Application . dataPath ;
129
+ break ;
130
+ case PathType . ReadOnly :
131
+ path = Application . streamingAssetsPath ;
132
+ break ;
133
+ case PathType . ReadWrite :
134
+ path = Application . persistentDataPath ;
135
+ break ;
136
+ case PathType . TemporaryCache :
137
+ path = Application . temporaryCachePath ;
138
+ break ;
139
+ }
140
140
141
- EditorGUILayout . LabelField ( "Path" , path ) ;
142
- }
141
+ EditorGUILayout . LabelField ( "Path" , path ) ;
142
+ }
143
143
144
- GUILayout . EndVertical ( ) ;
144
+ GUILayout . EndVertical ( ) ;
145
145
}
146
146
}
147
147
0 commit comments