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
+ }
88
88
}
0 commit comments