Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit c86ed32

Browse files
committed
增加Addressables的更新接口
1 parent 2868958 commit c86ed32

15 files changed

+1566
-1390
lines changed
Lines changed: 87 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,88 @@
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-
using System.IO;
10-
using UnityEditor.AddressableAssets.Settings.GroupSchemas;
11-
12-
namespace Wanderer.GameFramework
13-
{
14-
public class AddressablesEditor
15-
{
16-
public static string ShellBuild(string activeProfileId = "Default")
17-
{
18-
bool buildPlayerContent = true;
19-
var settings = AddressableAssetSettingsDefaultObject.Settings;
20-
if (settings != null && settings.BuildRemoteCatalog)
21-
{
22-
var profileId = settings.profileSettings.GetProfileId(activeProfileId);
23-
settings.activeProfileId = profileId;
24-
string binPath = ContentUpdateScript.GetContentStateDataPath(false);
25-
if (File.Exists(binPath))
26-
{
27-
//Debug.Log($"binPath: {binPath}");
28-
buildPlayerContent = false;
29-
30-
//Check update
31-
var entries = ContentUpdateScript.GatherModifiedEntries(settings, binPath);
32-
if (entries.Count > 0)
33-
{
34-
StringBuilder @string = new StringBuilder();
35-
foreach (var item in entries)
36-
{
37-
@string.AppendLine(item.address);
38-
}
39-
//将被修改过的资源单独分组
40-
var groupName = string.Format("UpdateGroup_{0}#", System.DateTime.Now.ToString("yyyyMMdd"));
41-
ContentUpdateScript.CreateContentUpdateGroup(settings, entries, groupName);
42-
var group= settings.FindGroup(groupName);
43-
BundledAssetGroupSchema bagSchema = group.GetSchema<BundledAssetGroupSchema>();
44-
if (bagSchema == null)
45-
{
46-
bagSchema = group.AddSchema<BundledAssetGroupSchema>();
47-
}
48-
var defultBAGSchema = settings.DefaultGroup.GetSchema<BundledAssetGroupSchema>();
49-
50-
bagSchema.BuildPath.SetVariableByName(settings, defultBAGSchema.BuildPath.GetValue(settings));
51-
bagSchema.LoadPath.SetVariableByName(settings, defultBAGSchema.LoadPath.GetValue(settings));
52-
Debug.Log($"Update content:{@string}");
53-
EditorUtility.SetDirty(settings);
54-
AssetDatabase.Refresh();
55-
}
56-
57-
//Build update
58-
ContentUpdateScript.BuildContentUpdate(settings, binPath);
59-
}
60-
}
61-
if (buildPlayerContent)
62-
{
63-
AddressableAssetSettings.BuildPlayerContent();
64-
}
65-
66-
AssetDatabase.Refresh();
67-
68-
if (settings != null && settings.BuildRemoteCatalog)
69-
return settings.RemoteCatalogBuildPath.GetValue(settings);
70-
71-
return "";
72-
}
73-
74-
public static void ShellBuildPlayerContent(string activeProfileId = "Default")
75-
{
76-
var settings = AddressableAssetSettingsDefaultObject.Settings;
77-
if (settings != null && settings.BuildRemoteCatalog)
78-
{
79-
var profileId = settings.profileSettings.GetProfileId(activeProfileId);
80-
settings.activeProfileId = profileId;
81-
}
82-
AddressableAssetSettings.BuildPlayerContent();
83-
EditorUtility.SetDirty(settings);
84-
AssetDatabase.Refresh();
85-
}
86-
87-
}
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+
using System.IO;
10+
using UnityEditor.AddressableAssets.Settings.GroupSchemas;
11+
12+
namespace Wanderer.GameFramework
13+
{
14+
public class AddressablesEditor
15+
{
16+
public static string ShellBuild(string activeProfileId = "Default")
17+
{
18+
bool buildPlayerContent = true;
19+
var settings = AddressableAssetSettingsDefaultObject.Settings;
20+
if (settings != null && settings.BuildRemoteCatalog)
21+
{
22+
var profileId = settings.profileSettings.GetProfileId(activeProfileId);
23+
settings.activeProfileId = profileId;
24+
string binPath = ContentUpdateScript.GetContentStateDataPath(false);
25+
if (File.Exists(binPath))
26+
{
27+
//Debug.Log($"binPath: {binPath}");
28+
buildPlayerContent = false;
29+
30+
//Check update
31+
var entries = ContentUpdateScript.GatherModifiedEntries(settings, binPath);
32+
if (entries.Count > 0)
33+
{
34+
StringBuilder @string = new StringBuilder();
35+
foreach (var item in entries)
36+
{
37+
@string.AppendLine(item.address);
38+
}
39+
//将被修改过的资源单独分组
40+
var groupName = string.Format("UpdateGroup_{0}#", System.DateTime.Now.ToString("yyyyMMdd"));
41+
ContentUpdateScript.CreateContentUpdateGroup(settings, entries, groupName);
42+
var group= settings.FindGroup(groupName);
43+
BundledAssetGroupSchema bagSchema = group.GetSchema<BundledAssetGroupSchema>();
44+
if (bagSchema == null)
45+
{
46+
bagSchema = group.AddSchema<BundledAssetGroupSchema>();
47+
}
48+
var defultBAGSchema = settings.DefaultGroup.GetSchema<BundledAssetGroupSchema>();
49+
50+
bagSchema.BuildPath.SetVariableByName(settings, defultBAGSchema.BuildPath.GetValue(settings));
51+
bagSchema.LoadPath.SetVariableByName(settings, defultBAGSchema.LoadPath.GetValue(settings));
52+
Debug.Log($"Update content:{@string}");
53+
EditorUtility.SetDirty(settings);
54+
AssetDatabase.Refresh();
55+
}
56+
57+
//Build update
58+
ContentUpdateScript.BuildContentUpdate(settings, binPath);
59+
}
60+
}
61+
if (buildPlayerContent)
62+
{
63+
AddressableAssetSettings.BuildPlayerContent();
64+
}
65+
66+
AssetDatabase.Refresh();
67+
68+
if (settings != null && settings.BuildRemoteCatalog)
69+
return settings.RemoteCatalogBuildPath.GetValue(settings);
70+
71+
return "";
72+
}
73+
74+
public static void ShellBuildPlayerContent(string activeProfileId = "Default")
75+
{
76+
var settings = AddressableAssetSettingsDefaultObject.Settings;
77+
if (settings != null && settings.BuildRemoteCatalog)
78+
{
79+
var profileId = settings.profileSettings.GetProfileId(activeProfileId);
80+
settings.activeProfileId = profileId;
81+
}
82+
AddressableAssetSettings.BuildPlayerContent();
83+
EditorUtility.SetDirty(settings);
84+
AssetDatabase.Refresh();
85+
}
86+
87+
}
8888
}

GameFramework/Editor/AssetManagement/AddressablesEditor.cs.meta

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)