GQ_Communicate/GQ_URP/GQ/Assets/script/筛选/CalendarDetails.cs

131 lines
3.1 KiB
C#

using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// 显示区
/// </summary>
public class CalendarDetails : MonoBehaviour
{
public static CalendarDetails Inst;
//public GameObject scrollView;
//public GameObject prefab;
//public Transform Content;
public Image img_bg;
public Image img;
Button img_bt;
public GameObject bg;
public GameObject preform;
public Transform content;
RectTransform content_ret;
GridLayoutGroup content_grid;
public Button cls_bt;
public Vector3 vector3;
private void Awake()
{
Inst = this;
content_ret = content.GetComponent<RectTransform>();
content_grid = content.GetComponent<GridLayoutGroup>();
vector3 = img_bg.transform.localPosition;
img_bt = img.gameObject.GetComponent<Button>();
close();
}
// Start is called before the first frame update
void Start()
{
cls_bt.onClick.AddListener(() =>
{
//scrollView.SetActive(true);
img_bg.gameObject.SetActive(false);
WebInteraction.Inst.setlittleXunJian();
});
img_bt.onClick.AddListener(() =>
{
if (img_bg.gameObject.activeSelf)
{
WebInteraction.Inst.setlittleXunJian();
setlittle();
}
});
}
public void img_btOnClick(Sprite sprite)
{
//if (img_bg.transform.localScale.x > 0.6)
if (img_bg.gameObject.activeSelf)
{
if (sprite == img.sprite)
{
WebInteraction.Inst.setlittleXunJian();
setlittle();
}
else
{
img.sprite = sprite;
}
}
else
{
WebInteraction.Inst.setbigXunJian();
setbig(sprite);
}
}
// Update is called once per frame
void Update()
{
GameManager.Inst.AdaptiveHight(content.gameObject, content, content_ret, content_grid);
}
public void open()
{
gameObject.SetActive(true);
//img_bg.gameObject.SetActive(true);
bg.gameObject.SetActive(true);
}
public void init()
{
img_bg.transform.localPosition = (vector3);
img_bg.transform.localScale = (Vector3.one * 0.5f);
gameObject.SetActive(true);
img_bg.gameObject.SetActive(false);
bg.gameObject.SetActive(false);
}
public void close()
{
img_bg.gameObject.SetActive(false);
bg.gameObject.SetActive(false);
gameObject.SetActive(false);
}
public void setbig(Sprite sprite)
{
img.sprite = sprite;
img_bg.gameObject.SetActive(true);
DOTween.Kill(img_bg, false);
img_bg.transform.DOLocalMove(Vector3.right * 190f, 0.5f);
img_bg.transform.DOScale(Vector3.one, 0.5f);
}
public void setlittle()
{
img_bg.gameObject.SetActive(false);
//DOTween.Kill(img_bg, false);
//img_bg.transform.DOLocalMove(vector3, 0.5f);
//img_bg.transform.DOScale(Vector3.one * 0.5f, 0.5f);
}
}