@@ -30,12 +30,11 @@ private async void OnEnable() {
30
30
}
31
31
}
32
32
33
- private void UpdataUI ( ) {
34
- this . GetSystem < IAddressableSystem > ( ) . LoadAsset < Sprite > ( Util . GetAvatarUrl ( curAid ) , ( obj ) => {
35
- if ( obj . Status == AsyncOperationStatus . Succeeded ) {
36
- curAvatar . sprite = Instantiate ( obj . Result , transform , false ) ;
37
- }
38
- } ) ;
33
+ private async void UpdataUI ( ) {
34
+ var obj = await this . GetSystem < IAddressableSystem > ( ) . LoadAssetAsync < Sprite > ( Util . GetAvatarUrl ( curAid ) ) ;
35
+ if ( obj . Status == AsyncOperationStatus . Succeeded ) {
36
+ curAvatar . sprite = Instantiate ( obj . Result , transform , false ) ;
37
+ }
39
38
curAvatarName . text = avatarModel . AvatarDic [ curAid ] . name ;
40
39
Util . DeleteChildren ( avatarItemParent ) ;
41
40
foreach ( var kvp in avatarModel . AvatarDic ) {
@@ -61,19 +60,18 @@ private void Start() {
61
60
this . RegisterEvent < UpdataAvatarUIEvent > ( OnUpdataAvatarUIEvent ) . UnRegisterWhenGameObjectDestroyed ( gameObject ) ;
62
61
}
63
62
64
- private void OnUpdataAvatarUIEvent ( UpdataAvatarUIEvent e ) {
63
+ private async void OnUpdataAvatarUIEvent ( UpdataAvatarUIEvent e ) {
65
64
if ( e . aid == this . GetModel < IUserModel > ( ) . Aid ) {
66
65
applyBtn . interactable = false ;
67
66
} else {
68
67
applyBtn . interactable = true ;
69
68
}
70
- this . GetSystem < IAddressableSystem > ( ) . LoadAsset < Sprite > ( Util . GetAvatarUrl ( e . aid ) , ( obj ) => {
71
- if ( obj . Status == AsyncOperationStatus . Succeeded ) {
72
- curAvatar . sprite = Instantiate ( obj . Result , transform , false ) ;
73
- }
74
- } ) ;
75
69
curAvatarName . text = avatarModel . AvatarDic [ e . aid ] . name ;
76
70
curAid = e . aid ;
71
+ var obj = await this . GetSystem < IAddressableSystem > ( ) . LoadAssetAsync < Sprite > ( Util . GetAvatarUrl ( e . aid ) ) ;
72
+ if ( obj . Status == AsyncOperationStatus . Succeeded ) {
73
+ curAvatar . sprite = Instantiate ( obj . Result , transform , false ) ;
74
+ }
77
75
}
78
76
79
77
public IArchitecture GetArchitecture ( ) {
0 commit comments