Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit 943e2ab

Browse files
准备支持Addressable
1 parent 2a1cc1c commit 943e2ab

File tree

4 files changed

+82
-21
lines changed

4 files changed

+82
-21
lines changed

‎Editor/GameMode/Module/ConfigModuleEditor.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ public ConfigModuleEditor(string name, Color mainColor, GameMode gameMode)
3232
_defaultConfigData["DefaultInStreamingAsset"] = true;
3333
_defaultConfigData["DebugEnable"] = true;
3434
_defaultConfigData["DebugLogMaxLine"] = 100;
35+
//_defaultConfigData["AddressablesSupport"] = false;
3536
_defaultConfigData["LogFileEnable"] = true;
3637
_defaultConfigData["AppVersion"] = Application.version;
38+
_defaultConfigData["DefineSymbols"] = "UNITASK_DOTWEEN_SUPPORT;";//ADDRESSABLES_SUPPORT;
3739
}
3840
}
3941

‎Editor/GameMode/Module/ResourceModuleEditor.cs‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public ResourceModuleEditor(string name, Color mainColor, GameMode gameMode)
3636
//获取当前的BuildTargetGroup
3737
_lastBuildTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);
3838
_lastScriptingDefineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(_lastBuildTargetGroup);
39+
//if (string.IsNullOrEmpty(_lastScriptingDefineSymbols))
40+
//{
41+
// _lastScriptingDefineSymbols= (string)_gameMode.ConfigJsonData["DefineSymbols"];
42+
// PlayerSettings.SetScriptingDefineSymbolsForGroup(_lastBuildTargetGroup, _lastScriptingDefineSymbols);
43+
//}
3944
}
4045

4146
public override void OnDrawGUI()
@@ -49,6 +54,11 @@ public override void OnDrawGUI()
4954
GUILayout.BeginHorizontal("HelpBox");
5055
GUILayout.Label("Define", GUILayout.Width(50));
5156
string scriptingDefineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(_lastBuildTargetGroup);
57+
if (string.IsNullOrEmpty(_lastScriptingDefineSymbols))
58+
{
59+
_lastScriptingDefineSymbols = (string)_gameMode.ConfigJsonData["DefineSymbols"];
60+
PlayerSettings.SetScriptingDefineSymbolsForGroup(_lastBuildTargetGroup, _lastScriptingDefineSymbols);
61+
}
5262
_lastScriptingDefineSymbols = GUILayout.TextArea(_lastScriptingDefineSymbols);
5363
if (GUILayout.Button("OK", GUILayout.Width(40)) && !_lastScriptingDefineSymbols.Equals(scriptingDefineSymbols))
5464
{
@@ -57,6 +67,7 @@ public override void OnDrawGUI()
5767
}
5868
GUILayout.EndHorizontal();
5969

70+
#if !ADDRESSABLES_SUPPORT
6071
//检查配置文件是否存在
6172
CheckConfig(RESOURCEUPDATETYPE, 0);
6273
ResourceUpdateType gameModeResourceUpdateType = (ResourceUpdateType)(int)_gameMode.ConfigJsonData[RESOURCEUPDATETYPE];
@@ -140,7 +151,7 @@ public override void OnDrawGUI()
140151

141152
EditorGUILayout.LabelField("Path", path);
142153
}
143-
154+
#endif
144155
GUILayout.EndVertical();
145156
}
146157
}

‎Editor/GameMode/Module/SettingModuleEditor.cs‎

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

‎Editor/GameMode/ModuleEditorBase.cs‎

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,24 @@ public ModuleEditorBase(string name, Color mainColor, GameMode gameMode)
4444
//默认绘制界面
4545
public virtual void OnInspectorGUI()
4646
{
47-
GUI.color = _mainColor;
48-
GUILayout.BeginVertical("Box");
49-
GUI.color = _defaultColor;
50-
GUILayout.BeginHorizontal();
51-
GUILayout.Space(12);
52-
_isExpand = EditorGUILayout.Foldout(_isExpand, _name, true);
53-
GUILayout.EndHorizontal();
54-
if (_isExpand)
55-
OnDrawGUI();
56-
GUILayout.EndVertical();
47+
if (EditorApplication.isCompiling)
48+
{
49+
EditorUtility.DisplayProgressBar("", "Compiling, please wait...", 1.0f);
50+
}
51+
else
52+
{
53+
EditorUtility.ClearProgressBar();
54+
GUI.color = _mainColor;
55+
GUILayout.BeginVertical("Box");
56+
GUI.color = _defaultColor;
57+
GUILayout.BeginHorizontal();
58+
GUILayout.Space(12);
59+
_isExpand = EditorGUILayout.Foldout(_isExpand, _name, true);
60+
GUILayout.EndHorizontal();
61+
if (_isExpand)
62+
OnDrawGUI();
63+
GUILayout.EndVertical();
64+
}
5765
}
5866

5967
//绘制界面

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /