66using UnityEditor . AddressableAssets ;
77using System . Text ;
88using UnityEditor . AddressableAssets . Settings ;
9+ using System . IO ;
910
1011namespace 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