This commit is contained in:
Bob.Song
2026-03-25 17:07:05 +08:00
parent 09540ad1a8
commit 830cf3c354
141 changed files with 537 additions and 197 deletions

View File

@@ -26,8 +26,9 @@ namespace NBF
UIObjectFactory.SetPackageItemExtension(BtnTextInputControl.URL, typeof(BtnTextInputControl));
UIObjectFactory.SetPackageItemExtension(UserMenuInfo.URL, typeof(UserMenuInfo));
UIObjectFactory.SetPackageItemExtension(CommonItemList.URL, typeof(CommonItemList));
UIObjectFactory.SetPackageItemExtension(NoticeItem.URL, typeof(NoticeItem));
UIObjectFactory.SetPackageItemExtension(NotificationItem.URL, typeof(NotificationItem));
UIObjectFactory.SetPackageItemExtension(BtnInputControl.URL, typeof(BtnInputControl));
UIObjectFactory.SetPackageItemExtension(AlertItem.URL, typeof(AlertItem));
UIObjectFactory.SetPackageItemExtension(ListTitleItem.URL, typeof(ListTitleItem));
UIObjectFactory.SetPackageItemExtension(BtnSubMenu.URL, typeof(BtnSubMenu));
UIObjectFactory.SetPackageItemExtension(ModelViewer.URL, typeof(ModelViewer));

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 AlertItem
{
public const string URL = "ui://6hgkvlaur7eg18m";
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: 84369ab20bf2d024a862f3ec74340867

View File

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

View File

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

View File

@@ -7,7 +7,7 @@ using NBC;
namespace NBF
{
public partial class NoticeItem
public partial class NotificationItem
{
public const string URL = "ui://6hgkvlaur03uj7";

View File

@@ -6,7 +6,7 @@ using NBC;
namespace NBF
{
public partial class NoticeItem : GComponent
public partial class NotificationItem : GComponent
{
private void OnInited()
{

View File

@@ -12,7 +12,6 @@ namespace NBF
public const string URL = "ui://6hgkvlaufcfggr";
public Controller showTitleCtrl;
public GImage back;
public GList List;
public override void ConstructFromXML(XML xml)
@@ -20,7 +19,6 @@ namespace NBF
base.ConstructFromXML(xml);
showTitleCtrl = GetController("showTitleCtrl");
back = (GImage)GetChild("back");
List = (GList)GetChild("List");
OnInited();
UILanguage.TrySetComponentLanguage(this);

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b22c6fd5099247e0aee146cef865175c
timeCreated: 1774403352

View File

@@ -0,0 +1,131 @@
using System.Collections.Generic;
using FairyGUI;
using NBC;
namespace NBF
{
public class Alert : INoticeComponent
{
private static bool _init;
private const int Gap = 8;
private const int ItemWidth = 300;
private const int ItemHeight = 42;
private float _startY;
private float _startX;
private const int LimitCount = 6; //显示条数上限
private GObjectPool _noticePool;
private static readonly Queue<string> _msgArr = new();
protected GComponent ContentPane;
public static void Show(string msg)
{
if (string.IsNullOrEmpty(msg)) return;
Log.Info($"显示一个notice={msg}");
if (!_init)
{
NoticesPanel.TryAddNoticeComponent(new Alert());
}
_msgArr.Enqueue(msg);
}
public void OnInit(GComponent root)
{
_init = true;
ContentPane = root;
_noticePool = new GObjectPool(ContentPane.container.cachedTransform);
_startY = GRoot.inst.height - ItemHeight - Gap - 90;
_startX = GRoot.inst.width * 0.5f - ItemWidth * 0.5f;
}
public void OnUpdate()
{
if (_msgArr.Count > 0)
{
var msg = _msgArr.Dequeue();
ShowOnceNotice(msg);
//旧的向上移动
var count = ContentPane.numChildren - 1;
for (int i = 0; i < count; i++)
{
GObject obj = ContentPane.GetChildAt(i);
if (obj != null)
{
SetObjRise(obj);
}
}
RemoveLimitMsg();
}
}
public void OnDestroy()
{
_noticePool.Clear();
}
private void ShowOnceNotice(string msg)
{
var item = GetFromPool(AlertItem.URL) as AlertItem;
if (item == null) return;
item.SetData(msg);
item.x = _startX;
item.y = _startY;
item.alpha = 1;
//显示在固定区域 两秒后消失
item.TweenFade(0, 0.5f).SetDelay(5).OnComplete(() => { ReturnToPool(item); });
}
private void SetObjRise(GObject item)
{
item.TweenMoveY(item.y - item.height - 10, 0.2f).SetEase(EaseType.QuintInOut);
}
private void RemoveLimitMsg()
{
var count = ContentPane.numChildren;
if (count > LimitCount)
{
for (int i = 0; i < count - LimitCount; i++)
{
GObject obj = ContentPane.GetChildAt(i);
if (obj != null)
{
if (GTween.IsTweening(obj))
{
GTween.Kill(obj, true);
}
else
{
ReturnToPool(obj);
}
}
}
}
}
private GObject GetFromPool(string url)
{
var ret = _noticePool.GetObject(url);
if (ret == null) return null;
ret.visible = true;
ContentPane.AddChild(ret);
GTween.GetTween(ret, TweenPropType.Y)?.Kill();
return ret;
}
private void ReturnToPool(GObject obj)
{
ContentPane.RemoveChild(obj);
_noticePool.ReturnObject(obj);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 02c8803ebf5f404da737ff0f699f5866
timeCreated: 1774402864

View File

@@ -0,0 +1,11 @@
using FairyGUI;
namespace NBF
{
public interface INoticeComponent
{
void OnInit(GComponent root);
void OnUpdate();
void OnDestroy();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c5292036b17c4e4988a2d5bf383737ab
timeCreated: 1774403415

View File

@@ -1,14 +1,10 @@
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using System.Collections.Generic;
using System.Collections.Generic;
using FairyGUI;
using UnityEngine;
using NBC;
using UIPanel = NBC.UIPanel;
namespace NBF
{
public partial class Notices : UIPanel
public class Notices : INoticeComponent
{
public enum NoticeType
{
@@ -23,27 +19,29 @@ namespace NBF
public NoticeType Type;
public string Text;
}
private static bool _isOpen;
private static readonly Queue<NoticeData> _msgArr = new();
private GObjectPool _noticePool;
private string _itemUrl;
private float _startY;
private float _startX;
private const int LimitCount = 6; //显示条数上限
private static bool _init;
private const int Gap = 8;
private const int ItemWidth = 330;
private const int ItemHeight = 76;
private float _startY;
private float _startX;
private const int LimitCount = 6; //显示条数上限
private GObjectPool _noticePool;
private static readonly Queue<NoticeData> _msgArr = new();
protected GComponent ContentPane;
public static void Info(string msg, NoticeType noticeType = NoticeType.Info)
{
if (string.IsNullOrEmpty(msg)) return;
Log.Info($"显示一个notice={msg}");
if (!_isOpen)
if (!_init)
{
Notices.Show();
NoticesPanel.TryAddNoticeComponent(new Notices());
}
_msgArr.Enqueue(new NoticeData { Type = noticeType, Text = msg });
@@ -65,21 +63,16 @@ namespace NBF
}
protected override void OnInit()
public void OnInit(GComponent root)
{
ContentPane.sortingOrder = UIDef.UIOrder.Notices;
_startY = GRoot.inst.height - ItemHeight - Gap - 110;
_startX = GRoot.inst.width - ItemWidth - Gap;
_itemUrl = UIPackage.GetItemURL(UIDef.Pack.Common, "NoticeItem");
_init = true;
ContentPane = root;
_noticePool = new GObjectPool(ContentPane.container.cachedTransform);
_startY = Gap + 140;
_startX = GRoot.inst.width - ItemWidth - Gap;
}
protected override void OnShow()
{
_isOpen = true;
}
protected override void OnUpdate()
public void OnUpdate()
{
if (_msgArr.Count > 0)
{
@@ -100,25 +93,28 @@ namespace NBF
}
}
//region notice
public void OnDestroy()
{
_noticePool.Clear();
}
private void ShowOnceNotice(NoticeData notice)
{
var item = GetFromPool(_itemUrl) as NoticeItem;
var item = GetFromPool(NotificationItem.URL) as NotificationItem;
if (item == null) return;
item.SetData(notice.Text, notice.Type);
item.x = _startX;
item.y = _startY;
item.alpha = 1;
// item.TweenFade(0, 0.5f).SetDelay(2);
// item.TweenMoveY(0, 3).SetEase(EaseType.QuintInOut).OnComplete(() => { ReturnToPool(item); });
//显示在固定区域 两秒后消失
item.TweenFade(0, 0.5f).SetDelay(3).OnComplete(() => { ReturnToPool(item); });
}
private void SetObjRise(GObject item)
{
item.TweenMoveY(item.y - item.height - 10, 0.2f).SetEase(EaseType.QuintInOut);
item.TweenMoveY(item.y + item.height + Gap, 0.2f).SetEase(EaseType.QuintInOut);
}
private void RemoveLimitMsg()
@@ -159,15 +155,5 @@ namespace NBF
ContentPane.RemoveChild(obj);
_noticePool.ReturnObject(obj);
}
protected override void OnHide()
{
_isOpen = false;
}
protected override void OnDestroy()
{
_noticePool.Clear();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5a2c129ec53a45f29b5a3ad6d4869d8a
timeCreated: 1774402966

View File

@@ -8,21 +8,21 @@ using System.Collections.Generic;
namespace NBF
{
/// <summary> </summary>
public partial class Notices
public partial class NoticesPanel
{
public GObject this[string aKey] => ContentPane.GetChild(aKey);
public override string UIPackName => "Common";
public override string UIResName => "Notices";
public override string UIResName => "NoticesPanel";
[AutoFind(Name = "show")]
public Controller show;
public override string[] GetDependPackages(){ return new string[] {}; }
public static void Show(object param = null){ UI.Inst.OpenUI<Notices>(param); }
public static void Show(object param = null){ UI.Inst.OpenUI<NoticesPanel>(param); }
public static void Hide(){ UI.Inst.HideUI<Notices>(); }
public static void Hide(){ UI.Inst.HideUI<NoticesPanel>(); }
public static void Del(){ UI.Inst.DestroyUI<Notices>(); }
public static void Del(){ UI.Inst.DestroyUI<NoticesPanel>(); }
}
}

View File

@@ -0,0 +1,82 @@
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using System.Collections.Generic;
using System.Linq;
using FairyGUI;
using UnityEngine;
using NBC;
using UIPanel = NBC.UIPanel;
namespace NBF
{
public partial class NoticesPanel : UIPanel
{
private static HashSet<INoticeComponent> _noticeComponents = new();
private static Queue<INoticeComponent> _waitAddComponents = new();
private static bool _isOpen;
public static void TryAddNoticeComponent(INoticeComponent noticeComponent)
{
if (!_isOpen)
{
Show();
}
if (_noticeComponents.Any(iNoticeComponent => iNoticeComponent.GetType() == noticeComponent.GetType()))
{
return;
}
if (_waitAddComponents.Any(waitAddComponent => waitAddComponent.GetType() == noticeComponent.GetType()))
{
return;
}
_waitAddComponents.Enqueue(noticeComponent);
}
protected override void OnInit()
{
ContentPane.sortingOrder = UIDef.UIOrder.Notices;
}
protected override void OnShow()
{
_isOpen = true;
}
protected override void OnUpdate()
{
foreach (var noticeComponent in _noticeComponents)
{
noticeComponent?.OnUpdate();
}
if (_waitAddComponents.Count > 0)
{
var com = _waitAddComponents.Dequeue();
var noticeComponent = UIPackage.CreateObject(UIDef.Pack.Common, "CommonContainer") as GComponent;
noticeComponent.width = ContentPane.width;
noticeComponent.height = ContentPane.height;
ContentPane.AddChild(noticeComponent);
com.OnInit(noticeComponent);
_noticeComponents.Add(com);
}
}
protected override void OnHide()
{
_isOpen = false;
}
protected override void OnDestroy()
{
foreach (var noticeComponent in _noticeComponents)
{
noticeComponent?.OnDestroy();
}
}
}
}

View File

@@ -18,6 +18,10 @@ namespace NBF
public MainMenu MainMenu;
[AutoFind(Name = "SubMenu")]
public CommonSubMenu SubMenu;
[AutoFind(Name = "BtnTest1")]
public GButton BtnTest1;
[AutoFind(Name = "BtnTest2")]
public GButton BtnTest2;
public override string[] GetDependPackages(){ return new string[] {}; }
public static void Show(object param = null){ UI.Inst.OpenUI<TestPanel>(param); }

View File

@@ -1,11 +1,29 @@
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using FairyGUI;
using UnityEngine;
using NBC;
using UIPanel = NBC.UIPanel;
namespace NBF
{
public partial class TestPanel : UIPanel
{
protected override void OnInit()
{
this.AutoAddClick(OnClick);
}
public void OnClick(GComponent btn)
{
if (btn == BtnTest1)
{
Notices.Info("测试1");
}
else if (btn == BtnTest2)
{
Alert.Show("测试2");
}
}
}
}

View File

@@ -18,7 +18,7 @@ namespace NBF
UIObjectFactory.SetPackageItemExtension(BtnTextInputControl.URL, typeof(BtnTextInputControl));
UIObjectFactory.SetPackageItemExtension(CommonItemList.URL, typeof(CommonItemList));
UIObjectFactory.SetPackageItemExtension(BtnTitleInputControl.URL, typeof(BtnTitleInputControl));
UIObjectFactory.SetPackageItemExtension(NoticeItem.URL, typeof(NoticeItem));
UIObjectFactory.SetPackageItemExtension(NotificationItem.URL, typeof(NotificationItem));
UIObjectFactory.SetPackageItemExtension(CommonSubMenu.URL, typeof(CommonSubMenu));
UIObjectFactory.SetPackageItemExtension(BtnInputControl.URL, typeof(BtnInputControl));
UIObjectFactory.SetPackageItemExtension(ListTitleItem.URL, typeof(ListTitleItem));

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 ItemDetailPanel
{
public GObject this[string aKey] => ContentPane.GetChild(aKey);
public override string UIPackName => "Common";
public override string UIResName => "ItemDetailPanel";
[AutoFind(Name = "style")]
public Controller style;
public override string[] GetDependPackages(){ return new string[] {}; }
public static void Show(object param = null){ UI.Inst.OpenUI<ItemDetailPanel>(param); }
public static void Hide(){ UI.Inst.HideUI<ItemDetailPanel>(); }
public static void Del(){ UI.Inst.DestroyUI<ItemDetailPanel>(); }
}
}

View File

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

View File

@@ -0,0 +1,11 @@
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using UnityEngine;
using NBC;
namespace NBF
{
public partial class ItemDetailPanel : UIPanel
{
}
}

View File

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