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 2d46cae

Browse files
Addressables增加Shell打包的接口
1 parent 833bde9 commit 2d46cae

File tree

1 file changed

+42
-26
lines changed

1 file changed

+42
-26
lines changed

‎GameFramework/Editor/AddressablesEditor/AddressablesEditor.cs‎

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,59 @@
66
using UnityEditor.AddressableAssets;
77
using System.Text;
88
using UnityEditor.AddressableAssets.Settings;
9+
using System.IO;
910

1011
namespace Wanderer.GameFramework
1112
{
1213
public class AddressablesEditor
1314
{
14-
[MenuItem("Tools/Addressables/Build Content")]
15-
public static void BuildContent()
15+
public static string ShellBuild(string activeProfileId = "Default")
1616
{
17-
AddressableAssetSettings.BuildPlayerContent();
18-
}
19-
20-
[MenuItem("Tools/Addressables/Check Update")]
21-
public static void CheckUpdate()
22-
{
23-
string binPath = ContentUpdateScript.GetContentStateDataPath(false);
17+
bool buildPlayerContent = true;
2418
var settings = AddressableAssetSettingsDefaultObject.Settings;
25-
var entries = ContentUpdateScript.GatherModifiedEntries(settings, binPath);
26-
StringBuilder @string = new StringBuilder();
27-
foreach (var item in entries)
19+
if (settings != null && settings.BuildRemoteCatalog)
2820
{
29-
@string.AppendLine(item.address);
21+
var profileId = settings.profileSettings.GetProfileId(activeProfileId);
22+
settings.activeProfileId = profileId;
23+
string binPath = ContentUpdateScript.GetContentStateDataPath(false);
24+
if (File.Exists(binPath))
25+
{
26+
Debug.Log($"binPath: {binPath}");
27+
buildPlayerContent = false;
28+
29+
//Check update
30+
var entries = ContentUpdateScript.GatherModifiedEntries(settings, binPath);
31+
if (entries.Count > 0)
32+
{
33+
StringBuilder @string = new StringBuilder();
34+
foreach (var item in entries)
35+
{
36+
@string.AppendLine(item.address);
37+
}
38+
//将被修改过的资源单独分组
39+
var groupName = string.Format("UpdateGroup_{0}_", System.DateTime.Now.ToString("yyyyMMdd"));
40+
ContentUpdateScript.CreateContentUpdateGroup(settings, entries, groupName);
41+
Debug.Log($"Update content:{@string}");
42+
AssetDatabase.Refresh();
43+
}
44+
45+
//Build update
46+
ContentUpdateScript.BuildContentUpdate(settings, binPath);
47+
}
48+
}
49+
if (buildPlayerContent)
50+
{
51+
AddressableAssetSettings.BuildPlayerContent();
3052
}
31-
//将被修改过的资源单独分组
32-
var groupName = string.Format("UpdateGroup_{0}", System.DateTime.Now.ToString("yyyyMMdd"));
33-
ContentUpdateScript.CreateContentUpdateGroup(settings, entries, groupName);
34-
Debug.Log($"Update content:{@string}");
35-
AssetDatabase.Refresh();
36-
}
3753

38-
[MenuItem("Tools/Addressables/Build Update")]
39-
public static void BuildUpdate()
40-
{
41-
var binPath = ContentUpdateScript.GetContentStateDataPath(false);
42-
var settings = AddressableAssetSettingsDefaultObject.Settings;
43-
AddressablesPlayerBuildResult result = ContentUpdateScript.BuildContentUpdate(settings, binPath);
44-
Debug.Log("BuildFinish path = " + settings.RemoteCatalogBuildPath.GetValue(settings));
4554
AssetDatabase.Refresh();
55+
56+
if (settings != null && settings.BuildRemoteCatalog)
57+
return settings.RemoteCatalogBuildPath.GetValue(settings);
58+
59+
return "";
60+
4661
}
62+
4763
}
4864
}

0 commit comments

Comments
(0)

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