45 lines
1.0 KiB
C#
45 lines
1.0 KiB
C#
using UnityEngine;
|
|
using WI;
|
|
using TMPro;
|
|
using System.Collections;
|
|
using UnityEngine.UI;
|
|
|
|
public class Panel_ToolBarAlarm : PanelBase
|
|
{
|
|
private TextMeshProUGUI Content;
|
|
private Image Image_Icon;
|
|
public float fadeTime;
|
|
public Vector3 offset;
|
|
|
|
public override void AfterAwake()
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
public void ActiveAlarm(Vector3 pos, string value, bool isSuccess)
|
|
{
|
|
transform.position = new Vector3(pos.x + offset.x, pos.y + offset.y, 0);
|
|
gameObject.SetActive(true);
|
|
|
|
Image_Icon.color = isSuccess ? Color.green : Color.red;
|
|
Content.SetText(value);
|
|
|
|
StartCoroutine(ScaleDown());
|
|
}
|
|
private IEnumerator ScaleDown()
|
|
{
|
|
float timer = 0f;
|
|
float percent = 0f;
|
|
|
|
while (percent < 1)
|
|
{
|
|
timer += Time.deltaTime;
|
|
percent = timer / fadeTime;
|
|
transform.localScale = Vector3.Lerp(transform.localScale, Vector3.one, percent);
|
|
|
|
yield return null;
|
|
}
|
|
gameObject.SetActive(false);
|
|
|
|
}
|
|
}
|