@@ -20,8 +20,10 @@ public class SettingModuleEditor : ModuleEditorBase
2020 private BuildTargetGroup _lastBuildTargetGroup ;
2121 private string _lastScriptingDefineSymbols ;
2222 private int _selectType = 1 ;
23+ private int _resourcePlanType = 0 ;
2324 private HashSet < string > _defineSymbols ;
2425 private const string TEST = "TEST" ;
26+ private const string ADDRESSABLES = "ADDRESSABLES_SUPPORT" ;
2527
2628 public SettingModuleEditor ( string name , Color mainColor , GameMode gameMode )
2729 : base ( name , mainColor , gameMode )
@@ -40,10 +42,14 @@ public SettingModuleEditor(string name, Color mainColor, GameMode gameMode)
4042 if ( ! string . IsNullOrEmpty ( item ) )
4143 {
4244 _defineSymbols . Add ( item ) ;
43- if ( item . Equals ( " TEST" ) )
45+ if ( item . Equals ( TEST ) )
4446 {
4547 _selectType = 0 ;
4648 }
49+ else if ( item . Equals ( ADDRESSABLES ) )
50+ {
51+ _resourcePlanType = 1 ;
52+ }
4753 }
4854 }
4955 }
@@ -53,6 +59,22 @@ public SettingModuleEditor(string name, Color mainColor, GameMode gameMode)
5359 public override void OnDrawGUI ( )
5460 {
5561 GUILayout . BeginVertical ( "HelpBox" ) ;
62+ //Resource plan
63+ int resourcePlanType = EditorGUILayout . IntPopup ( "Resource Plan" , _resourcePlanType , new string [ ] { "Asset Bundle" , "Addressables" } , new int [ ] { 0 , 1 } ) ;
64+ if ( resourcePlanType != _resourcePlanType )
65+ {
66+ if ( resourcePlanType == 1 )
67+ {
68+ _defineSymbols . Add ( ADDRESSABLES ) ;
69+ }
70+ else
71+ {
72+ _defineSymbols . Remove ( ADDRESSABLES ) ;
73+ }
74+ _resourcePlanType = resourcePlanType ;
75+ SaveScriptingDefineSymbols ( ) ;
76+ }
77+ #if ! ADDRESSABLES_SUPPORT
5678 //app server
5779 int selectType = EditorGUILayout . IntPopup ( "App Server" , _selectType , new string [ ] { "Test" , "Official" } , new int [ ] { 0 , 1 } ) ;
5880 if ( selectType != _selectType )
@@ -65,22 +87,24 @@ public override void OnDrawGUI()
6587 {
6688 _defineSymbols . Remove ( TEST ) ;
6789 }
68- _lastScriptingDefineSymbols = "" ;
69- foreach ( var item in _defineSymbols )
70- {
71- _lastScriptingDefineSymbols = $ "{ _lastScriptingDefineSymbols } { item } ;";
72- }
73- 74- _lastBuildTargetGroup = BuildPipeline . GetBuildTargetGroup ( EditorUserBuildSettings . activeBuildTarget ) ;
75- PlayerSettings . SetScriptingDefineSymbolsForGroup ( _lastBuildTargetGroup , _lastScriptingDefineSymbols ) ;
7690 _selectType = selectType ;
77- 91+ SaveScriptingDefineSymbols ( ) ;
7892 }
93+ #endif
7994 //检查配置文件
8095 if ( ! NoConfigError ( ) )
8196 {
8297 GUILayout . BeginHorizontal ( ) ;
8398
99+ ////支持Address
100+ //bool addressablesSupport=(bool)_gameMode.ConfigJsonData["AddressablesSupport"];
101+ //bool newAddressablesSupport = GUILayout.Toggle(addressablesSupport, "Addressables Support");
102+ //if (addressablesSupport != newAddressablesSupport)
103+ //{
104+ // _gameMode.ConfigJsonData["AddressablesSupport"] = addressablesSupport;
105+ // SaveConfig();
106+ //}
107+ 84108 //启动调试器
85109 bool debugEnable = ( bool ) _gameMode . ConfigJsonData [ "DebugEnable" ] ;
86110 bool newDebugEnable = GUILayout . Toggle ( debugEnable , "Debug Enable" ) ;
@@ -105,5 +129,21 @@ public override void OnDrawGUI()
105129 public override void OnClose ( )
106130 {
107131 }
132+ 133+ 134+ private void SaveScriptingDefineSymbols ( )
135+ {
136+ //EditorUtility.DisplayProgressBar("", "Is setting PlayerSettings ScriptingDefineSymbolsForGroup, please wait...",0.9f);
137+ _lastScriptingDefineSymbols = "" ;
138+ foreach ( var item in _defineSymbols )
139+ {
140+ _lastScriptingDefineSymbols = $ "{ _lastScriptingDefineSymbols } { item } ;";
141+ }
142+ 143+ _lastBuildTargetGroup = BuildPipeline . GetBuildTargetGroup ( EditorUserBuildSettings . activeBuildTarget ) ;
144+ PlayerSettings . SetScriptingDefineSymbolsForGroup ( _lastBuildTargetGroup , _lastScriptingDefineSymbols ) ;
145+ //EditorUtility.ClearProgressBar();
146+ }
147+ 108148 }
109149}
0 commit comments