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