using System.Collections; using System.Collections.Generic; using UnityEngine; using DG.Tweening; using System; namespace DisComputer { /// /// @func 显示隐藏动效 /// @author lz /// @date 2020/05/27 /// 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); } } }