using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.UIElements; public enum ModeEnum//窗口模式枚举 { autofill = 0,//自动填充 fixedSize = 1,//固定大小 } public class BoxTypeItem//注册窗体物体类 { public int type;//窗体类型 public string title = "测试窗体标题";//窗体标题 public string content = "测试窗体内容";//窗体内容 } public class NormalPopUpWindow : MonoBehaviour { public ModeEnum Mode = ModeEnum.autofill;//窗口模式 public void setMinimumHeight(int value) { minimumHeight = value; GetComponent().minHeight = minimumHeight; Debug.Log(GetComponent().minHeight); } private int minimumHeight = -1;//最小高度 public void setMinimumWidth(int value) { minimumWidth = value; GetComponent().minWidth = minimumWidth; Debug.Log(GetComponent().minWidth); } private int minimumWidth = -1;//最小宽度 public GameObject Title;//窗口标题对象 public GameObject contentList;//窗口内容对象 private List gameObjects = new List();//注册的全部窗体 public List newPopup(List my_boxTypes, string title = "标题")//ui更新返回数组 { List gameObjectitem = new List(); Title.GetComponent().text = title; float posY = 0; foreach (BoxTypeItem boxType in my_boxTypes) { GameObject gameObject = AddItem(boxType); gameObjects.Add(gameObject); gameObjectitem.Add(gameObject); posY += gameObject.GetComponent().sizeDelta.y; } //scroll_view.GetComponent().verticalNormalizedPosition = 1.0f; return gameObjectitem; } private GameObject AddItem(BoxTypeItem boxType) { GameObject ranking_list_item = null; switch (boxType.type) { case 0: ranking_list_item = Instantiate(popUpsCanvas.popUpsCanvasobj.buttonItem, contentList.transform); break; } ranking_list_item.GetComponent().UpdateBoxTypeItem(boxType); return ranking_list_item; } }