This commit is contained in:
2025-09-04 11:43:35 +08:00
parent 8872c20cf2
commit 60e4ef39ed
707 changed files with 1498 additions and 29309 deletions

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class SplashScreen : MonoBehaviour
{
private Image image;
async void Start()
{
image = GetComponentInChildren<Image>();
// 初始完全透明
image.color = new Color(1, 1, 1, 0);
// 渐显效果2秒
await Fade(0, 1, 0.5f);
// 保持显示原2秒等待
await UniTask.Delay(TimeSpan.FromSeconds(1));
// 渐隐效果1秒
await Fade(1, 0, 0.5f);
await SceneManager.LoadSceneAsync(1);
if (transform != null)
Destroy(gameObject);
}
private async UniTask Fade(float startAlpha, float endAlpha, float duration)
{
float elapsed = 0f;
while (elapsed < duration)
{
float alpha = Mathf.Lerp(startAlpha, endAlpha, elapsed / duration);
image.color = new Color(1, 1, 1, alpha);
elapsed += Time.deltaTime;
await UniTask.Yield();
}
image.color = new Color(1, 1, 1, endAlpha);
}
}