Cute_demon_attacks/meng_yao/Assets/script/TanChuang/GgTanchuang.cs
2024-12-29 21:25:01 +08:00

94 lines
2.8 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
public class GgTanchuang : mount
{
public Button Ggbtn;
public Image hdtxbg;
public RectTransform GgPanel;
Vector3 Deflate = new Vector3(0.5f, 0.5f, 0.5f);
public Sprite GgglDownsp;
public Sprite GgglUpsp;
public Transform canvas;
// Start is called before the first frame update
void Start()
{
Ggbtn.onClick.AddListener(Display_pop_up_window);
// canvas = GameObject.Find("MainCanvas").transform;
//GgPanel = this.GetComponent<RectTransform>();
}
private async void Display_pop_up_window()
{
GgPanel.DOScale(Deflate, 0.3f).SetEase(Ease.OutBack);
hdtxbg.sprite = GgglDownsp;
StartCoroutine(Magnify(GgPanel));
NoticeIndfo noticeIndfo = await Scene_main_jiekou.instance.NoticeInfos(1);
string n;
if (noticeIndfo.Data.exist == 0)
{
n = "";
}
else
{
n = noticeIndfo.Data.notice.content;
}
List<BoxType> boxTypes = new List<BoxType>();
boxTypes.Add(new BoxType { Name = "", prompt = "", Type = 9,widthnum =700,WidthHeight =650 ,content = n }) ;
boxTypes.Add(new BoxType { Name = "", prompt = "确认", Type = 11 });
GameObject gameObject = add_pop_up();
gameObject.transform.SetParent(canvas);
gameObject.transform.position = new Vector3(Screen.width/2,Screen.height/2,0);
RectTransform re = gameObject.GetComponent<RectTransform>();
re.offsetMin = new Vector2(0, 0);
re.offsetMax = new Vector2(0, 0);
re.localScale = Vector3.one;
//设置他的recttransform使他能够完全填满整个屏幕
gameObject.GetComponent<input_box_pop_up_window>().minHeight = 800;//设置最低高度
gameObject.GetComponent<input_box_pop_up_window>().setScrollMode(0);//设置滚动模式为滚动
//gameObject.GetComponent<input_box_pop_up_window>().setScrollMode(0);//设置滚动模式为自动填充
List<GameObject> gameObjects = gameObject.GetComponent<input_box_pop_up_window>().updateUI(boxTypes, noticeIndfo.Data.notice.title);//测试输入框回调处理
gameObjects[1].GetComponent<input_box_pop_up_window_item>().register_click(async (BoxType boxType, int type) =>//登录确定或取消
{
if (type == 1)
{
gameObject.GetComponent<input_box_pop_up_window>().destroy();
}
});
}
IEnumerator Magnify(RectTransform allpanel)
{
Debug.Log("执行公告弹窗协程");
allpanel.DOScale(Vector3.one, 0.8f).SetEase(Ease.OutBack).OnComplete(() =>
{
hdtxbg.sprite = GgglUpsp;
});
yield return null;
}
// Update is called once per frame
void Update()
{
}
}