zip压缩加载测试
This commit is contained in:
103
Assets/Main/Script/Runtime/LasterDoMain/IntroPanel.cs
Normal file
103
Assets/Main/Script/Runtime/LasterDoMain/IntroPanel.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Stary.Evo;
|
||||
using Stary.Evo.AudioCore;
|
||||
using Stary.Evo.InformationSave;
|
||||
using Stary.Evo.UIFarme;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using YooAsset;
|
||||
|
||||
namespace Main
|
||||
{
|
||||
public class IntroPanel : BasePanel
|
||||
{
|
||||
static readonly string path = "IntroPanel";
|
||||
|
||||
private Image intro;
|
||||
|
||||
private LocalTransformInfo transformInfo;
|
||||
|
||||
public IntroPanel()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public override void Initialize(GameObject panelGo)
|
||||
{
|
||||
base.Initialize(panelGo);
|
||||
|
||||
intro = activePanel.transform.Find("Intro").GetComponent<Image>();
|
||||
transformInfo = activePanel.transform.GetComponent<LocalTransformInfo>();
|
||||
intro.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public override void OnEnter()
|
||||
{
|
||||
base.OnEnter();
|
||||
|
||||
this.RegisterEvent<IntroType, string, string>(IntroType.IntroSprite, OnClickPreviousIntro);
|
||||
this.RegisterEvent<IntroType, RuntimeAnimatorController, string>(IntroType.IntroAnimation, OnAddAnimation);
|
||||
this.RegisterEvent<IntroType, string, string>(IntroType.IntroAudio, OnClickPreviousIntroAudio);
|
||||
}
|
||||
|
||||
public override void OnExit(float delay = 0)
|
||||
{
|
||||
base.OnExit(delay);
|
||||
intro.sprite = null;
|
||||
intro.gameObject.SetActive(false);
|
||||
this.UnRegisterEvent<IntroType, string, string>(IntroType.IntroSprite, OnClickPreviousIntro);
|
||||
this.UnRegisterEvent<IntroType, string, string>(IntroType.IntroAudio, OnClickPreviousIntroAudio);
|
||||
this.UnRegisterEvent<IntroType, RuntimeAnimatorController, string>(IntroType.IntroAnimation, OnAddAnimation);
|
||||
var animator = intro.transform.GetComponent<Animator>();
|
||||
if (animator != null)
|
||||
{
|
||||
GameObject.Destroy(animator);
|
||||
}
|
||||
}
|
||||
|
||||
public async void OnAddAnimation(RuntimeAnimatorController animatorController, string desc)
|
||||
{
|
||||
var animator = intro.transform.GetOrAddComponent<Animator>();
|
||||
animator.runtimeAnimatorController = animatorController;
|
||||
|
||||
intro.SetNativeSize();
|
||||
intro.gameObject.SetActive(true);
|
||||
transformInfo.Set(desc);
|
||||
}
|
||||
|
||||
public async void OnClickPreviousIntro(string spriteName, string desc)
|
||||
{
|
||||
var handle= YooAssets.LoadAssetAsync<Sprite>(spriteName);
|
||||
await handle.Task;
|
||||
intro.sprite = handle.GetAssetObject<Sprite>();
|
||||
intro.SetNativeSize();
|
||||
intro.gameObject.SetActive(true);
|
||||
transformInfo.Set(desc);
|
||||
}
|
||||
|
||||
public async void OnClickPreviousIntroAudio(string auid, string desc)
|
||||
{
|
||||
var info = await this.GetData<IAudioTableData>().GetAudioClipToUISprite(auid);
|
||||
AudioCoreManager.PlayVoice(new AudioData()
|
||||
{
|
||||
clip = info.audioClip,
|
||||
});
|
||||
SetIntroSprite(info.sprite, desc);
|
||||
}
|
||||
private void SetIntroSprite(Sprite sprite, string desc)
|
||||
{
|
||||
|
||||
intro.sprite = sprite;
|
||||
intro.SetNativeSize();
|
||||
intro.gameObject.SetActive(true);
|
||||
transformInfo.Set(desc);
|
||||
}
|
||||
public enum IntroType
|
||||
{
|
||||
IntroSprite,
|
||||
IntroAudio,
|
||||
IntroAnimation
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user