_xiaofang/xiaofang/Assets/Script/hylScripts/ScreenRed.cs

41 lines
864 B
C#
Raw Normal View History

2024-12-06 15:15:30 +08:00
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); // <20>ȴ<EFBFBD>300<30><30><EFBFBD><EFBFBD>
red.color = defaultColor;
}
}