Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Commit

Permalink
Fix popup overlaping
Browse files Browse the repository at this point in the history
  • Loading branch information
Team-on committed May 4, 2021
1 parent 964d90d commit 2348273
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Ld48/Assets/Scripts/UI/Popup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,25 @@
using Random = UnityEngine.Random;

public class Popup : MonoBehaviour {
static int canvasSortOrder = 100;
public bool IsShowed => isShowed;

[Header("Refs"), Space]
[SerializeField] Canvas canvas;
[SerializeField] CanvasGroup cg;
[SerializeField] TextMeshProUGUI textField;

bool isShowed;

#if UNITY_EDITOR
private void OnValidate() {
if (!canvas)
canvas = GetComponent<Canvas>();
if (!cg)
cg = GetComponent<CanvasGroup>();
}
#endif

private void Awake() {
cg.alpha = 0.0f;
}
Expand All @@ -28,13 +39,17 @@ public void SetText(string text) {
public void Show() {
isShowed = true;

canvas.sortingOrder = canvasSortOrder++;

LeanTween.cancel(gameObject, false);
LeanTweenEx.ChangeAlpha(cg, 1.0f, 0.1f).setEase(LeanTweenType.easeInOutQuad);
}

public void Hide() {
isShowed = false;

--canvasSortOrder;

LeanTween.cancel(gameObject, false);
LeanTweenEx.ChangeAlpha(cg, 0.0f, 0.1f).setEase(LeanTweenType.easeInOutQuad);
}
Expand Down

0 comments on commit 2348273

Please sign in to comment.