Skip to content

Commit 833bde9

Browse files
committed
增加Addressables编辑器打包的接口
1 parent fa6cab9 commit 833bde9

File tree

4 files changed

+86
-17
lines changed

4 files changed

+86
-17
lines changed

GameFramework/Editor/AddressablesEditor.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using UnityEditor;
5+
using UnityEditor.AddressableAssets.Build;
6+
using UnityEditor.AddressableAssets;
7+
using System.Text;
8+
using UnityEditor.AddressableAssets.Settings;
9+
10+
namespace Wanderer.GameFramework
11+
{
12+
public class AddressablesEditor
13+
{
14+
[MenuItem("Tools/Addressables/Build Content")]
15+
public static void BuildContent()
16+
{
17+
AddressableAssetSettings.BuildPlayerContent();
18+
}
19+
20+
[MenuItem("Tools/Addressables/Check Update")]
21+
public static void CheckUpdate()
22+
{
23+
string binPath = ContentUpdateScript.GetContentStateDataPath(false);
24+
var settings = AddressableAssetSettingsDefaultObject.Settings;
25+
var entries = ContentUpdateScript.GatherModifiedEntries(settings, binPath);
26+
StringBuilder @string = new StringBuilder();
27+
foreach (var item in entries)
28+
{
29+
@string.AppendLine(item.address);
30+
}
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+
}
37+
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));
45+
AssetDatabase.Refresh();
46+
}
47+
}
48+
}

GameFramework/Editor/AddressablesEditor/AddressablesEditor.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
{
2-
"name": "GameFramework.Editor",
3-
"references": [
4-
"GameFramework",
5-
"Libraries"
6-
],
7-
"includePlatforms": [
8-
"Editor"
9-
],
10-
"excludePlatforms": [],
11-
"allowUnsafeCode": false,
12-
"overrideReferences": false,
13-
"precompiledReferences": [],
14-
"autoReferenced": true,
15-
"defineConstraints": [],
16-
"versionDefines": [],
17-
"noEngineReferences": false
1+
{
2+
"name": "GameFramework.Editor",
3+
"rootNamespace": "",
4+
"references": [
5+
"GameFramework",
6+
"Libraries",
7+
"Unity.Addressables.Editor"
8+
],
9+
"includePlatforms": [
10+
"Editor"
11+
],
12+
"excludePlatforms": [],
13+
"allowUnsafeCode": false,
14+
"overrideReferences": false,
15+
"precompiledReferences": [],
16+
"autoReferenced": true,
17+
"defineConstraints": [],
18+
"versionDefines": [],
19+
"noEngineReferences": false
1820
}

0 commit comments

Comments
 (0)