From 34cff550fa54aa9d6ebacf28618a7321dbcd4328 Mon Sep 17 00:00:00 2001 From: bob <605277374@qq.com> Date: Wed, 4 Jun 2025 12:12:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B9=E5=90=91=E9=94=AE=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/PlayerInputControl.inputactions | 44 +++++ .../Procedural Worlds/Packages - Install.meta | 8 + .../Gaia Pro Assets and Biomes.meta | 8 + Assets/Resources/Fgui/Common/Common_fui.bytes | Bin 30325 -> 30345 bytes Assets/Resources/Fgui/Main/Main_fui.bytes | Bin 9481 -> 9835 bytes Assets/Scenes/StartUp.unity | 62 ------- Assets/Scripts/Fishing/PlayerInputControl.cs | 44 +++++ Assets/Scripts/Startup/App.cs | 3 +- .../UI/Home/Pages/HomeMainPage.Designer.cs | 2 + Assets/Scripts/UI/Home/Pages/HomeMainPage.cs | 32 +++- Assets/Scripts/Utils/ButtonNavigate.cs | 164 ++++++++++++++++++ Assets/Scripts/Utils/ButtonNavigate.cs.meta | 3 + .../Utils/Extends/FairyGUIExtensions.cs | 13 ++ .../Utils/Extends/FairyGUIExtensions.cs.meta | 3 + FGUIProject/assets/Common/package.xml | 2 +- .../assets/Main/Com/Home/BtnHomeMap.xml | 8 +- .../assets/Main/Com/Home/BtnHomeMedium.xml | 9 +- .../assets/Main/Com/Home/BtnHomeSmall.xml | 10 +- .../Main/Com/Home/Pages/HomeMainPage.xml | 1 + 19 files changed, 340 insertions(+), 76 deletions(-) create mode 100644 Assets/Procedural Worlds/Packages - Install.meta create mode 100644 Assets/Procedural Worlds/Packages - Install/Gaia Pro Assets and Biomes.meta create mode 100644 Assets/Scripts/Utils/ButtonNavigate.cs create mode 100644 Assets/Scripts/Utils/ButtonNavigate.cs.meta create mode 100644 Assets/Scripts/Utils/Extends/FairyGUIExtensions.cs create mode 100644 Assets/Scripts/Utils/Extends/FairyGUIExtensions.cs.meta diff --git a/Assets/PlayerInputControl.inputactions b/Assets/PlayerInputControl.inputactions index c732e6677..ed539d7fa 100644 --- a/Assets/PlayerInputControl.inputactions +++ b/Assets/PlayerInputControl.inputactions @@ -1250,6 +1250,17 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "ec9eb0c2-a2e0-47eb-ac8b-52cb0ef46101", + "path": "/rightArrow", + "interactions": "", + "processors": "", + "groups": "", + "action": "Right", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "031b930d-59b6-4a26-9dfe-97764c3e8b37", @@ -1272,6 +1283,17 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "680b36f2-5797-4257-83a7-3a498891d856", + "path": "/leftArrow", + "interactions": "", + "processors": "", + "groups": "", + "action": "Left", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "45f78626-cbf2-4e1f-904d-d82e4c2a2f41", @@ -1294,6 +1316,17 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "40501ac1-9d3e-4059-8e8f-ff7035f6e32e", + "path": "/downArrow", + "interactions": "", + "processors": "", + "groups": "", + "action": "Down", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "f1a47b3c-e79f-4ab3-86b6-fcc0a6470114", @@ -1316,6 +1349,17 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "9996c4e1-f7fb-4793-ab51-da569bdbab09", + "path": "/upArrow", + "interactions": "", + "processors": "", + "groups": "", + "action": "Up", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "393f1eb9-d10d-4cd1-87e7-ea299f92b2da", diff --git a/Assets/Procedural Worlds/Packages - Install.meta b/Assets/Procedural Worlds/Packages - Install.meta new file mode 100644 index 000000000..a19be10f5 --- /dev/null +++ b/Assets/Procedural Worlds/Packages - Install.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7be223564adbc5c41926687e7ab40afa +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Procedural Worlds/Packages - Install/Gaia Pro Assets and Biomes.meta b/Assets/Procedural Worlds/Packages - Install/Gaia Pro Assets and Biomes.meta new file mode 100644 index 000000000..403765fc3 --- /dev/null +++ b/Assets/Procedural Worlds/Packages - Install/Gaia Pro Assets and Biomes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4d84b88941db835439b793dbf6286189 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Fgui/Common/Common_fui.bytes b/Assets/Resources/Fgui/Common/Common_fui.bytes index dbf5711ab436399add1011a8b9e61160f0a45f25..4e262ff4b25703c72fdb01ac3164a0487d3a553c 100644 GIT binary patch delta 67 zcmezRhOzT4;{+SdRt7MLbKmIt&qG~@f$=xvAI9AO{}_S74Im6+Z~`$G5ElV)E)Z`H I^OV;G0GBBb-T(jq delta 40 scmeBt%lP#T;{+SdLIyC1Gv4U>&x1pPf$=xvAI99t{7&MV%RGg30TNaWp#T5? diff --git a/Assets/Resources/Fgui/Main/Main_fui.bytes b/Assets/Resources/Fgui/Main/Main_fui.bytes index e6f6fcc5bad6cbad57de60a1a57d25f2e0ce6b8d..21cf6c91e893403fd00c47002113b522e77432f7 100644 GIT binary patch delta 1342 zcmb_cU2Ke57=F&2w%>G^(ivvj&a_l5i9{?zRjJWw{d6cJT&%=yBVn>O)PK2aC2qtn z;zcRNMMKqJYs628#MQbG_Lhja7ujTElXcV2bIx>T)94*%^1SDK@B7X<=Y7s|&e7zD zH76JOst&=nDZdRhbrjadHA*obes`E&wUuV~c)&B=Ym%lBb;M?RJcK4fM49|uc)U{_ zg^6fDBaSiWcL+EH5@@2eP35LEU-5K0ZF)s7++qG)XmByGt3y4O0F_(;3iY{Me#E;> zMz)m~uxB{Y{nSN(v#9yk-nsM^zIu}{b`D(|=y^yyB3=+L>0?tiePk>zOKPGToAL~pl2>DsHg%yHNon;q zcJ}1Mh9CiFFa*W1jMg?oP=4NA(cg=picth9*Y%WOg5}ATlv7~|>i4G9>Ks7})oYCs ztQjH5^On2YYY2M!6+sv2?Ii|@yYf@&AMc>{2G^WMXrY0R8n4ztCwZrusSPG{0(y6H(3V4J_(cu<Vd{J^vjXR&-ywBxS5!A zc?%>Gt#od%wwt&m@o0;4o8vneloQdE8j|z`s!n@CMSFjY9oXIhZ+on+ZAZtR9nc)f$EkZV>FR@?Qm1`h X+riznX*h}f?Hjl4+n;$`Gh2ND*Lo{T delta 945 zcmZ`%TS$~a6#nKP-G9~96x)lq`){sTv$_DJB3u-{@rf$vFj(Du5pNngn-hVKZLzGE)v1j=rBTWA0bA>Z`kxd-h!dPT1 zF_Xo}W}k;J(i1*wBhBUDgZ(sbw$X^Wm^#wzhJbTv0nw-n@UJ3ZR3Zy|{|Qh&^R7L* zfc_N%S~=3r2_}$R@tz`E;MRSqQy3+~UOOOm>)S5JD%gkDV3-IDKP*Kwcuf z@_!vXn9(K>eUsr9!XI6*R7;+;>@w-YqQn(k#Xvm9r>XrwivG};U!hiS*IULr#uu8l zIB1>SN^`jv>6^o8%9pqfqOrA;au7r0w+6%wZjMtG%najZk~wM%h+9c!1fxmjl06`9 zCzwo$I~b!Sdr0_c!BR;>4!ann8Anjw#XYj*CF1+(RbI0ZKVagLaok_EE?0p%#TR^nr@Xe(l&e&o=JgDo@p>!SG)+9GZCcP7iO2Y}%`&Gj z1pfh^Ojyq^6QLPxgNV>a!~QXBkz0>68@AV7Bwj>E-GfT5`Gl`5)D`aTg85|lNKakI bq2tux=~hiWn|-~/rightArrow"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Right"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, { ""name"": """", ""id"": ""031b930d-59b6-4a26-9dfe-97764c3e8b37"", @@ -1360,6 +1371,17 @@ namespace NBF ""isComposite"": false, ""isPartOfComposite"": false }, + { + ""name"": """", + ""id"": ""680b36f2-5797-4257-83a7-3a498891d856"", + ""path"": ""/leftArrow"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Left"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, { ""name"": """", ""id"": ""45f78626-cbf2-4e1f-904d-d82e4c2a2f41"", @@ -1382,6 +1404,17 @@ namespace NBF ""isComposite"": false, ""isPartOfComposite"": false }, + { + ""name"": """", + ""id"": ""40501ac1-9d3e-4059-8e8f-ff7035f6e32e"", + ""path"": ""/downArrow"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Down"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, { ""name"": """", ""id"": ""f1a47b3c-e79f-4ab3-86b6-fcc0a6470114"", @@ -1404,6 +1437,17 @@ namespace NBF ""isComposite"": false, ""isPartOfComposite"": false }, + { + ""name"": """", + ""id"": ""9996c4e1-f7fb-4793-ab51-da569bdbab09"", + ""path"": ""/upArrow"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Up"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, { ""name"": """", ""id"": ""393f1eb9-d10d-4cd1-87e7-ea299f92b2da"", diff --git a/Assets/Scripts/Startup/App.cs b/Assets/Scripts/Startup/App.cs index f86232fa8..dfdc7bfdd 100644 --- a/Assets/Scripts/Startup/App.cs +++ b/Assets/Scripts/Startup/App.cs @@ -137,7 +137,8 @@ namespace NBF // UI.Inst.OpenUI(); LoadData(); UI.Inst.OpenUI(); - Fishing.Inst.Go(1); + UI.Inst.OpenUI(); + // Fishing.Inst.Go(1); // UI.Inst.OpenUI(); // UI.Inst.OpenUI(); } diff --git a/Assets/Scripts/UI/Home/Pages/HomeMainPage.Designer.cs b/Assets/Scripts/UI/Home/Pages/HomeMainPage.Designer.cs index c7706415c..77f03d174 100644 --- a/Assets/Scripts/UI/Home/Pages/HomeMainPage.Designer.cs +++ b/Assets/Scripts/UI/Home/Pages/HomeMainPage.Designer.cs @@ -13,6 +13,7 @@ namespace NBF public HomeButtonGroups OpGroup; public BottomMenu BottomMenu; + public GButton BtnTest; public override void ConstructFromXML(XML xml) { @@ -20,6 +21,7 @@ namespace NBF OpGroup = (HomeButtonGroups)GetChild("OpGroup"); BottomMenu = (BottomMenu)GetChild("BottomMenu"); + BtnTest = (GButton)GetChild("BtnTest"); OnInited(); UILanguage.TrySetComponentLanguage(this); } diff --git a/Assets/Scripts/UI/Home/Pages/HomeMainPage.cs b/Assets/Scripts/UI/Home/Pages/HomeMainPage.cs index 8f17e3cd3..c7994cbf0 100644 --- a/Assets/Scripts/UI/Home/Pages/HomeMainPage.cs +++ b/Assets/Scripts/UI/Home/Pages/HomeMainPage.cs @@ -3,16 +3,29 @@ using System.Collections.Generic; using FairyGUI; using NBC; +using UnityEngine; namespace NBF { public partial class HomeMainPage : HomePageBase { - private List _buttons = new List(); + private ButtonNavigate navigate; private void OnInited() { - _buttons.Add(OpGroup.BtnGo); + List buttons = new List(); + var children = OpGroup.GetChildren(); + foreach (var child in children) + { + if (child is GButton button) + { + buttons.Add(button); + } + } + + buttons.Add(BtnTest); + + navigate = new ButtonNavigate(buttons); } protected override void OnShow() @@ -21,6 +34,7 @@ namespace NBF UseBottomMenu(); } + protected override void OnHide() { InputManager.OnUICanceled -= OnUICanceled; @@ -37,9 +51,23 @@ namespace NBF } else if (action == InputDef.UI.Up) { + navigate.Up(); } else if (action == InputDef.UI.Down) { + navigate.Down(); + } + else if (action == InputDef.UI.Right) + { + navigate.Right(); + } + else if (action == InputDef.UI.Left) + { + navigate.Left(); + } + else if (action == InputDef.UI.Enter) + { + navigate.Click(); } } diff --git a/Assets/Scripts/Utils/ButtonNavigate.cs b/Assets/Scripts/Utils/ButtonNavigate.cs new file mode 100644 index 000000000..a198d0cbe --- /dev/null +++ b/Assets/Scripts/Utils/ButtonNavigate.cs @@ -0,0 +1,164 @@ +using System.Collections.Generic; +using FairyGUI; +using UnityEngine; + +namespace NBF +{ + public class ButtonNavigate + { + private readonly List _buttons = new List(); + private int _currentIndex = 0; + + public ButtonNavigate(List buttons, bool selectFist = true) + { + _buttons.AddRange(buttons); + if (selectFist && _buttons.Count > 0) + { + SetButtonSelect(buttons[0]); + } + } + + public void Up() + { + Navigate(Vector2.up); + } + + public void Down() + { + Navigate(Vector2.down); + } + + public void Left() + { + Navigate(Vector2.left); + } + + public void Right() + { + Navigate(Vector2.right); + } + + /// + /// 点击选中按钮 + /// + public void Click() + { + foreach (var button in _buttons) + { + if (button.selected) + { + button.Click(); + break; + } + } + } + + private void Navigate(Vector2 direction) + { + GButton current = _buttons[_currentIndex]; + Rect currentRect = GetGlobalRect(current); + + GButton bestCandidate = null; + float bestDistance = float.MaxValue; + + foreach (var candidate in _buttons) + { + if (candidate == current) continue; + + Rect candidateRect = GetGlobalRect(candidate); + + // 检查方向匹配性 + bool isDirectionMatch = false; + + if (direction == Vector2.up) // 上方向 + { + isDirectionMatch = candidateRect.yMax <= currentRect.yMin && + RectOverlapX(currentRect, candidateRect); + } + else if (direction == Vector2.down) // 下方向 + { + isDirectionMatch = candidateRect.yMin >= currentRect.yMax && + RectOverlapX(currentRect, candidateRect); + } + else if (direction == Vector2.left) // 左方向 + { + isDirectionMatch = candidateRect.xMax <= currentRect.xMin && + RectOverlapY(currentRect, candidateRect); + } + else if (direction == Vector2.right) // 右方向 + { + isDirectionMatch = candidateRect.xMin >= currentRect.xMax && + RectOverlapY(currentRect, candidateRect); + } + + if (isDirectionMatch) + { + float distance = Vector2.Distance(currentRect.center, candidateRect.center); + if (distance < bestDistance) + { + bestDistance = distance; + bestCandidate = candidate; + } + } + } + + if (bestCandidate != null) + { + _currentIndex = _buttons.IndexOf(bestCandidate); + SetButtonSelect(bestCandidate); + } + } + + /// + /// 获取按钮在根坐标空间中的矩形区域 + /// + /// + /// + private Rect GetGlobalRect(GObject obj) + { + // 获取对象在根组件中的全局位置 + Vector2 globalPos = obj.LocalToGlobal(Vector2.zero); + Vector2 rootPos = GRoot.inst.GlobalToLocal(globalPos); + + // 考虑对象的缩放 + float width = obj.width * obj.scaleX; + float height = obj.height * obj.scaleY; + + return new Rect(rootPos.x, rootPos.y, width, height); + } + + /// + /// 检查两个矩形在X轴上的重叠 + /// + /// + /// + /// + private bool RectOverlapX(Rect a, Rect b) + { + return !(a.xMin >= b.xMax || a.xMax <= b.xMin); + } + + /// + /// 检查两个矩形在Y轴上的重叠 + /// + /// + /// + /// + private bool RectOverlapY(Rect a, Rect b) + { + return !(a.yMin >= b.yMax || a.yMax <= b.yMin); + } + + /// + /// 设置按钮选中 + /// + /// + private void SetButtonSelect(GButton button) + { + foreach (var btn in _buttons) + { + btn.selected = btn == button; + } + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Utils/ButtonNavigate.cs.meta b/Assets/Scripts/Utils/ButtonNavigate.cs.meta new file mode 100644 index 000000000..502bb882e --- /dev/null +++ b/Assets/Scripts/Utils/ButtonNavigate.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 83f029b458614e419234114c3d90f1fc +timeCreated: 1749009573 \ No newline at end of file diff --git a/Assets/Scripts/Utils/Extends/FairyGUIExtensions.cs b/Assets/Scripts/Utils/Extends/FairyGUIExtensions.cs new file mode 100644 index 000000000..b0cc13a44 --- /dev/null +++ b/Assets/Scripts/Utils/Extends/FairyGUIExtensions.cs @@ -0,0 +1,13 @@ +using FairyGUI; + +namespace NBF +{ + public static class FairyGUIExtensions + { + public static void Click(this GButton button) + { + button.FireClick(true); + button.onClick.Call(); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Utils/Extends/FairyGUIExtensions.cs.meta b/Assets/Scripts/Utils/Extends/FairyGUIExtensions.cs.meta new file mode 100644 index 000000000..95f3576fd --- /dev/null +++ b/Assets/Scripts/Utils/Extends/FairyGUIExtensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6f9d43645df348cc8e3e498a7570cd2f +timeCreated: 1749008303 \ No newline at end of file diff --git a/FGUIProject/assets/Common/package.xml b/FGUIProject/assets/Common/package.xml index 6963012bb..ed71c6012 100644 --- a/FGUIProject/assets/Common/package.xml +++ b/FGUIProject/assets/Common/package.xml @@ -138,7 +138,7 @@ - + diff --git a/FGUIProject/assets/Main/Com/Home/BtnHomeMap.xml b/FGUIProject/assets/Main/Com/Home/BtnHomeMap.xml index 2a8437e63..11367326f 100644 --- a/FGUIProject/assets/Main/Com/Home/BtnHomeMap.xml +++ b/FGUIProject/assets/Main/Com/Home/BtnHomeMap.xml @@ -5,9 +5,11 @@ - - - + + + + + diff --git a/FGUIProject/assets/Main/Com/Home/BtnHomeMedium.xml b/FGUIProject/assets/Main/Com/Home/BtnHomeMedium.xml index 7299303d5..0f2efaa31 100644 --- a/FGUIProject/assets/Main/Com/Home/BtnHomeMedium.xml +++ b/FGUIProject/assets/Main/Com/Home/BtnHomeMedium.xml @@ -1,12 +1,15 @@ - + - - + + + + + diff --git a/FGUIProject/assets/Main/Com/Home/BtnHomeSmall.xml b/FGUIProject/assets/Main/Com/Home/BtnHomeSmall.xml index ae57ea57c..8f8b0ae29 100644 --- a/FGUIProject/assets/Main/Com/Home/BtnHomeSmall.xml +++ b/FGUIProject/assets/Main/Com/Home/BtnHomeSmall.xml @@ -1,13 +1,15 @@ - + + + + + + - - -