Cute_demon_attacks/meng_yao/Assets/script/JumpScene/GameSceneBtn.cs
2024-12-24 17:44:00 +08:00

63 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using DG.Tweening;
public class GameSceneBtn : MonoBehaviour
{
public static Action OnSceneMouseBTN;
private SceneSpriteAniationPro aniationPro;
float time;
public GameObject gotoscene;
public GameObject nowScene;
// Start is called before the first frame update
void Start()
{
OnSceneMouseBTN += JUmpScem;
aniationPro = GetComponent<SceneSpriteAniationPro>();
}
private void OnMouseDown()
{
transform.DOScale(new Vector3(0.5f, 0.5f, 0.5f), 0.3f).SetEase(Ease.OutBack);
StartCoroutine("Magnify");
}
IEnumerator Magnify()
{
transform.DOScale(Vector3.one, 0.5f).SetEase(Ease.OutBack);
OnSceneMouseBTN();
return null;
}
void JUmpScem()
{
gotoscene.SetActive(true);
nowScene.SetActive(false);
}
private void Update()
{
time += Time.deltaTime;
if (time > 5)
{
aniationPro.SetAni(0);
aniationPro.changeAni(false);
}
if (time > 7)
{
time = 0;
aniationPro.changeAni(true);
}
}
private void OnDestroy()
{
OnSceneMouseBTN -= JUmpScem;
}
}