@@ -18,7 +18,7 @@ public class PopupManager : MonoBehaviour
1818 [ SerializeField ]
1919 private TweenData closeAnimation ;
2020
21- private List < Popup > openedPopups = new ( ) ;
21+ private readonly List < Popup > openedPopups = new ( ) ;
2222
2323 public static PopupManager Instance { get ; private set ; }
2424
@@ -31,7 +31,7 @@ private void Start()
3131 {
3232 foreach ( var popup in allPopups )
3333 {
34- ClosePopup ( popup ) ;
34+ popup . CanvasGroup . transform . localScale = Vector2 . zero ;
3535 popup . OnClose += ClosePopup ;
3636 }
3737 }
@@ -68,7 +68,7 @@ public void OpenPopup(Popup popup)
6868 openedPopups . Add ( popup ) ;
6969 popup . OpenTween = popup . transform . DOScale ( Vector2 . one , openAnimation . Duration )
7070 . SetEase ( openAnimation . Ease )
71- . SetTarget ( this ) ;
71+ . SetLink ( popup . gameObject ) ;
7272 }
7373
7474 public void ClosePopup ( PopupType type )
@@ -81,7 +81,7 @@ public void ClosePopup(Popup popup)
8181 {
8282 popup . OpenTween ? . Kill ( ) ;
8383 int previousIndex = openedPopups . FindIndex ( x => x == popup ) - 1 ;
84- if ( previousIndex > - 1 && openedPopups . Count > previousIndex )
84+ if ( previousIndex >= 0 && openedPopups . Count > previousIndex )
8585 {
8686 openedPopups [ previousIndex ] . CanvasGroup . blocksRaycasts = true ;
8787 }
@@ -90,7 +90,7 @@ public void ClosePopup(Popup popup)
9090 popup . CloseTween = popup . transform . DOScale ( Vector2 . zero , closeAnimation . Duration * popup . transform . localScale . x )
9191 . SetEase ( closeAnimation . Ease )
9292 . OnComplete ( ( ) => FinalizePopup ( popup ) )
93- . SetTarget ( this ) ;
93+ . SetLink ( popup . gameObject ) ;
9494 }
9595
9696 private void FinalizePopup ( Popup popup )
0 commit comments