|
|
@ -30,6 +30,7 @@ public class UIPanel : MonoBehaviour |
|
|
|
private RectTransform rectTransform; |
|
|
|
private CanvasGroup canvasGroup; |
|
|
|
private Vector3 originalPos; |
|
|
|
private bool isShowing = false; |
|
|
|
|
|
|
|
void Awake () |
|
|
|
{ |
|
|
@ -58,10 +59,13 @@ public class UIPanel : MonoBehaviour |
|
|
|
setShowState(); |
|
|
|
else |
|
|
|
setHideState(); |
|
|
|
pauseGame(); |
|
|
|
} |
|
|
|
|
|
|
|
public void showPanel() |
|
|
|
{ |
|
|
|
// if (isShowing)
|
|
|
|
// return;
|
|
|
|
float startAlpha = 0f; |
|
|
|
float endAlpha = 1f; |
|
|
|
Vector3 startPos = originalPos; |
|
|
@ -92,11 +96,13 @@ public class UIPanel : MonoBehaviour |
|
|
|
canvasGroup.alpha = startAlpha + (endAlpha-startAlpha)*fadeCurve.Evaluate(val); |
|
|
|
rectTransform.anchoredPosition3D = startPos + (endPos-startPos)*showCurve.Evaluate(val); |
|
|
|
transform.localScale = startScale + (endScale-startScale)*showCurve.Evaluate(val); |
|
|
|
}).setOnComplete(setShowState); |
|
|
|
}).setOnComplete(setShowState).setIgnoreTimeScale(true); |
|
|
|
} |
|
|
|
|
|
|
|
public void hidePanel() |
|
|
|
{ |
|
|
|
// if (!isShowing)
|
|
|
|
// return;
|
|
|
|
float startAlpha = 1f; |
|
|
|
float endAlpha = 0f; |
|
|
|
Vector3 startPos = originalPos; |
|
|
@ -127,7 +133,7 @@ public class UIPanel : MonoBehaviour |
|
|
|
canvasGroup.alpha = startAlpha + (endAlpha-startAlpha)*fadeCurve.Evaluate(val); |
|
|
|
rectTransform.anchoredPosition3D = startPos + (endPos-startPos)*hideCurve.Evaluate(val); |
|
|
|
transform.localScale = startScale + (endScale-startScale)*hideCurve.Evaluate(val); |
|
|
|
}).setOnComplete(setHideState); |
|
|
|
}).setOnComplete(setHideState).setIgnoreTimeScale(true); |
|
|
|
} |
|
|
|
|
|
|
|
public void setShowState() |
|
|
@ -137,6 +143,7 @@ public class UIPanel : MonoBehaviour |
|
|
|
canvasGroup.alpha = 1f; |
|
|
|
rectTransform.anchoredPosition3D = originalPos; |
|
|
|
transform.localScale = Vector3.one; |
|
|
|
isShowing = true; |
|
|
|
} |
|
|
|
|
|
|
|
public void setHideState() |
|
|
@ -144,6 +151,7 @@ public class UIPanel : MonoBehaviour |
|
|
|
canvasGroup.interactable = false; |
|
|
|
canvasGroup.blocksRaycasts = false; |
|
|
|
canvasGroup.alpha = 0f; |
|
|
|
isShowing = false; |
|
|
|
} |
|
|
|
|
|
|
|
public void quitApplication() |
|
|
@ -154,5 +162,16 @@ public class UIPanel : MonoBehaviour |
|
|
|
public void startGame() |
|
|
|
{ |
|
|
|
NotificationServer.notify("show GameUI"); |
|
|
|
unpauseGame(); |
|
|
|
} |
|
|
|
|
|
|
|
public void pauseGame() |
|
|
|
{ |
|
|
|
Time.timeScale = 0f; |
|
|
|
} |
|
|
|
|
|
|
|
public void unpauseGame() |
|
|
|
{ |
|
|
|
Time.timeScale = 1f; |
|
|
|
} |
|
|
|
} |