更改文件架构
This commit is contained in:
50
Packages/Common~/Scripts/UX/BlackScreen/BlackScreen.cs
Normal file
50
Packages/Common~/Scripts/UX/BlackScreen/BlackScreen.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using DG.Tweening;
|
||||
using UnityEngine.Events;
|
||||
using Cysharp.Threading.Tasks;
|
||||
namespace BITKit.UX
|
||||
{
|
||||
public class BlackScreen : MonoBehaviour
|
||||
{
|
||||
[Header(Constant.Header.Components)]
|
||||
public UIDocument document;
|
||||
VisualElement root;
|
||||
void Start()
|
||||
{
|
||||
root = document.rootVisualElement;
|
||||
Data.AddListener<UnityAction>("BlackScreen", x =>
|
||||
{
|
||||
CrossFade(x, 0.32f);
|
||||
});
|
||||
root.SetOpacity(1);
|
||||
root.SetActive(false);
|
||||
}
|
||||
void CrossFade(UnityAction action, float duration = 1f)
|
||||
{
|
||||
Sequence sequence = DOTween.Sequence();
|
||||
var enterTween = DOTween.To(root.GetOpacity, root.SetOpacity, 1, duration);
|
||||
var exitTween = DOTween.To(root.GetOpacity, root.SetOpacity, 0, duration);
|
||||
|
||||
sequence.Append(enterTween);
|
||||
sequence.AppendInterval(0.1f);
|
||||
sequence.Append(exitTween);
|
||||
|
||||
enterTween.onComplete += () =>
|
||||
{
|
||||
action.Invoke();
|
||||
};
|
||||
sequence.onComplete += () =>
|
||||
{
|
||||
root.SetActive(false);
|
||||
};
|
||||
|
||||
root.SetActive(true);
|
||||
root.SetOpacity(0);
|
||||
|
||||
sequence.Play();
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/UX/BlackScreen/BlackScreen.cs.meta
Normal file
11
Packages/Common~/Scripts/UX/BlackScreen/BlackScreen.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e93f74931ac425c45953585809454f41
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user