File tree Expand file tree Collapse file tree 1 file changed +22
-9
lines changed
Expand file tree Collapse file tree 1 file changed +22
-9
lines changed Original file line number Diff line number Diff line change 1+ using System ;
12using System . Threading ;
23using UnityEngine ;
34using UnityEngine . EventSystems ;
@@ -47,20 +48,32 @@ public void OnPointerUp(PointerEventData eventData)
4748 private async UniTaskVoid ScaleButtonAsync ( Vector3 targetScale , float duration , CancellationToken token )
4849 {
4950 float time = 0f ;
51+ if ( _image == null )
52+ return ;
53+
5054 Vector3 startScale = _image . transform . localScale ;
5155
52- while ( time < duration )
56+ try
5357 {
54- if ( token . IsCancellationRequested )
55- return ;
58+ while ( time < duration && ! token . IsCancellationRequested )
59+ {
60+ if ( this == null || _image == null )
61+ return ;
5662
57- float t = time / duration ;
58- _image . transform . localScale = Vector3 . Lerp ( startScale , targetScale , t ) ;
59- time += Time . unscaledDeltaTime ;
60- await UniTask . Yield ( PlayerLoopTiming . Update , token ) ;
61- }
63+ float t = time / duration ;
64+ _image . transform . localScale = Vector3 . Lerp ( startScale , targetScale , t ) ;
65+ time += Time . unscaledDeltaTime ;
66+ await UniTask . Yield ( PlayerLoopTiming . Update , token ) ;
67+ }
6268
63- _image . transform . localScale = targetScale ;
69+ if ( this != null && _image != null )
70+ _image . transform . localScale = targetScale ;
71+ }
72+ catch ( OperationCanceledException )
73+ {
74+
75+ }
6476 }
77+
6578 }
6679}
You can’t perform that action at this time.
0 commit comments