You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.6 KiB
79 lines
1.6 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using DG.Tweening;
|
|
using System;
|
|
|
|
namespace DisComputer
|
|
{
|
|
/// <summary>
|
|
/// @func 显示隐藏动效
|
|
/// @author lz
|
|
/// @date 2020/05/27
|
|
/// </summary>
|
|
public class UIShowOrHide : MonoBehaviour
|
|
{
|
|
|
|
|
|
|
|
[Header("显示系数")]
|
|
public Vector3 showV3;
|
|
|
|
[Header("隐藏系数")]
|
|
public Vector3 hideV3;
|
|
|
|
[Header("动效时间")]
|
|
public float interval = 0.35f;
|
|
|
|
public bool isShow = false;
|
|
|
|
|
|
public Action showFinishHandle;
|
|
|
|
public Action hideFinishHandle;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void OnShow(object data=null)
|
|
{
|
|
this.gameObject.SetActive(true);
|
|
|
|
Tween show = this.transform.DOScale(showV3, interval);
|
|
show.SetEase(Ease.InSine);
|
|
show.OnComplete(()=> {
|
|
isShow = true;
|
|
showFinishHandle?.Invoke();
|
|
});
|
|
}
|
|
|
|
public virtual void OnHide()
|
|
{
|
|
if (!this.gameObject.activeSelf)
|
|
return;
|
|
|
|
Tween hideTw = this.transform.DOScale(hideV3, interval);
|
|
hideTw.SetEase(Ease.InSine);
|
|
hideTw.OnComplete(()=>
|
|
{
|
|
this.gameObject.SetActive(false);
|
|
isShow = false;
|
|
hideFinishHandle?.Invoke();
|
|
});
|
|
}
|
|
|
|
public void InitScale()
|
|
{
|
|
this.transform.DOScale(hideV3, 0);
|
|
this.gameObject.SetActive(false);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|