gameplay所有基本功能都装了,加入了全局警告。加入飘字等各种东西。
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections;
|
||||
|
||||
public class skillWarn_prefab : MonoBehaviour
|
||||
{
|
||||
[Header("Skill Warning")]
|
||||
public Image warn_btm_img;
|
||||
public Text warn_txt;
|
||||
[Header("color sprite")]
|
||||
public Sprite warn_btm_red;
|
||||
public Sprite warn_btm_yellow;
|
||||
public Sprite warn_btm_green;
|
||||
public Sprite warn_btm_blue;
|
||||
|
||||
[Header("Fade Settings")]
|
||||
public float waitDuration = 2.0f; // 等待几秒开始渐隐
|
||||
public float fadeDuration = 1.0f; // 渐隐持续时间
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartCoroutine(FadeRoutine());
|
||||
}
|
||||
|
||||
private IEnumerator FadeRoutine()
|
||||
{
|
||||
// Wait before fading
|
||||
yield return new WaitForSeconds(waitDuration);
|
||||
|
||||
float elapsedTime = 0f;
|
||||
Color originalImgColor = warn_btm_img != null ? warn_btm_img.color : Color.white;
|
||||
Color originalTxtColor = warn_txt != null ? warn_txt.color : Color.white;
|
||||
|
||||
while (elapsedTime < fadeDuration)
|
||||
{
|
||||
elapsedTime += Time.deltaTime;
|
||||
float alpha = Mathf.Clamp01(1f - (elapsedTime / fadeDuration));
|
||||
|
||||
if (warn_btm_img != null)
|
||||
{
|
||||
Color newColor = originalImgColor;
|
||||
newColor.a = originalImgColor.a * alpha;
|
||||
warn_btm_img.color = newColor;
|
||||
}
|
||||
|
||||
if (warn_txt != null)
|
||||
{
|
||||
Color newColor = originalTxtColor;
|
||||
newColor.a = originalTxtColor.a * alpha;
|
||||
warn_txt.color = newColor;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user