From 4fda1fbb7c57b43511d0c602dcb20ab47c140232 Mon Sep 17 00:00:00 2001 From: shurongsen <1799096798@qq.com> Date: Tue, 12 Nov 2024 01:06:12 +0800 Subject: [PATCH] add --- .../preform/VerNormalPopUpWindow.prefab | 85 ++++++++++++++++++- Assets/UnityTools/script/NormalPopUpWindow.cs | 41 ++++++++- Assets/UnityTools/script/popUpsCanvas.cs | 2 + Assets/UnityTools/script/test.cs | 4 +- 4 files changed, 125 insertions(+), 7 deletions(-) diff --git a/Assets/UnityTools/preform/VerNormalPopUpWindow.prefab b/Assets/UnityTools/preform/VerNormalPopUpWindow.prefab index 4ffddc7..54ef73e 100644 --- a/Assets/UnityTools/preform/VerNormalPopUpWindow.prefab +++ b/Assets/UnityTools/preform/VerNormalPopUpWindow.prefab @@ -311,7 +311,7 @@ RectTransform: m_Children: - {fileID: 3145268759521990836} m_Father: {fileID: 3145268760560762038} - m_RootOrder: 0 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -631,6 +631,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: + - {fileID: 8974144926583687908} - {fileID: 3145268760064504697} m_Father: {fileID: 0} m_RootOrder: 0 @@ -751,3 +752,85 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Mode: 0 + Title: {fileID: 0} + contentList: {fileID: 3145268759409834734} +--- !u!1 &5748990112681471550 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8974144926583687908} + - component: {fileID: 8360380688318706704} + - component: {fileID: 8281317698932617217} + m_Layer: 5 + m_Name: Text (Legacy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &8974144926583687908 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5748990112681471550} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 3145268760560762038} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &8360380688318706704 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5748990112681471550} + m_CullTransparentMesh: 1 +--- !u!114 &8281317698932617217 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5748990112681471550} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 32 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: "\u6807\u9898" diff --git a/Assets/UnityTools/script/NormalPopUpWindow.cs b/Assets/UnityTools/script/NormalPopUpWindow.cs index 40f9e32..3f2febf 100644 --- a/Assets/UnityTools/script/NormalPopUpWindow.cs +++ b/Assets/UnityTools/script/NormalPopUpWindow.cs @@ -2,11 +2,18 @@ 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 { @@ -25,13 +32,39 @@ public class NormalPopUpWindow : MonoBehaviour Debug.Log(GetComponent().minWidth); } private int minimumWidth = -1;//最小宽度 - - void Start() + + 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; } - // Update is called once per frame - void Update() + 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; } } diff --git a/Assets/UnityTools/script/popUpsCanvas.cs b/Assets/UnityTools/script/popUpsCanvas.cs index 846062d..95bc512 100644 --- a/Assets/UnityTools/script/popUpsCanvas.cs +++ b/Assets/UnityTools/script/popUpsCanvas.cs @@ -9,6 +9,8 @@ public class popUpsCanvas : MonoBehaviour public GameObject VerNormalPopUpWindow;//普通弹窗 public GameObject tabPopUpWindow;//选项卡弹窗 + public GameObject buttonItem;//按钮窗体 + private void Awake() { popUpsCanvasobj = this; diff --git a/Assets/UnityTools/script/test.cs b/Assets/UnityTools/script/test.cs index 0b49492..5279ff9 100644 --- a/Assets/UnityTools/script/test.cs +++ b/Assets/UnityTools/script/test.cs @@ -8,7 +8,7 @@ public class test : MonoBehaviour void Start() { GameObject gameObject = popUpsCanvas.popUpsCanvasobj.addPopUp(popUpsCanvas.popUpsCanvasobj.VerNormalPopUpWindow);//测试 - gameObject.GetComponent().setMinimumHeight(200); - Debug.Log(gameObject); + List light = new List(); + gameObject.GetComponent().newPopup(light,"测试标题"); } }