_xiaofang/xiaofang/Assets/Script/hylScripts/ScreenRed.cs
2024-12-06 15:15:30 +08:00

41 lines
864 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
public class ScreenRed : MonoBehaviour
{
public static ScreenRed instance;
private Image red;
public Color redColor;
private Color defaultColor;
// Start is called before the first frame update
void Start()
{
instance = this;
red = GameObject.Find("Canvas/ScreenRed").GetComponent<Image>();
defaultColor = red.color;
}
// Update is called once per frame
void Update()
{
}
public async void ShowRed()
{
await ScreenIsRedingAsync();
}
private async Task ScreenIsRedingAsync()
{
red.color = Color.Lerp(defaultColor, redColor, 0.5f);
await Task.Delay(300); // µÈ´ý300ºÁÃë
red.color = defaultColor;
}
}