From 2da1f06bcb3492b3967674c0ab780413c0997b3e Mon Sep 17 00:00:00 2001 From: ZhangBiao Date: Thu, 8 Apr 2021 15:36:27 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=87=AA=E9=80=89=E5=AE=9D=E7=AE=B1?= =?UTF-8?q?=E3=80=91=E8=BF=98=E6=98=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 89c81798400e614bebfd5d89948ac3fb2ed9b736) --- .../UI/RewardBox/RewardBoxPanel.prefab | 27 ++++++++++++-- .../~Lua/Modules/RewardBox/RewardBoxPanel.lua | 36 +++++++++++-------- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/Assets/ManagedResources/Prefabs/UI/RewardBox/RewardBoxPanel.prefab b/Assets/ManagedResources/Prefabs/UI/RewardBox/RewardBoxPanel.prefab index f5e26c413f..3646502d12 100644 --- a/Assets/ManagedResources/Prefabs/UI/RewardBox/RewardBoxPanel.prefab +++ b/Assets/ManagedResources/Prefabs/UI/RewardBox/RewardBoxPanel.prefab @@ -1129,6 +1129,7 @@ GameObject: - component: {fileID: 5247935428401062656} - component: {fileID: 4469237718377244165} - component: {fileID: 8598351590046701246} + - component: {fileID: 5041373642146469403} m_Layer: 5 m_Name: selectBtn m_TagString: Untagged @@ -1150,9 +1151,9 @@ RectTransform: m_Father: {fileID: 637834703727152052} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 135, y: -50} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: -315, y: 0} m_SizeDelta: {x: 130, y: 130} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &4469237718377244165 @@ -1192,6 +1193,26 @@ MonoBehaviour: m_FillClockwise: 1 m_FillOrigin: 0 m_UseSpriteMesh: 0 +--- !u!114 &5041373642146469403 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2749384115574582686} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1679637790, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreLayout: 1 + m_MinWidth: -1 + m_MinHeight: -1 + m_PreferredWidth: -1 + m_PreferredHeight: -1 + m_FlexibleWidth: -1 + m_FlexibleHeight: -1 + m_LayoutPriority: 1 --- !u!1 &2790987625313459491 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/ManagedResources/~Lua/Modules/RewardBox/RewardBoxPanel.lua b/Assets/ManagedResources/~Lua/Modules/RewardBox/RewardBoxPanel.lua index 687ef47799..a72bf2c342 100644 --- a/Assets/ManagedResources/~Lua/Modules/RewardBox/RewardBoxPanel.lua +++ b/Assets/ManagedResources/~Lua/Modules/RewardBox/RewardBoxPanel.lua @@ -47,11 +47,6 @@ function RewardBoxPanel:InitComponent() this.ScrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5) this.ScrollView.moveTween.MomentumAmount = 1 this.ScrollView.moveTween.Strength = 2 - - this.selectList ={} - for n = 1, this.selectBar.transform.childCount-1 do--设置当前页签 - table.insert(this.selectList,this.selectBar.transform:GetChild(n).gameObject) - end end --绑定事件(用于子类重写) function RewardBoxPanel:BindEvent() @@ -83,16 +78,6 @@ function RewardBoxPanel:BindEvent() Util.AddClick(this.btnOk, function() this:ClosePanel() end) - for i = 1, #this.selectList do - Util.AddClick(this.selectList[i],function() - curId = 0 - tagNum = i - RewardBoxPanel:SetGiftData() - this.selectBtn.transform:SetParent(this.selectList[i].transform) - this.selectBtn.transform.localPosition = Vector3.zero - this.selectBtn.transform.localScale = Vector3.one - end) - end end --添加事件监听(用于子类重写) @@ -117,6 +102,25 @@ function RewardBoxPanel:OnOpen(...) this.scroll.gameObject:GetComponent("RectTransform").sizeDelta = #this.rewardGroup ~= 1 and Vector2.New(940, 836.8) or Vector2.New(940, 900) this.scroll.gameObject:GetComponent("RectTransform").anchoredPosition = #this.rewardGroup ~= 1 and Vector2.New(0, 376) or Vector2.New(0, 444) this.ScrollView.gameObject:GetComponent("RectTransform").sizeDelta = #this.rewardGroup ~= 1 and Vector2.New(940, 830) or Vector2.New(940, 900) + + this.selectList ={} + for n = 1, this.selectBar.transform.childCount-1 do--设置当前页签 + table.insert(this.selectList,this.selectBar.transform:GetChild(n).gameObject) + end + this.selectBtn.transform:SetParent(this.selectList[1].transform) + this.selectBtn.transform.localPosition = Vector3.zero + this.selectBtn.transform.localScale = Vector3.one + for i = 1, #this.selectList do + Util.AddOnceClick(this.selectList[i],function() + curId = 0 + tagNum = i + RewardBoxPanel:SetGiftData() + this.selectBtn.transform:SetParent(this.selectList[i].transform) + this.selectBtn.transform.localPosition = Vector3.zero + this.selectBtn.transform.localScale = Vector3.one + end) + end + end -- 打开,重新打开时回调 @@ -238,6 +242,7 @@ end --界面关闭时调用(用于子类重写) function RewardBoxPanel:OnClose() + this.selectList ={} curNum = 1 this.selectBtn.transform.parent = this.selectBar.transform:GetChild(0).transform this.selectBtn.transform.localPosition = Vector3.zero @@ -246,6 +251,7 @@ end --界面销毁时调用(用于子类重写) function RewardBoxPanel:OnDestroy() + this.selectList ={} itemIconList={} goList = {} end