This repository was archived by the owner on Jun 4, 2021. It is now read-only.
File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 9
9
using Random = UnityEngine . Random ;
10
10
11
11
public class Popup : MonoBehaviour {
12
+ static int canvasSortOrder = 100 ;
12
13
public bool IsShowed => isShowed ;
13
14
14
15
[ Header ( "Refs" ) , Space ]
16
+ [ SerializeField ] Canvas canvas ;
15
17
[ SerializeField ] CanvasGroup cg ;
16
18
[ SerializeField ] TextMeshProUGUI textField ;
17
19
18
20
bool isShowed ;
19
21
22
+ #if UNITY_EDITOR
23
+ private void OnValidate ( ) {
24
+ if ( ! canvas )
25
+ canvas = GetComponent < Canvas > ( ) ;
26
+ if ( ! cg )
27
+ cg = GetComponent < CanvasGroup > ( ) ;
28
+ }
29
+ #endif
30
+
20
31
private void Awake ( ) {
21
32
cg . alpha = 0.0f ;
22
33
}
@@ -28,13 +39,17 @@ public void SetText(string text) {
28
39
public void Show ( ) {
29
40
isShowed = true ;
30
41
42
+ canvas . sortingOrder = canvasSortOrder ++ ;
43
+
31
44
LeanTween . cancel ( gameObject , false ) ;
32
45
LeanTweenEx . ChangeAlpha ( cg , 1.0f , 0.1f ) . setEase ( LeanTweenType . easeInOutQuad ) ;
33
46
}
34
47
35
48
public void Hide ( ) {
36
49
isShowed = false ;
37
50
51
+ -- canvasSortOrder ;
52
+
38
53
LeanTween . cancel ( gameObject , false ) ;
39
54
LeanTweenEx . ChangeAlpha ( cg , 0.0f , 0.1f ) . setEase ( LeanTweenType . easeInOutQuad ) ;
40
55
}
You can’t perform that action at this time.
0 commit comments