chicken_dy/Assets/Scripts/UI/CustomControl/ButtonSlot.cs

54 lines
1.2 KiB
C#
Raw Normal View History

2022-02-09 08:35:01 +00:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
2022-02-14 11:17:52 +00:00
using DG.Tweening;
2022-02-09 08:35:01 +00:00
public class ButtonSlot : MonoBehaviour
{
public Action<int> DelClick;
2022-02-14 11:17:52 +00:00
[SerializeField] RectTransform mRctContent;
2022-02-09 08:35:01 +00:00
[SerializeField] GameObject mGobCurrentSign;
[SerializeField] Image mImgSound;
private int mIndex;
private void Awake()
{
Button tBtn = GetComponent<Button>();
UIUtils.BindBtn(tBtn, OnClick);
}
public void Init(int pIndex)
{
mIndex = pIndex;
mImgSound.gameObject.SetActive(false);
}
public void ShowCurrent(bool pShow)
{
mGobCurrentSign.SetActive(pShow);
}
public void SetSoundPic(Sprite pSoundPic)
{
mImgSound.gameObject.SetActive(true);
mImgSound.sprite = pSoundPic;
}
2022-02-14 11:17:52 +00:00
public void RiseUp()
{
Sequence tRiseSeq = DOTween.Sequence();
tRiseSeq.Append(mRctContent.DOAnchorPosY(70, 0.3f));
tRiseSeq.AppendInterval(0.5f);
tRiseSeq.Append(mRctContent.DOAnchorPosY(0, 0.3f));
tRiseSeq.Play();
}
2022-02-09 08:35:01 +00:00
private void OnClick()
{
DelClick?.Invoke(mIndex);
}
}