首次提交

This commit is contained in:
Bob.Song
2026-03-05 18:07:55 +08:00
commit e125bb869e
4534 changed files with 563920 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class BtnTextInputControl
{
public const string URL = "ui://6hgkvlaunmzbk6";
public Controller show;
public GTextField TextInput;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
show = GetController("show");
TextInput = (GTextField)GetChild("TextInput");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e99f131a7321e8e42bf9eb6bfe452c8b

View File

@@ -0,0 +1,15 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class BtnTextInputControl : GButton
{
private void OnInited()
{
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ba21874e88e12e347a543e98c6dc286f

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e421fb97db2b48ccb37e75b8766265de
timeCreated: 1748071593

View File

@@ -0,0 +1,25 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class BtnInputControl
{
public const string URL = "ui://6hgkvlaur03ut";
public Controller show;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
show = GetController("show");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: dfab5a485e648254dad616e988d7a17e

View File

@@ -0,0 +1,15 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class BtnInputControl : BtnInputControlBase
{
private void OnInited()
{
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9bc3045114c90ef4888ae8cd51aa1e2e

View File

@@ -0,0 +1,28 @@
using FairyGUI;
using NBC;
namespace NBF
{
public abstract class BtnInputControlBase : GButton
{
public string ActionName;
public string ShowName;
public virtual void SetData(string actionName, string showName, string map = InputManager.InputMapUI)
{
this.ActionName = actionName;
this.ShowName = showName;
if (!string.IsNullOrEmpty(showName))
{
title = Lan.Get(showName);
}
else
{
title = Lan.Get(actionName);
}
var iconName = InputManager.Instance.GetInputIcon(map, ActionName);
icon = UIPackage.GetItemURL(UIDef.Pack.Common, iconName);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4da865139cbb401a91f63bcf30d233c4
timeCreated: 1769960386

View File

@@ -0,0 +1,27 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class BtnInputName
{
public const string URL = "ui://6hgkvlaumnqhz2";
public Controller styleCtrl;
public Transition start;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
styleCtrl = GetController("styleCtrl");
start = GetTransition("start");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3bbc263e9355f5144b0b4a6989f72c05

View File

@@ -0,0 +1,40 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
using NBF.Setting;
using UnityEngine.InputSystem;
namespace NBF
{
public partial class BtnInputName : GButton
{
// private InputAction _inputAction;
private KeyBoardOption _keyBoardOption;
private int _index;
private void OnInited()
{
}
public void SetData(int index, KeyBoardOption boardOption)
{
_index = index;
_keyBoardOption = boardOption;
// _inputAction = inputAction;
var bindings = boardOption.InputAction.bindings;
if (bindings.Count > index)
{
title = boardOption.GetDisplayString(); //boardOption.InputAction.GetBindingDisplayString(index);
}
else
{
title = "未绑定";
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5046c80b3e704c94886c9c81b9da0f2b

View File

@@ -0,0 +1,25 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class BtnTitleInputControl
{
public const string URL = "ui://6hgkvlaur03uj0";
public Controller style;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
style = GetController("style");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3a4cdcb09978fcd47b043fa05e53e433

View File

@@ -0,0 +1,16 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System;
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class BtnTitleInputControl : BtnInputControlBase
{
private void OnInited()
{
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 15ebd24da667f9146bc2cfbfec56a512

View File

@@ -0,0 +1,27 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class CommonInput
{
public const string URL = "ui://6hgkvlau9zboma";
public Controller FocusState;
public GTextInput Input;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
FocusState = GetController("FocusState");
Input = (GTextInput)GetChild("Input");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fb776407f4f25e64a8e803ba135bddef

View File

@@ -0,0 +1,47 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class CommonInput : GComponent
{
public EventListener onChanged => Input.onChanged;
public override string text
{
get => Input.text;
set => Input.text = value;
}
public string title
{
get => text;
set => text = value;
}
public string promptText
{
get => Input.promptText;
set => Input.promptText = value;
}
private void OnInited()
{
onFocusIn.Add(OnInputFocusIn);
onFocusOut.Add(OnInputFocusOut);
}
private void OnInputFocusIn()
{
FocusState.selectedIndex = 1;
}
private void OnInputFocusOut()
{
FocusState.selectedIndex = 0;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c7adc7972d1d401489dc796fb27d1eaa

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 688374f241004942b3ef3af4086c983e
timeCreated: 1760344663

View File

@@ -0,0 +1,20 @@
using FairyGUI;
namespace NBF
{
public static class GListExtensions
{
public static void AutoHeight(this GList list)
{
if (list.numItems < 1)
{
list.height = 100;
return;
}
var item = list.GetChildAt(0);
var listHeight = list.numItems * item.height + list.lineGap * list.numItems;
list.height = listHeight;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5bb71cdaee584b00a50ea53c6023ea79
timeCreated: 1761876194

View File

@@ -0,0 +1,89 @@
using System.Collections.Generic;
using System.Linq;
namespace NBF
{
public static class TabItemDataExtensions
{
/// <summary>
/// 为TabItemData列表添加"全部"选项卡
/// </summary>
/// <param name="tabItems">原始选项卡列表</param>
/// <returns>包含"全部"选项卡的新列表</returns>
public static void AddAllTabItem(this List<TabItemData> tabItems)
{
//判断是否存在二级目录,有二级目录则只在二级目录有"全部"选项卡
if (tabItems.Any(tabItem => tabItem.Children.Count > 0))
{
foreach (var tabItemData in tabItems)
{
if (tabItemData.Children.Count > 0)
{
var allTab = new TabItemData
{
Id = 0,
Key = "All",
Icon = "All",
IsAll = true,
Items = GetAllItemsFromTabs(tabItemData.Children)
};
tabItemData.Children.Insert(0, allTab);
}
}
}
else
{
var allTab = new TabItemData
{
Id = 0,
Key = "All",
Icon = "All",
IsAll = true,
Items = GetAllItemsFromTabs(tabItems)
};
tabItems.Insert(0, allTab);
}
}
/// <summary>
/// 递归获取所有选项卡中的项目(去重)
/// </summary>
private static List<object> GetAllItemsFromTabs(List<TabItemData> tabs)
{
var allItems = new List<object>();
foreach (var tab in tabs)
{
// if (addListTitle)
// {
// allItems.Add(new ClassifyListTitleData()
// {
// Title = tab.Key
// });
// }
// 添加当前选项卡的项目
if (tab.Items != null)
{
allItems.AddRange(tab.Items);
}
}
// 去重处理基于引用相等如果需要基于内容去重需要重写Equals方法
return allItems.Distinct().ToList();
}
public static void TabItemDataAddListTitle(this TabItemData tabItem)
{
if (tabItem.Items == null || tabItem.Items.Count < 1) return;
var hasListTitle = tabItem.Items.OfType<ClassifyListTitleData>().Any();
if (!hasListTitle)
{
tabItem.Items.Insert(0, new ClassifyListTitleData()
{
Title = tabItem.Key
});
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ab38f91a1c10449ea1d908bdffc5111a
timeCreated: 1760344665

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c64fdab373ea4ce29f82649e8be2a186
timeCreated: 1747969700

View File

@@ -0,0 +1,14 @@
using FairyGUI;
namespace NBF
{
public abstract class ListItemBase : GButton
{
public virtual void SetData(object showData)
{
OnSetData(showData);
}
protected abstract void OnSetData(object showData);
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 380c357d667646b69158440a7d7eecd9
timeCreated: 1747969715

View File

@@ -0,0 +1,25 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class ListTitleItem
{
public const string URL = "ui://6hgkvlaush9ymc";
public Controller show;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
show = GetController("show");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f130a01ca6286e1408db0809028cf787

View File

@@ -0,0 +1,23 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class ListTitleItem : GButton
{
private void OnInited()
{
}
public virtual void SetData(object showData)
{
if (showData is ClassifyListTitleData listTitleData)
{
this.SetLanguage(listTitleData.Title);
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b2881797917479b469f018a06726152d

View File

@@ -0,0 +1,35 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class NoticeItem
{
public const string URL = "ui://6hgkvlaur03uj7";
public Controller style;
public GImage box;
public GTextField TextTitle;
public GTextField TextContent;
public GLoader icon;
public GButton BtnClose;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
style = GetController("style");
box = (GImage)GetChild("box");
TextTitle = (GTextField)GetChild("TextTitle");
TextContent = (GTextField)GetChild("TextContent");
icon = (GLoader)GetChild("icon");
BtnClose = (GButton)GetChild("BtnClose");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 1f3a9415491e1fc43a80ecc8a8b6fb54

View File

@@ -0,0 +1,21 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class NoticeItem : GComponent
{
private void OnInited()
{
}
public void SetData(string message, Notices.NoticeType noticeType)
{
style.selectedIndex = (int)noticeType;
TextContent.text = message;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 35a52f92a85d4f440bc65751eb617655

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: fc2f77f68cda4a9c9d7353fc536d2443
timeCreated: 1760148550

View File

@@ -0,0 +1,25 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class ClassifyList
{
public const string URL = "ui://6hgkvlaudrkwh1";
public GList List;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
List = (GList)GetChild("List");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 75f98daf87c484ef782216da87003f53

View File

@@ -0,0 +1,126 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
using Fantasy;
using Log = NBC.Log;
namespace NBF
{
public class ClassifyListTitleData
{
public string Title;
}
public partial class ClassifyList : GComponent
{
private readonly List<object> _listData = new List<object>();
public event Action<object> OnClickItem;
public event Action<object> OnDoubleClickItem;
private int _columnsCount;
public ListSelector Selector;
private void OnInited()
{
List.onClickItem.Add(OnClickListItem);
Selector = new ListSelector(List, typeof(ListTitleItem));
}
public void InvokeClickItem(object data)
{
OnClickItem?.Invoke(data);
}
public void SetListData(List<object> listData,
ListSelectionMode selectionMode = ListSelectionMode.Single)
{
List.selectedIndex = -1;
_listData.Clear();
foreach (var obj in listData)
{
_listData.Add(obj);
}
List.RemoveChildrenToPool();
List.defaultItem = ListTitleItem.URL;
List.itemProvider = GetListItemResource;
List.itemRenderer = OnRenderItem;
List.selectionMode = selectionMode;
try
{
List.numItems = _listData.Count;
List.ScrollToView(0);
}
catch (Exception e)
{
Log.Error(e);
}
_columnsCount = 6;
Selector.Refresh();
}
void OnClickListItem(EventContext context)
{
OnClickItem?.Invoke(context.data);
if (context.inputEvent.isDoubleClick)
{
OnDoubleClickItem?.Invoke(context.data);
}
}
void OnRenderItem(int index, GObject obj)
{
var itemData = _listData[index];
if (obj is ListItemBase item)
{
item.SetData(itemData);
}
else if (obj is BagItem bagItem)
{
bagItem.SetData(itemData as ItemInfo);
}
else if (obj is ListTitleItem titleItem)
{
titleItem.SetData(itemData);
titleItem.SetSize(List.width, 32);
}
else if (obj is ShopGearItem shopGearItem)
{
shopGearItem.SetData(itemData as ShopItemInfo);
}
}
//根据索引的不同返回不同的资源URL
string GetListItemResource(int index)
{
var itemData = _listData[index];
if (itemData is ItemInfo itemInfo)
{
return BagItem.URL;
}
if (itemData is ShopItemInfo shopItemInfo)
{
return ShopGearItem.URL;
}
if (itemData is ClassifyListTitleData titleData)
{
return ListTitleItem.URL;
}
return List.defaultItem;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ec101ca53ba6849efa2e51492b6310cf

View File

@@ -0,0 +1,27 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class CommonItemList
{
public const string URL = "ui://6hgkvlaup1fps";
public CommonMenu Menu;
public ClassifyList List;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
Menu = (CommonMenu)GetChild("Menu");
List = (ClassifyList)GetChild("List");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 28dc4cb333840804fb479364c41ad525

View File

@@ -0,0 +1,101 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using FairyGUI;
using NBC;
using UIPanel = NBC.UIPanel;
namespace NBF
{
public partial class CommonItemList : GComponent
{
private List<TabItemData> _tabList = new List<TabItemData>();
private TabItemData _currentTab;
private void OnInited()
{
Menu.OnTabChange += ChangeTab;
// SubMenu.OnTabChange += ChangeSubTab;
}
public override void Dispose()
{
Menu.OnTabChange -= ChangeTab;
// SubMenu.OnTabChange -= ChangeSubTab;
base.Dispose();
}
/// <summary>
///
/// </summary>
/// <param name="tabItemList"></param>
/// <param name="showAll">是否显示全部页签</param>
/// <param name="showListTitle">是否列表页显示分类标题</param>
public void SetData(List<TabItemData> tabItemList, bool showAll = false, bool showListTitle = true)
{
_tabList.Clear();
_currentTab = null;
// style.selectedIndex = 0; //一级菜单
// if (tabItemList.Any(tabItem => tabItem.Children.Count > 0))
// {
// style.selectedIndex = 1; //有二级菜单
// }
_tabList.AddRange(tabItemList);
if (showListTitle)
{
foreach (var tabItemData in _tabList)
{
tabItemData.TabItemDataAddListTitle();
if (tabItemData.Children.Count > 0)
{
foreach (var itemData in tabItemData.Children)
{
itemData.TabItemDataAddListTitle();
}
}
}
}
if (showAll)
{
_tabList.AddAllTabItem();
}
Menu.SetTabs(_tabList);
}
private void ChangeTab(int index)
{
if (index < 0) return;
var tabListData = _tabList[index];
_currentTab = tabListData;
// if (style.selectedIndex == 0)
{
//只有一级菜单
List.SetListData(_currentTab.Items);
}
// else
// {
// SubMenu.SetTabs(_currentTab.Children);
// }
}
private void ChangeSubTab(int index)
{
if (index < 0) return;
if (_currentTab == null)
{
return;
}
var subList = _currentTab.Children[index];
List.SetListData(subList.Items);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: cb564f321c6947e45a44cdd07cd48a8b

View File

@@ -0,0 +1,202 @@
using System;
using System.Collections.Generic;
using FairyGUI;
using UnityEngine;
namespace NBF
{
public class ListSelector
{
private GList _list;
private readonly List<Type> _ignores = new List<Type>();
// private readonly List<GObject> _items = new List<GObject>();
private float itemWidth = 200f;
private float itemHeight = 180f;
public object SelectedItem => _list.selectedIndex > 0 ? _list.GetChildAt(_list.selectedIndex) : null;
public ListSelector(GList list, params Type[] ignores)
{
_list = list;
if (ignores != null && ignores.Length > 0)
{
_ignores.AddRange(ignores);
}
}
#region
public void Refresh()
{
var children = _list.GetChildren();
foreach (var item in children)
{
if (_ignores.Contains(item.GetType())) continue;
itemWidth = item.width;
itemHeight = item.height;
break;
}
}
#endregion
#region
public void Up()
{
Move(Vector2.up);
}
public void Down()
{
Move(Vector2.down);
}
public void Right()
{
Move(Vector2.right);
}
public void Left()
{
Move(Vector2.left);
}
public void Move(Vector2 direction)
{
if (_list.selectedIndex == -1)
{
// 首次选择第一个可选中项
SelectFirstSelectable();
return;
}
var currentPos = GetItemPosition(_list.selectedIndex);
var nearestIndex = FindNearestSelectableItem(currentPos, direction);
// 如果是左右移动且未找到目标,则尝试寻找前一个或后一个可选项
if (nearestIndex == -1 && (direction == Vector2.left || direction == Vector2.right))
{
if (direction == Vector2.left)
{
// 寻找前一个可选项
nearestIndex = FindPreviousSelectableItem(_list.selectedIndex);
}
else if (direction == Vector2.right)
{
// 寻找后一个可选项
nearestIndex = FindNextSelectableItem(_list.selectedIndex);
}
}
if (nearestIndex != -1)
{
SetSelection(nearestIndex);
}
}
#endregion
#region
private Vector2 GetItemPosition(int index)
{
var item = _list.GetChildAt(index);
return item.position;
}
private int FindNearestSelectableItem(Vector2 fromPos, Vector2 direction)
{
var bestIndex = -1;
var bestDistance = float.MaxValue;
for (var i = 0; i < _list.numItems; i++)
{
if (!IsSelectableItem(i)) continue;
var targetPos = GetItemPosition(i);
var diff = targetPos - fromPos;
// 检查方向匹配度
if (IsDirectionMatch(direction, diff))
{
var distance = Vector2.Distance(fromPos, targetPos);
if (distance < bestDistance && distance > 0.1f)
{
bestDistance = distance;
bestIndex = i;
}
}
}
return bestIndex;
}
private int FindPreviousSelectableItem(int currentIndex)
{
for (int i = currentIndex - 1; i >= 0; i--)
{
if (IsSelectableItem(i))
return i;
}
return -1;
}
private int FindNextSelectableItem(int currentIndex)
{
for (int i = currentIndex + 1; i < _list.numItems; i++)
{
if (IsSelectableItem(i))
return i;
}
return -1;
}
private bool IsDirectionMatch(Vector2 direction, Vector2 diff)
{
if (direction == Vector2.up)
return diff.y < 0 && Mathf.Abs(diff.x) < itemWidth; // 修正向上应该是Y值更小
if (direction == Vector2.down)
return diff.y > 0 && Mathf.Abs(diff.x) < itemWidth; // 修正向下应该是Y值更大
if (direction == Vector2.left)
return diff.x < 0 && Mathf.Abs(diff.y) < itemHeight;
if (direction == Vector2.right)
return diff.x > 0 && Mathf.Abs(diff.y) < itemHeight;
return false;
}
private bool IsSelectableItem(int index)
{
var item = _list.GetChildAt(index);
var ret = !_ignores.Contains(item.GetType());
if (item.GetType() == typeof(ListTitleItem))
{
}
return ret;
}
private void SelectFirstSelectable()
{
for (var i = 0; i < _list.numItems; i++)
{
if (IsSelectableItem(i))
{
SetSelection(i);
break;
}
}
}
private void SetSelection(int index)
{
_list.selectedIndex = index;
_list.ScrollToView(index, true);
}
#endregion
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 48f217b6f1dd4dc98d1b6e1c61f9ed65
timeCreated: 1761838465

View File

@@ -0,0 +1,27 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class MarqueeTag
{
public const string URL = "ui://6hgkvlaulvqll9";
public GRichTextField TextContent1;
public GRichTextField TextContent2;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
TextContent1 = (GRichTextField)GetChild("TextContent1");
TextContent2 = (GRichTextField)GetChild("TextContent2");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6a9cfe2c247599a4aacfea389e45ce14

View File

@@ -0,0 +1,15 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class MarqueeTag : GComponent
{
private void OnInited()
{
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 70a1e1d821a7bc24e8eac7cc9bbf074b

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5d49e5e796ac4b4487b72a164e22ba73
timeCreated: 1748093228

View File

@@ -0,0 +1,25 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class BottomMenu
{
public const string URL = "ui://6hgkvlau9mf1z";
public GList List;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
List = (GList)GetChild("List");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 172ed53c6c409e04c8a993c9fae4c820

View File

@@ -0,0 +1,72 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System;
using UnityEngine;
using FairyGUI;
using NBC;
using UIPanel = NBC.UIPanel;
namespace NBF
{
public partial class BottomMenu : GComponent
{
private void OnInited()
{
List.onClickItem.Add(OnClickItem);
// LeftList.onClickItem.Add(OnClickItem);
InputManager.OnUIInvokeChange += OnUIInvokeChange;
}
public override void Dispose()
{
InputManager.OnUIInvokeChange -= OnUIInvokeChange;
base.Dispose();
}
private void OnClickItem(EventContext context)
{
var item = context.data as BtnTitleInputControl;
if (item == null) return;
InputManager.Instance.SendUIInput(item.ActionName);
Debug.Log("模拟点击===");
}
private void OnUIInvokeChange()
{
List.RemoveChildrenToPool();
// LeftList.RemoveChildrenToPool();
var invokes = InputManager.Instance.GetUsableInvokes();
foreach (var uiInputInvoke in invokes)
{
var invokeData = uiInputInvoke.InputInvoke;
if (uiInputInvoke.InputInvoke.Mode == UIInputButtonShowMode.BottomLeft)
{
AddButton(invokeData.Name, invokeData.Key, false);
}
else if (uiInputInvoke.InputInvoke.Mode == UIInputButtonShowMode.BottomRight)
{
AddButton(invokeData.Name, invokeData.Key);
}
}
}
public void AddButton(string inputName, string showName = "", bool isRight = true)
{
if (List.AddItemFromPool() is BtnTitleInputControl item)
{
item.SetData(inputName, showName);
}
// if (isRight)
// {
// }
// else
// {
// if (LeftList.AddItemFromPool() is BtnTitleInputControl item)
// {
// item.SetData(inputName, showName);
// }
// }
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 94c5df4d4f05c2b40ad72c5c90008295

View File

@@ -0,0 +1,29 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class CommonMenu
{
public const string URL = "ui://6hgkvlaufcfggr";
public Controller showTitleCtrl;
public GImage back;
public GList List;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
showTitleCtrl = GetController("showTitleCtrl");
back = (GImage)GetChild("back");
List = (GList)GetChild("List");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 195be61b5e6ed4de4b8cec3c2ce8d003

View File

@@ -0,0 +1,92 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
using NBC;
using UIPanel = NBC.UIPanel;
namespace NBF
{
public partial class CommonMenu : GLabel
{
public event Action<int> OnTabChange;
private void OnInited()
{
List.onClickItem.Add(OnClickItem);
// BtnPrev.onClick.Add(OnClickBtnPrev);
// BtnNext.onClick.Add(OnClickBtnNext);
}
private string _leftActionName;
private string _rightActionName;
public void SetBtnActionName(string leftActionName, string rightActionName)
{
_leftActionName = leftActionName;
_rightActionName = rightActionName;
// BtnPrev.SetData(leftActionName, string.Empty);
// BtnNext.SetData(rightActionName, string.Empty);
}
public void SetTabs(List<TabItemData> tabList, int selectIndex = 0)
{
SetBtnActionName(InputDef.UI.Prev, InputDef.UI.Next);
List.RemoveChildrenToPool();
var listWidth = 0f;
for (int i = 0; i < tabList.Count; i++)
{
var tabData = tabList[i];
var tabItem = List.AddItemFromPool().asButton;
tabItem.SetLanguage(tabData.Key);
listWidth += tabItem.width;
if (i > 0)
{
listWidth += List.columnGap;
}
}
Log.Info($"Set tab index={List.selectedIndex}");
List.selectedIndex = selectIndex;
List.width = listWidth;
OnClickItem();
}
private void OnClickItem()
{
OnTabChange?.Invoke(List.selectedIndex);
}
public void OnClickBtnPrev()
{
if (List.selectedIndex > 0)
{
List.selectedIndex -= 1;
}
else
{
List.selectedIndex = List.numItems - 1;
}
OnClickItem();
}
public void OnClickBtnNext()
{
if (List.selectedIndex < List.numItems - 1)
{
List.selectedIndex += 1;
}
else
{
List.selectedIndex = 0;
}
OnClickItem();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b18b4ca156e62462ba447a851e105615

View File

@@ -0,0 +1,25 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class CommonSubMenu
{
public const string URL = "ui://6hgkvlaur03us";
public GList List;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
List = (GList)GetChild("List");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 4b9116bdcaaf42e4ea12741ceab85742

View File

@@ -0,0 +1,98 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
using NBC;
using UIPanel = NBC.UIPanel;
namespace NBF
{
public partial class CommonSubMenu : GComponent
{
public event Action<int> OnTabChange;
private string _leftActionName;
private string _rightActionName;
private void OnInited()
{
List.onClickItem.Add(OnClickItem);
// BtnPrev.onClick.Add(OnClickBtnPrev);
// BtnNext.onClick.Add(OnClickBtnNext);
// CommonSubMenu
}
public void SetBtnActionName(string leftActionName, string rightActionName)
{
_leftActionName = leftActionName;
_rightActionName = rightActionName;
// BtnPrev.SetData(leftActionName, string.Empty);
// BtnNext.SetData(rightActionName, string.Empty);
}
public override void Dispose()
{
base.Dispose();
}
public void SetTabs(List<TabItemData> subItems, int selectIndex = 0)
{
List.RemoveChildrenToPool();
var width = 0f;
for (int i = 0; i < subItems.Count; i++)
{
var tabData = subItems[i];
var tabItem = List.AddItemFromPool(BtnSubMenu.URL).asButton;//i == 0 ? BtnSubMenuLeft.URL :
tabItem.SetLanguage(tabData.Key);
width += tabItem.width;
if (i > 0)
{
width += List.columnGap;
}
}
Log.Info($"Set tab index={List.selectedIndex}");
List.selectedIndex = selectIndex;
List.width = width;
OnClickItem();
}
private void OnClickItem()
{
OnTabChange?.Invoke(List.selectedIndex);
}
public void OnClickBtnPrev()
{
if (List.selectedIndex > 0)
{
List.selectedIndex -= 1;
}
else
{
List.selectedIndex = List.numItems - 1;
}
OnClickItem();
}
public void OnClickBtnNext()
{
if (List.selectedIndex < List.numItems - 1)
{
List.selectedIndex += 1;
}
else
{
List.selectedIndex = 0;
}
OnClickItem();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 93621bc99ea075a4089f13224578d4ef

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 21fd308a87b848d7b4a9138f06c4c5f7
timeCreated: 1769923363

View File

@@ -0,0 +1,25 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class BtnSubMenu
{
public const string URL = "ui://6hgkvlauvbojxi";
public GImage back;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
back = (GImage)GetChild("back");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 670c4d5385c0ad741a5381d10fc7dd15

View File

@@ -0,0 +1,15 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class BtnSubMenu : GButton
{
private void OnInited()
{
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5b6a27e3fa4572443afc883702c768f3

View File

@@ -0,0 +1,25 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class BtnSubMenuLeft
{
public const string URL = "ui://6hgkvlaumbu9y9";
public GImage back;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
back = (GImage)GetChild("back");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: bfb4ffee7088da54d95a349215186ba6

View File

@@ -0,0 +1,15 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
namespace NBF
{
public partial class BtnSubMenuLeft : GButton
{
private void OnInited()
{
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5ce6cf183d4b20f4997dd9ca99797135

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6ab6eac3efbb4daf8f4051d1a22d3dd8
timeCreated: 1761415375

View File

@@ -0,0 +1,328 @@
using System;
using FairyGUI;
using FairyGUI.Utils;
using System.Collections;
using UnityEngine;
using UnityEngine.Rendering.Universal;
using Object = UnityEngine.Object;
namespace NBF
{
[Serializable]
public class ModelViewRenderImage
{
public Transform modelRoot { get; private set; }
public Camera Camera => _camera;
public RenderTexture RT => _renderTexture;
public ModelViewerSettings ViewerSettings { get; private set; }
Camera _camera;
Image _image;
Transform _root;
Transform _background;
Transform _model;
RenderTexture _renderTexture;
int _width;
int _height;
bool _cacheTexture;
// Vector3 _rotating;
const int RENDER_LAYER = 22;
const int HIDDEN_LAYER = 22;
public ModelViewRenderImage(GGraph holder)
{
_width = (int)holder.width;
_height = (int)holder.height;
_cacheTexture = true;
_image = new Image();
holder.SetNativeObject(_image);
_root = new GameObject("RenderImage").transform;
_root.transform.position = Vector3.zero;
// _root.SetParent(_camera.transform, false);
SetLayer(_root.gameObject, HIDDEN_LAYER);
Object.DontDestroyOnLoad(_root.gameObject);
Object prefab = Resources.Load("RenderTexture/RenderImageCamera");
GameObject go = (GameObject)Object.Instantiate(prefab, _root, false);
_camera = go.GetComponent<Camera>();
_camera.transform.position = Vector3.zero;
_camera.cullingMask = 1 << RENDER_LAYER;
_camera.enabled = false;
Object.DontDestroyOnLoad(_camera.gameObject);
modelRoot = new GameObject("model_root").transform;
modelRoot.SetParent(_root, false);
_background = new GameObject("background").transform;
_background.SetParent(_root, false);
_image.onAddedToStage.Add(OnAddedToStage);
_image.onRemovedFromStage.Add(OnRemoveFromStage);
// _viewerSettings = new ModelViewerSettings();
if (_image.stage != null)
OnAddedToStage();
else
_camera.gameObject.SetActive(false);
}
public void SetModel(GameObject model, ModelViewerSettings settings)
{
this.UnloadModel();
ViewerSettings = settings;
if (model == null) return;
var joint = model.GetComponent<Joint>();
if (joint != null)
{
Object.Destroy(joint);
}
_model = model.transform;
_model.SetParent(this.modelRoot, false);
_model.localPosition = Vector3.zero;
_model.localScale = Vector3.one;
_model.localEulerAngles = Vector3.zero;
if (ViewerSettings == null)
{
ViewerSettings = new ModelViewerSettings();
ModelViewerUtils.InitSetting(model, ViewerSettings);
}
var meshArr = _model.GetComponentsInChildren<MeshRenderer>();
foreach (var meshRenderer in meshArr)
{
// 设置物体仅接受 Layer 2 的光照
meshRenderer.renderingLayerMask = 1 << 2;
}
Review();
}
public void UnloadModel()
{
if (_model != null)
{
ViewerSettings = null;
_model.gameObject.SetActive(false);
Object.Destroy(_model.gameObject);
_model = null;
}
}
public void Review()
{
_model.position = ViewerSettings.objectPosition;
_model.localScale = ViewerSettings.objectScale;
_model.eulerAngles = ViewerSettings.objectRotation;
_camera.clearFlags = CameraClearFlags.Nothing;
_camera.backgroundColor = new Color(0, 0, 0, 0); // 完全透明
_camera.transform.position = ViewerSettings.cameraPosition;
_camera.transform.LookAt(ViewerSettings.cameraTarget);
_camera.orthographic = ViewerSettings.cameraOrtho;
_camera.orthographicSize = ViewerSettings.cameraSize;
_camera.orthographicSize /= ViewerSettings.camerasScaleFactor;
_camera.fieldOfView = ViewerSettings.cameraFov;
float fov = 2 * Mathf.Rad2Deg * Mathf.Atan2(
Mathf.Tan(_camera.fieldOfView * Mathf.Deg2Rad / 2), ViewerSettings.camerasScaleFactor
);
if (fov < 0)
fov += 180;
_camera.fieldOfView = fov;
_camera.nearClipPlane = 0.001f;
_camera.farClipPlane = 10000;
_camera.depthTextureMode = DepthTextureMode.Depth;
_camera.clearFlags = CameraClearFlags.Color;
_camera.GetUniversalAdditionalCameraData().renderPostProcessing = false; //URP only
}
public void Dispose()
{
UnloadModel();
Object.Destroy(_camera.gameObject);
DestroyTexture();
_image.Dispose();
_image = null;
}
void CreateTexture()
{
if (_renderTexture != null)
return;
//1920
_renderTexture = new RenderTexture(_width, _height, 24, RenderTextureFormat.ARGB32)
{
antiAliasing = 8,
filterMode = FilterMode.Bilinear,
anisoLevel = 0,
useMipMap = false
};
// _renderTexture.Create();
_image.texture = new NTexture(_renderTexture);
_image.shader = "Unlit/Transparent";
}
void DestroyTexture()
{
if (_renderTexture != null)
{
Object.Destroy(_renderTexture);
_renderTexture = null;
_image.texture = null;
}
}
void OnAddedToStage()
{
if (_renderTexture == null)
CreateTexture();
Timers.inst.AddUpdate(Render);
_camera.gameObject.SetActive(true);
Render();
}
void OnRemoveFromStage()
{
if (!_cacheTexture)
DestroyTexture();
Timers.inst.Remove(Render);
_camera.gameObject.SetActive(false);
}
void Render(object param = null)
{
// if (_rotating != Vector3.zero && this.modelRoot != null)
// {
// // 使用 Quaternion 来避免欧拉角带来的问题
// modelRoot.Rotate(_rotating, Space.World);
// }
SetLayer(_root.gameObject, RENDER_LAYER);
_camera.targetTexture = _renderTexture;
RenderTexture old = RenderTexture.active;
RenderTexture.active = _renderTexture;
GL.Clear(true, true, Color.clear);
_camera.Render();
RenderTexture.active = old;
SetLayer(_root.gameObject, HIDDEN_LAYER);
UpdateDebugSave();
}
void SetLayer(GameObject go, int layer)
{
Transform[] transforms = go.GetComponentsInChildren<Transform>(true);
foreach (Transform t in transforms)
{
t.gameObject.layer = layer;
}
}
#region
// 在 ModelViewRenderImage 中添加新字段
private Vector2 _lastMousePosition;
private bool _isDragging;
public void StartRotate(Vector2 currentMousePosition)
{
_lastMousePosition = currentMousePosition;
_isDragging = true;
}
public void UpdateRotation(Vector2 currentMousePosition)
{
if (!_isDragging || modelRoot == null || _camera == null) return;
Vector2 delta = currentMousePosition - _lastMousePosition;
// 使用适中的灵敏度
float sensitivity = 0.2f;
float rotX = -delta.y * sensitivity;
float rotY = -delta.x * sensitivity;
Quaternion yRotation = Quaternion.AngleAxis(rotY, _camera.transform.up);
Quaternion xRotation = Quaternion.AngleAxis(rotX, _camera.transform.right);
// 组合旋转并应用
modelRoot.rotation = yRotation * xRotation * modelRoot.rotation;
_lastMousePosition = currentMousePosition;
}
public void StopRotate()
{
_isDragging = false;
}
// 重置到初始状态的方法
public void ResetToInitialRotation()
{
modelRoot.localRotation = Quaternion.identity;
_isDragging = false;
}
#endregion
#region MyRegion
void UpdateDebugSave()
{
if (Input.GetKeyDown(KeyCode.F9))
{
SaveRenderTextureToPNG(_renderTexture, "RenderTextureDebug.png");
}
}
void SaveRenderTextureToPNG(RenderTexture rt, string fileName)
{
if (rt == null)
{
Debug.LogWarning("RenderTexture 为 null无法保存。");
return;
}
RenderTexture current = RenderTexture.active;
RenderTexture.active = rt;
Texture2D tex = new Texture2D(rt.width, rt.height, TextureFormat.RGBA32, false);
tex.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
tex.Apply();
byte[] bytes = tex.EncodeToPNG();
string path = System.IO.Path.Combine(Application.dataPath, "../" + fileName);
System.IO.File.WriteAllBytes(path, bytes);
Debug.Log($"✅ RenderTexture 已保存到: {path}");
UnityEngine.Object.Destroy(tex);
RenderTexture.active = current;
}
#endregion
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 14ecd9c69c8a4eb28e8f102cca593c0b
timeCreated: 1761412504

View File

@@ -0,0 +1,27 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class ModelViewer
{
public const string URL = "ui://6hgkvlauxd2fml";
public GGraph ModelHolder;
public GGraph TouchHolder;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
ModelHolder = (GGraph)GetChild("ModelHolder");
TouchHolder = (GGraph)GetChild("TouchHolder");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: d1f6b336c0f70ab428b9ab14c0f1bd6f

View File

@@ -0,0 +1,179 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System.IO;
using UnityEngine;
using FairyGUI;
using Fantasy;
using NBF.Fishing2;
using Log = NBC.Log;
namespace NBF
{
public partial class ModelViewer : GComponent
{
ModelViewRenderImage _renderImage;
public ModelViewRenderImage RenderImage => _renderImage;
private Transform ModelRoot => _renderImage?.modelRoot;
private Camera ViewCamera => _renderImage.Camera;
public ModelViewerSettings ViewerSettings => _renderImage.ViewerSettings;
private void OnInited()
{
TouchHolder.onRollOver.Set(OnFocusIn);
TouchHolder.onRollOut.Set(OnFocusOut);
Stage.inst.onMouseWheel.Add(OnMouseWheel);
onAddedToStage.Add(OnAddedToStage);
SetRotateListening();
}
void OnAddedToStage()
{
_renderImage = new ModelViewRenderImage(ModelHolder.asGraph);
}
public override void Dispose()
{
Stage.inst.onMouseWheel.Remove(OnMouseWheel);
_renderImage.Dispose();
base.Dispose();
}
public void SetData(ItemInfo itemInfo)
{
_renderImage.SetModel(PrefabsHelper.CreateItem(itemInfo.Config), ModelViewerSettings.Load((int)itemInfo.ConfigId));
}
public void SetData(cfg.Item itemConfig)
{
_renderImage.SetModel(PrefabsHelper.CreateItem(itemConfig), ModelViewerSettings.Load(itemConfig.Id));
}
public void UnloadModel()
{
_renderImage.UnloadModel();
}
#region ()
private bool _focus;
private float _minFOV = 10f;
private float _maxFOV = 120f;
private void SetRotateListening()
{
var dragObj = TouchHolder;
var gesture1 = new SwipeGesture(dragObj);
gesture1.onBegin.Set(OnSwipeBegin);
gesture1.onMove.Set(OnSwipeMove);
gesture1.onEnd.Set(OnSwipeEnd);
}
private void OnSwipeBegin(EventContext context)
{
var gesture = context.sender as SwipeGesture;
if (gesture == null) return;
if (context.inputEvent.button == 0)
{
_renderImage.StartRotate(gesture.position);
}
}
private void OnSwipeMove(EventContext context)
{
var gesture = context.sender as SwipeGesture;
if (gesture == null) return;
if (context.inputEvent.button == 0)
{
_renderImage.UpdateRotation(gesture.position);
}
}
private void OnSwipeEnd(EventContext context)
{
_renderImage.StopRotate();
}
private void OnFocusIn()
{
_focus = true;
Log.Info("focus true");
}
private void OnFocusOut()
{
_focus = false;
Log.Info("focus false");
}
private void OnMouseWheel(EventContext context)
{
if (!_focus) return;
float delta = context.inputEvent.mouseWheelDelta / Stage.devicePixelRatio;
SetZoom(delta);
}
private void SetZoom(float delta)
{
ViewCamera.fieldOfView = Mathf.Clamp(ViewCamera.fieldOfView + delta, _minFOV, _maxFOV);
}
#endregion
public void SaveRenderTextureToPNG(int id)
{
#if UNITY_EDITOR
RenderTexture rt = RenderImage.RT;
if (rt == null)
{
Debug.LogWarning("RenderTexture 为 null无法保存。");
return;
}
RenderTexture current = RenderTexture.active;
RenderTexture.active = rt;
Texture2D tex = new Texture2D(rt.width, rt.height, TextureFormat.RGBA32, false);
tex.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
tex.Apply();
Texture2D resizedTex = new Texture2D(256, 256, TextureFormat.RGBA32, false);
// 使用双线性滤波进行缩放
for (int y = 0; y < 256; y++)
{
for (int x = 0; x < 256; x++)
{
// 计算在原始纹理中的对应坐标
float u = (float)x / 255f;
float v = (float)y / 255f;
// 获取插值后的颜色
Color color = tex.GetPixelBilinear(u, v);
resizedTex.SetPixel(x, y, color);
}
}
resizedTex.Apply();
byte[] bytes = resizedTex.EncodeToPNG();
var path = Path.Combine(Application.dataPath, $"Resources/Icons/{id}.png");
File.WriteAllBytes(path, bytes);
Debug.Log($"✅ RenderTexture 已保存到: {path}");
Notices.Info($"生成:{id}");
Object.Destroy(tex);
RenderTexture.active = current;
#endif
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c4925b571afa6b84382089b71d8603f2

View File

@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using NBC.Asset;
using Newtonsoft.Json;
using UnityEngine;
using Color = UnityEngine.Color;
namespace NBF
{
[Serializable]
public class ModelViewerSettings
{
//物体设置
public Vector3 objectPosition;
public Vector3 objectRotation;
public Vector3 objectScale;
//摄像机设置
public Vector3 cameraPosition;
public Vector3 cameraTarget;
public bool autoPosition;
public bool autoScale;
public bool cameraOrtho;
public float cameraFov;
public float cameraSize;
public float camerasScaleFactor;
public float perspLastScale;
//灯光设置
public Color lightColour;
public Vector3 lightDir;
public float lightIntensity;
public Color ambientLightColour;
public static ModelViewerSettings Load(int id)
{
var configAsset = Assets.Load<TextAsset>($"Assets/ResRaw/config/Viewer/{id}");
if (configAsset != null)
{
return JsonConvert.DeserializeObject<ModelViewerSettings>(configAsset.text);
}
return null;
}
public ModelViewerSettings()
{
SetDefValues();
}
public ModelViewerSettings(Shader objRenderShader, string rapidIconRootFolder, GameObject rootObject)
{
SetDefValues();
}
private void SetDefValues()
{
objectPosition = Vector3.zero;
objectRotation = Vector3.zero;
objectScale = Vector3.one;
autoPosition = true;
cameraPosition = new Vector3(1, Mathf.Sqrt(2), 1);
perspLastScale = 1;
cameraOrtho = false;
cameraFov = 60;
cameraSize = 5;
camerasScaleFactor = 1;
cameraTarget = Vector3.zero;
autoScale = true;
ambientLightColour = Color.gray;
lightColour = Color.white;
lightDir = new Vector3(50, -30, 0);
lightIntensity = 1;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7ff80ea34f5f43069392dc52c7b49831
timeCreated: 1761415395

View File

@@ -0,0 +1,99 @@
using UnityEngine;
namespace NBF
{
public class ModelViewerUtils
{
public static ModelViewerSettings InitSetting(GameObject go, ModelViewerSettings settings)
{
if (settings.objectPosition.magnitude < 0.0001f)
settings.objectPosition = Vector3.zero;
//---Zero the GameObject euler angles if they're very small in magnitude---//
settings.objectRotation = go.transform.eulerAngles;
if (settings.objectRotation.magnitude < 0.0001f)
settings.objectRotation = Vector3.zero;
//---Set the object scale variable---//
settings.objectScale = go.transform.localScale;
//将默认对象位置设为使其位于图标中心的位置
Bounds bounds = GetObjectBounds(go);
settings.objectPosition = GetObjectAutoOffset(bounds);
// 将默认的相机设置调整为适合图标渲染中对象的呈现效果
float camAuto = GetCameraAuto(bounds);
settings.cameraSize = camAuto;
settings.cameraPosition = Vector3.one * camAuto;
return settings;
}
public static Bounds GetObjectBounds(GameObject go)
{
// 在将其位置归零之前先保存其位置信息
Vector3 prefabPos = go.transform.position;
go.transform.position = Vector3.zero;
// 创建一个边界对象,并将对象网格的边界进行封装。
MeshRenderer mr = go.GetComponent<MeshRenderer>();
Bounds bounds = new Bounds(Vector3.zero, 0.000001f * Vector3.one);
if (mr != null)
bounds.Encapsulate(mr.bounds);
else
{
SkinnedMeshRenderer smr = go.GetComponent<SkinnedMeshRenderer>();
if (smr != null)
bounds.Encapsulate(smr.bounds);
}
//同时将对象的子对象的范围也进行封装起来
EncapsulateChildBounds(go.transform, ref bounds);
//将预制物的位置重置为存储的值
go.transform.position = prefabPos;
return bounds;
}
public static Vector3 GetObjectAutoOffset(Bounds bounds)
{
//将偏移量应用到图标对象的位置上
return -bounds.center;
}
public static float GetCameraAuto(Bounds bounds)
{
//---Scale camera size and position so that the object fits in the render---//
Matrix4x4 trs = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 45, 0), 1.05f * Vector3.one);
Vector3 corner = new Vector3(bounds.extents.x, bounds.extents.y, bounds.extents.z);
corner = trs * corner;
Vector2 refB2 = new Vector2(0.74f, 0.53f);
Vector2 b2 = refB2 * corner.magnitude;
return b2.magnitude;
}
public static void EncapsulateChildBounds(Transform t, ref Bounds bounds)
{
// 遍历所有子对象,封装边界
MeshRenderer mr;
for (int i = 0; i < t.childCount; i++)
{
mr = t.GetChild(i).GetComponent<MeshRenderer>();
if (mr != null)
bounds.Encapsulate(mr.bounds);
else
{
SkinnedMeshRenderer smr = t.GetChild(i).GetComponent<SkinnedMeshRenderer>();
if (smr != null)
bounds.Encapsulate(smr.bounds);
}
EncapsulateChildBounds(t.GetChild(i), ref bounds);
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 61157ac2e9594f58ae919731a4a5028c
timeCreated: 1761487911

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 059888fe216d4a789f01c3289be01645
timeCreated: 1748933992

View File

@@ -0,0 +1,28 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
using System.Collections.Generic;
namespace NBF
{
/// <summary> </summary>
public partial class CommonTopPanel
{
public GObject this[string aKey] => ContentPane.GetChild(aKey);
public override string UIPackName => "Common";
public override string UIResName => "CommonTopPanel";
[AutoFind(Name = "Marquee")]
public MarqueeTag Marquee;
public override string[] GetDependPackages(){ return new string[] {}; }
public static void Show(object param = null){ UI.Inst.OpenUI<CommonTopPanel>(param); }
public static void Hide(){ UI.Inst.HideUI<CommonTopPanel>(); }
public static void Del(){ UI.Inst.DestroyUI<CommonTopPanel>(); }
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: bbb8f680eb100a84c957fad39fae2e96

View File

@@ -0,0 +1,82 @@
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using System.Collections.Generic;
using UnityEngine;
using NBC;
namespace NBF
{
public partial class CommonTopPanel : UIPanel
{
protected override void OnInit()
{
ContentPane.sortingOrder = UIDef.UIOrder.CommonTopPanel;
IsShowCursor = false;
Lan.Inst.ChangeAction += ChangeLanguageConfirm;
}
protected override void OnShow()
{
InputManager.OnUICanceled += OnUICanceled;
}
private void OnUICanceled(string action)
{
if (action == InputDef.UI.Back)
{
var panel = UI.Inst.GetUI<HomePanel>();
if (panel != null && panel.IsShowing) return;
HomePanel.Show();
}
}
protected override void OnUpdate()
{
// base.OnUpdate();
if (Input.GetKeyDown(KeyCode.F9))
{
PreviewPanel.Show();
}
}
private void ChangeLanguageConfirm()
{
var uis = UI.Inst.GetAllUI();
List<IUIPanel> panels = new List<IUIPanel>();
foreach (var ui in uis)
{
if (!ui.IsShowing && !ui.IsDotDel)
{
UI.Inst.DestroyUI(ui.GetType());
}
else
{
panels.Add(ui);
}
}
//打开的页面重刷多语言
foreach (var panel in panels)
{
panel.SetLanguage();
_ui.TrySetPanelLanguage(panel.ContentPane);
}
// Net.Inst.Send(EnmCmdValue.EcvCsAcSetLanguageReq, new CS_AC_SetLanguageReq()
// {
// AppLanguage = Lan.Inst.GetCurrentCustomLanguageName()
// });
}
protected override void OnHide()
{
InputManager.OnUICanceled -= OnUICanceled;
}
protected override void OnDestroy()
{
Lan.Inst.ChangeAction -= ChangeLanguageConfirm;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b07b25d31dce1224e913094a95196cbb

View File

@@ -0,0 +1,32 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
using System.Collections.Generic;
namespace NBF
{
/// <summary> </summary>
public partial class GMPanel
{
public GObject this[string aKey] => ContentPane.GetChild(aKey);
public override string UIPackName => "Common";
public override string UIResName => "GMPanel";
[AutoFind(Name = "InputForce")]
public GLabel InputForce;
[AutoFind(Name = "BtnOk")]
public GButton BtnOk;
[AutoFind(Name = "Dir")]
public GComboBox Dir;
public override string[] GetDependPackages(){ return new string[] {}; }
public static void Show(object param = null){ UI.Inst.OpenUI<GMPanel>(param); }
public static void Hide(){ UI.Inst.HideUI<GMPanel>(); }
public static void Del(){ UI.Inst.DestroyUI<GMPanel>(); }
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 77d73c07771cd2445b26abb2ed0fdbb1

View File

@@ -0,0 +1,30 @@
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using UnityEngine;
using NBC;
namespace NBF
{
public partial class GMPanel : UIPanel
{
protected override void OnInit()
{
base.OnInit();
}
protected override void OnShow()
{
base.OnShow();
}
protected override void OnHide()
{
base.OnHide();
}
protected override void OnDestroy()
{
base.OnDestroy();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e084db244c96e034f8213a921c8c3f9f

View File

@@ -0,0 +1,36 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
using System.Collections.Generic;
namespace NBF
{
/// <summary> </summary>
public partial class MessageBox
{
public GObject this[string aKey] => ContentPane.GetChild(aKey);
public override string UIPackName => "Common";
public override string UIResName => "MessageBox";
[AutoFind(Name = "back")]
public GImage back;
[AutoFind(Name = "TextTitle")]
public GTextField TextTitle;
[AutoFind(Name = "BtnConfirm")]
public GButton BtnConfirm;
[AutoFind(Name = "BtnClose")]
public GButton BtnClose;
[AutoFind(Name = "t0")]
public Transition t0;
public override string[] GetDependPackages(){ return new string[] {}; }
public static void Show(object param = null){ UI.Inst.OpenUI<MessageBox>(param); }
public static void Hide(){ UI.Inst.HideUI<MessageBox>(); }
public static void Del(){ UI.Inst.DestroyUI<MessageBox>(); }
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 7ce689c460bfe8245948899939807a59

View File

@@ -0,0 +1,96 @@
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using System;
using FairyGUI;
using UnityEngine;
using NBC;
using UIPanel = NBC.UIPanel;
namespace NBF
{
public partial class MessageBox : UIPanel
{
private static string _confirmText;
private static string _cancelText;
private static string _title;
private static string _content;
private static Action<bool> _callback;
private static int _style;
public static void Show(string msg, Action<bool> callback, string title = "", int style = 0,
string confirm = "", string cancel = "")
{
if (string.IsNullOrEmpty(title))
{
title = "TEXT_NOTE";
}
if (string.IsNullOrEmpty(confirm))
{
confirm = "TEXT_CONFIRM";
}
if (string.IsNullOrEmpty(cancel))
{
cancel = "TEXT_CANCEL";
}
_confirmText = confirm;
_cancelText = cancel;
_callback = callback;
_content = msg;
_title = title;
_style = style;
Show();
}
protected override void OnInit()
{
this.AutoAddClick(OnClick);
IsModal = true;
HideAnim = UIPanelAnimation.GetCenterPopScaleFade(this, true);
InputManager.OnUICanceled += OnUICanceled;
}
protected override void OnShow()
{
// TextTitle.SetLanguage(_title);
BtnConfirm.SetLanguage(_confirmText);
// BtnCancel.SetLanguage(_cancelText);
// MessageStyle.selectedIndex = _style;
TextTitle.SetLanguage(_content);
}
private void OnUICanceled(string action)
{
if (!IsShowing) return;
if (!IsTop) return;
if (action == InputDef.UI.Enter)
{
ClosePanel(true);
}
else if (action == InputDef.UI.Back)
{
ClosePanel(false);
}
}
protected override void OnDestroy()
{
base.OnDestroy();
InputManager.OnUICanceled -= OnUICanceled;
}
private void OnClick(GComponent btn)
{
ClosePanel(btn == BtnConfirm);
}
private void ClosePanel(bool ret)
{
_callback?.Invoke(ret);
Hide();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8e4609ff88d94fa8ad77c3cb17641809

Some files were not shown because too many files have changed in this diff Show More