6
6
using UnityEditor . AddressableAssets ;
7
7
using System . Text ;
8
8
using UnityEditor . AddressableAssets . Settings ;
9
+ using System . IO ;
9
10
10
11
namespace Wanderer . GameFramework
11
12
{
12
13
public class AddressablesEditor
13
14
{
14
- [ MenuItem ( "Tools/Addressables/Build Content" ) ]
15
- public static void BuildContent ( )
15
+ public static string ShellBuild ( string activeProfileId = "Default" )
16
16
{
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 ;
24
18
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 )
28
20
{
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 ( ) ;
30
52
}
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
53
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
54
AssetDatabase . Refresh ( ) ;
55
+
56
+ if ( settings != null && settings . BuildRemoteCatalog )
57
+ return settings . RemoteCatalogBuildPath . GetValue ( settings ) ;
58
+
59
+ return "" ;
60
+
46
61
}
62
+
47
63
}
48
64
}
0 commit comments