提交修改

This commit is contained in:
Bob.Song
2025-10-29 17:59:36 +08:00
parent b390cf2051
commit 5750c4fe56
2148 changed files with 13962 additions and 5549 deletions

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 65441e72d19f4334b7d4e9748762839e
timeCreated: 1607069598

View File

@@ -1,11 +0,0 @@
using System;
using UnityEngine;
namespace NBC
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = true)]
public class AutoFindAttribute : Attribute
{
public string Name;
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 370e0f8ad369463ca826cbb7c3d2cc21
timeCreated: 1607069612

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 9cf70d9f97294cf284d2a538d95c762c
timeCreated: 1606991848

View File

@@ -1,309 +0,0 @@
using System;
using System.Collections.Generic;
using FairyGUI;
using NBC.Entitas;
using NBC.Event;
using UnityEngine;
namespace NBC
{
public abstract class UIPanel //: Entity
{
public static Func<string, string> GetUIPackNameFunc = s => $"{s}/{s}";
/// <summary>
/// 是否显示在最顶层
/// </summary>
public bool IsTop => _ui.IsTop(this);
/// <summary>
/// 是否显示黑色背景蒙版
/// </summary>
public bool IsModal { get; protected set; }
public virtual bool IsShowing => ContentPane != null && ContentPane.parent != null;
public virtual bool IsCanVisible => ContentPane != null && ContentPane.parent != null && ContentPane.visible;
public bool IsDotDel { get; protected set; }
public bool IsDontBack { get; protected set; }
public virtual string UIPackRootUrl => string.Empty;
public virtual string UIPackName { get; set; }
public virtual string UIResName { get; set; }
/// <summary>
/// 模块id(可用于对模块编号实现一些特定功能,如新手引导)
/// </summary>
public virtual int Id { get; protected set; }
/// <summary>
/// 是否显示光标,屏蔽游戏内输入
/// </summary>
public virtual bool IsShowCursor { get; protected set; } = true;
/// <summary>
/// 面板打开动画
/// </summary>
public Func<FTask> ShowAnim;
/// <summary>
/// 面板关闭动画
/// </summary>
public Func<FTask> HideAnim;
private object _paramData;
private bool _isInited;
public GComponent ContentPane { get; protected set; }
protected UIComponent _ui;
public void SetUIManager(UIComponent manager)
{
_ui = manager;
}
public void SetData(object args)
{
_paramData = args;
}
public object GetData()
{
return _paramData;
}
public virtual string[] GetDependPackages()
{
return new string[] { };
}
public void Init()
{
try
{
var uiPackRootUrl = string.IsNullOrEmpty(UIPackRootUrl) ? UIConst.UIPackRootUrl : UIPackRootUrl;
//实例化预设
if (!_isInited)
{
var dependPackages = GetDependPackages();
if (dependPackages != null && dependPackages.Length > 0)
{
foreach (var package in dependPackages)
{
if (package != UIPackName)
{
_ui.AddPackage(uiPackRootUrl, GetUIPackNameFunc(package));
}
}
}
_ui.AddPackage(uiPackRootUrl, GetUIPackNameFunc(UIPackName));
GObject panelObj = UIPackage.CreateObject(UIPackName, UIResName);
if (panelObj == null)
{
throw new Exception("不存在包名:" + UIPackName + "/ResName=" + UIResName);
}
panelObj.SetSize(GRoot.inst.width, GRoot.inst.height);
panelObj.position = Vector3.zero;
panelObj.scale = Vector2.one;
panelObj.pivotX = 0.5f;
panelObj.pivotY = 0.5f;
ContentPane = panelObj.asCom;
ContentPane.name = UIResName;
this.AutoFindAllField();
OnInit();
// FairyBatching
GComponent panelObjCom = panelObj.asCom;
if (panelObjCom != null)
{
panelObjCom.fairyBatching = true;
}
_isInited = true;
}
}
catch (Exception e)
{
Log.Error(e);
throw;
}
}
internal async FTask Show()
{
try
{
if (!IsShowing)
{
GRoot.inst.AddChild(ContentPane);
_ui.AdjustModalLayer();
}
else
{
if (!IsTop) _ui.BringToFront(this);
}
OpenAnimBegin();
if (ShowAnim != null)
{
await ShowAnim();
}
OpenAnimFinished();
}
catch (Exception e)
{
Log.Error($"UIPackName={UIPackName} UIResName={UIResName} e={e}");
throw;
}
}
internal async FTask Hide()
{
if (!IsShowing) return;
if (HideAnim != null)
{
await HideAnim();
}
HideAnimFinished();
}
public void Update()
{
OnUpdate();
}
public void Refresh()
{
_ = Show();
}
/// <summary>
/// 设置刷新多语言
/// </summary>
public void SetLanguage()
{
_ui.TrySetPanelLanguage(ContentPane);
OnSetLanguage();
}
public void HideImmediately()
{
if (ContentPane.parent != null)
{
GRoot.inst.RemoveChild(ContentPane);
_ui.AdjustModalLayer();
var evData = new UIHideEvent()
{
panel = this
};
App.Main.EventComponent.Publish(evData);
App.Main.EventComponent.PublishAsync(evData).Coroutine();
}
OnHide();
}
public void Dispose()
{
if (!IsDotDel)
{
HideImmediately();
ContentPane.Dispose();
OnDestroy();
}
else
{
Log.Error("当前panel标记为不可删除name=" + UIResName);
}
}
private void OpenAnimBegin()
{
OnShow();
SetLanguage();
var evData = new UIShowEvent()
{
panel = this
};
App.Main.EventComponent.Publish(evData);
App.Main.EventComponent.PublishAsync(evData).Coroutine();
}
/// <summary>
/// 打开动画播放完成
/// </summary>
private void OpenAnimFinished()
{
OnShowed();
}
/// <summary>
/// 关闭动画播放完成
/// </summary>
private void HideAnimFinished()
{
HideImmediately();
}
#region
/// <summary>
/// 界面初始化的时候
/// </summary>
protected virtual void OnInit()
{
}
/// <summary>
/// 代码设置多语言OnShow后和语言变化时会调用
/// </summary>
protected virtual void OnSetLanguage()
{
}
/// <summary>
/// 显示界面显示
/// </summary>
/// <param name="param"></param>
protected virtual void OnShow()
{
}
/// <summary>
/// 显示界面完成(动画后)
/// </summary>
protected virtual void OnShowed()
{
}
protected virtual void OnUpdate()
{
}
/// <summary>
/// 界面隐藏的时候
/// </summary>
protected virtual void OnHide()
{
}
/// <summary>
/// 界面销毁的时候
/// </summary>
protected virtual void OnDestroy()
{
}
#endregion
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 6717340027374964a13049a5b6f18c2f
timeCreated: 1606992345

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 324106ae827a4b39a7d306901d9cf61d
timeCreated: 1603427397

View File

@@ -1,14 +0,0 @@
using UnityEngine;
namespace NBC
{
public static class UIConst
{
public const string ServiceName = "NBC.UIKit";
/// <summary>
/// UI资源前缀
/// </summary>
public static string UIPackRootUrl = "";
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 8599513d5235498b9f2cc5894451a3e6
timeCreated: 1603427408

View File

@@ -1,9 +0,0 @@
namespace NBC
{
public static class UIEvents
{
public const string UIShow = "UIShow";
public const string UIHide = "UIHide";
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 398ef2627f5f47c2969f775329e212c0
timeCreated: 1658111393

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: d87cd29db4384bcfbcc46fa1fcb5f6b3
timeCreated: 1751430948

View File

@@ -1,12 +0,0 @@
namespace NBC.Event
{
public struct UIHideEvent
{
public UIPanel panel;
}
public struct UIShowEvent
{
public UIPanel panel;
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 4db48c7e18b84728b7f1411741010f16
timeCreated: 1751430996

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 301625d0537e4abd8e4d2be119c2d6a8
timeCreated: 1607073119

View File

@@ -1,154 +0,0 @@
using System.Threading.Tasks;
using FairyGUI;
using UnityEngine;
namespace NBC
{
public static class UIAnimExtension
{
public static FTask ShowCenterScaleBig(this UIPanel panel)
{
return CenterScaleBigAnim(panel, false);
}
public static FTask HideCenterScaleBig(this UIPanel panel)
{
return CenterScaleBigAnim(panel, true);
}
public static FTask ShowUpToSlide(this UIPanel panel)
{
return GetUpToSlide(panel, false);
}
public static FTask HideUpToSlide(this UIPanel panel)
{
return GetUpToSlide(panel, true);
}
public static FTask ShowDownToSlide(this UIPanel panel)
{
return GetDownToSlide(panel, false);
}
public static FTask HideDownToSlide(this UIPanel panel)
{
return GetDownToSlide(panel, true);
}
public static FTask ShowLeftToSlide(this UIPanel panel)
{
return GetLeftToSlide(panel, false);
}
public static FTask HideLeftToSlide(this UIPanel panel)
{
return GetLeftToSlide(panel, true);
}
public static FTask ShowRightToSlide(this UIPanel panel)
{
return GetRightToSlide(panel, false);
}
public static FTask HideRightToSlide(this UIPanel panel)
{
return GetRightToSlide(panel, true);
}
public static FTask ShowFade(this UIPanel panel)
{
return GetFade(panel, false);
}
public static FTask HideFade(this UIPanel panel)
{
return GetFade(panel, true);
}
private static async FTask CenterScaleBigAnim(UIPanel panel, bool close = false)
{
var strat = close ? Vector3.one : Vector3.zero;
var end = close ? Vector3.zero : Vector3.one;
var easeType = close ? EaseType.BackIn : EaseType.BackOut;
GTween.To(strat, end, 0.5f)
.SetEase(easeType)
.SetTarget(panel.ContentPane, TweenPropType.Scale);
await Task.Delay(500);
}
public static async FTask GetUpToSlide(UIPanel panel, bool close = false)
{
var hight = GRoot.inst.viewHeight;
var y = -hight;
var strat = close ? 0 : y;
var end = close ? y : 0;
GTween.To(strat, end, 0.5f)
.SetEase(EaseType.CubicOut)
.SetTarget(panel.ContentPane, TweenPropType.Y);
await Task.Delay(500);
}
public static async FTask GetDownToSlide(UIPanel panel, bool close = false)
{
var hight = GRoot.inst.viewHeight;
var y = hight;
var strat = close ? 0 : y;
var end = close ? y : 0;
GTween.To(strat, end, 0.5f)
.SetEase(EaseType.CubicOut)
.SetTarget(panel.ContentPane, TweenPropType.Y);
// await App.Main.TimerComponent.Net.WaitAsync(500);
await Task.Delay(500);
}
public static async FTask GetLeftToSlide(UIPanel panel, bool close = false)
{
var width = GRoot.inst.viewWidth;
var x = -width;
var strat = close ? 0 : x;
var end = close ? x : 0;
GTween.To(strat, end, 0.5f)
.SetEase(EaseType.CubicOut)
.SetTarget(panel.ContentPane, TweenPropType.X);
// await App.Main.TimerComponent.Net.WaitAsync(500);
await Task.Delay(500);
}
public static async FTask GetRightToSlide(UIPanel panel, bool close = false)
{
var width = GRoot.inst.viewWidth;
var x = width;
var strat = close ? 0 : x;
var end = close ? x : 0;
GTween.To(strat, end, 0.5f)
.SetEase(EaseType.CubicOut)
.SetTarget(panel.ContentPane, TweenPropType.X);
// await App.Main.TimerComponent.Net.WaitAsync(500);
await Task.Delay(500);
}
public static async FTask GetFade(UIPanel panel, bool close = false)
{
var s = close ? 1 : 0;
var end = close ? 0 : 1;
panel.ContentPane.alpha = s;
GTween.To(s, end, 0.5f)
.SetEase(EaseType.Linear)
.SetTarget(panel, TweenPropType.Alpha);
// await App.Main.TimerComponent.Net.WaitAsync(500);
await Task.Delay(500);
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: d68bf7e0471c4863857235883fdd933e
timeCreated: 1751445462

View File

@@ -1,122 +0,0 @@
using System;
using System.Linq;
using System.Reflection;
using FairyGUI;
using UnityEngine;
namespace NBC
{
public static class UIExtension
{
public static void AutoFindAllField<T>(this T self) where T : UIPanel
{
var fields = self.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (var field in fields)
{
var attrs = field.GetCustomAttributes<AutoFindAttribute>().ToArray();
if (attrs.Length <= 0) continue;
var findInfo = attrs[0];
var name = string.IsNullOrEmpty(findInfo.Name) ? field.Name : findInfo.Name;
object obj;
// var type = field.FieldType;
if (field.FieldType == typeof(Controller))
{
obj = self.ContentPane.GetController(name);
}
else if (field.FieldType == typeof(Transition))
{
obj = self.ContentPane.GetTransition(name);
}
else
{
obj = self.ContentPane.GetChild(name);
}
if (obj == null)
{
throw new Exception("查找子物体失败" + "type=" + field.FieldType + "/name=" + findInfo.Name);
}
// Log.I(self.UIResName + "查找子物体" + "type=" + field.FieldType + "/name=" + findInfo.Name);
field.SetValue(self, obj);
}
}
/// <summary>
/// 自动注册点击事件
/// </summary>
/// <param name="self"></param>
/// <param name="btnStartName">FGUI中按钮以什么开头</param>
/// <param name="onClick"></param>
/// <typeparam name="T"></typeparam>
public static void AutoAddClick<T>(this T self, Action<GComponent> onClick, string btnStartName = "Btn")
where T : UIPanel
{
for (int i = 0; i < self.ContentPane.numChildren; i++)
{
GObject gObject = self.ContentPane.GetChildAt(i);
if (gObject.name.StartsWith(btnStartName))
{
gObject.onClick.Add(a => { onClick?.Invoke(a.sender as GComponent); });
}
}
}
public static void AutoClearClick<T>(this T self, string btnStartName = "Btn")
where T : UIPanel
{
for (int i = 0; i < self.ContentPane.numChildren; i++)
{
GObject gObject = self.ContentPane.GetChildAt(i);
if (gObject.name.StartsWith(btnStartName))
{
gObject.onClick.Clear();
}
}
}
/// <summary>
/// 自动注册点击事件
/// </summary>
/// <param name="self"></param>
/// <param name="btnStartName"></param>
/// <param name="onClick"></param>
/// <typeparam name="T"></typeparam>
public static void AutoAddClick(this GComponent self, Action<GComponent> onClick, string btnStartName = "Btn")
{
for (int i = 0; i < self.numChildren; i++)
{
GObject gObject = self.GetChildAt(i);
if (gObject.name.StartsWith(btnStartName))
{
gObject.onClick.Add(a => { onClick?.Invoke(a.sender as GComponent); });
}
}
}
public static void AutoSetClick(this GComponent self, Action<GComponent> onClick, string btnStartName = "Btn")
{
for (int i = 0; i < self.numChildren; i++)
{
GObject gObject = self.GetChildAt(i);
if (gObject.name.StartsWith(btnStartName))
{
gObject.onClick.Set(a => { onClick?.Invoke(a.sender as GComponent); });
}
}
}
public static void AutoClearClick(this GComponent self, string btnStartName = "Btn")
{
for (int i = 0; i < self.numChildren; i++)
{
GObject gObject = self.GetChildAt(i);
if (gObject.name.StartsWith(btnStartName))
{
gObject.onClick.Clear();
}
}
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: c6e1faca2d324be59996ac7b326ac9a7
timeCreated: 1607073126

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: d5dc408ef68f470386edde3039dc804b
timeCreated: 1603427536

View File

@@ -1,7 +0,0 @@
namespace NBC
{
public interface IBind
{
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: a0acf981fdc74a7685b9298cbbeb959a
timeCreated: 1608000546

View File

@@ -1,416 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FairyGUI;
using NBC.Asset;
using NBC.Entitas;
using NBC.Entitas.Interface;
using UnityEngine;
namespace NBC
{
public class UIComponent : Entity
{
public sealed class UIManagerComponentAwakeSystem : AwakeSystem<UIComponent>
{
protected override void Awake(UIComponent self)
{
self.Awake();
}
}
public sealed class UIManagerComponentUpdateSystem : UpdateSystem<UIComponent>
{
protected override void Update(UIComponent self)
{
self.Update();
}
}
public sealed class UIManagerComponentDestroySystem : DestroySystem<UIComponent>
{
protected override void Destroy(UIComponent self)
{
self.Destroy();
}
}
/// <summary>
/// 所有UI
/// </summary>
private readonly Dictionary<string, UIPanel> _uiArray = new Dictionary<string, UIPanel>();
private GGraph _modalLayer;
private GRoot _uiRoot;
private UIComponentLanguagePack _uiLanguageConfig;
private void Awake()
{
Log.Info("UI 模块初始化");
_uiRoot = GRoot.inst;
}
public void Destroy()
{
}
private void Update()
{
UIRunner.Update();
foreach (var panel in _uiArray.Values)
{
if (panel != null && panel.IsShowing)
{
panel.Update();
}
}
}
#region
internal void ShowUI(string uiName, object param = null)
{
var panel = GetUI(uiName);
panel.SetData(param);
if (panel.IsShowing)
{
panel.Refresh();
}
else
{
_ = panel.Show();
}
}
internal void RemoveUI(string uiName)
{
var wind = GetUI(uiName);
if (wind == null)
{
Log.Warning($"要删除的界面不存在:{uiName}");
return;
}
if (!wind.IsDotDel)
{
wind.Dispose();
_uiArray.Remove(uiName);
}
}
private void CreateModalLayer()
{
var modalLayerColor = UIConfig.modalLayerColor;
if (_modalLayer != null)
{
_modalLayer.onClick.Clear();
}
_modalLayer = new GGraph();
_modalLayer.DrawRect(_uiRoot.width, _uiRoot.height, 0, Color.white,
modalLayerColor);
_modalLayer.AddRelation(_uiRoot, RelationType.Size);
_modalLayer.name = _modalLayer.gameObjectName = "ModalLayer";
_modalLayer.SetHome(_uiRoot);
}
#endregion
#region OpenUI
public T OpenUI<T>(object param = null) where T : UIPanel
{
return OpenUI<T>(typeof(T).Name, param);
}
public T OpenUI<T>(string uiName, object param = null) where T : UIPanel
{
var panel = GetUI<T>();
if (panel == null)
{
panel = Activator.CreateInstance<T>();
if (panel != null)
{
panel.SetUIManager(this);
panel.SetData(param);
panel.Init();
_uiArray[uiName] = panel;
}
}
ShowUI(uiName, param);
return panel;
}
#endregion
#region Get
public T GetUI<T>() where T : UIPanel
{
UIPanel wind = null;
Type type = typeof(T);
var uiName = type.Name;
foreach (var name in _uiArray.Keys)
{
if (name != uiName) continue;
wind = _uiArray[name];
break;
}
return wind as T;
}
public UIPanel GetUI(string uiName)
{
foreach (var name in _uiArray.Keys)
{
if (name != uiName) continue;
return _uiArray[name];
}
return null;
}
public UIPanel[] GetAllUI()
{
return _uiArray.Values.ToArray();
}
public List<string> GetAllUIName()
{
return _uiArray.Keys.ToList();
}
#endregion
#region Hide
public void HideUI(Type type)
{
HideUI(type.Name);
}
public void HideUI<T>()
{
Type type = typeof(T);
HideUI(type.Name);
}
public void HideUI(string uiName)
{
var wind = GetUI(uiName);
if (wind == null)
{
Log.Warning($"要删除的界面不存在:{uiName}");
return;
}
wind.Hide().Coroutine();
}
/// <summary>
/// 隐藏所有窗口
/// </summary>
public void HideAllUI(bool isDotDel = false)
{
var names = GetAllUIName();
foreach (var uiName in names)
{
UIPanel panel = GetUI(uiName);
if (panel.IsShowing)
{
if (!panel.IsDotDel || isDotDel)
{
HideUI(uiName);
}
}
}
}
#endregion
#region Delete
/// <summary>
/// 删除所有打开的窗口
/// </summary>
public void DeleteAllUI()
{
var names = GetAllUIName();
foreach (var uiName in names)
{
DestroyUI(uiName);
}
}
public void DestroyUI<T>()
{
Type type = typeof(T);
DestroyUI(type.Name);
}
public void DestroyUI(Type type)
{
DestroyUI(type.Name);
}
public void DestroyUI(string uiName)
{
RemoveUI(uiName);
}
#endregion
#region Util
public void BringToFront(UIPanel uiPanel)
{
var uiRoot = GRoot.inst;
var contentPane = uiPanel.ContentPane;
if (contentPane.parent != uiRoot)
{
Log.Error("不在root内无法置顶==");
return;
}
var cnt = uiRoot.numChildren;
var i = 0;
if (_modalLayer != null && _modalLayer.parent != null && !uiPanel.IsModal)
{
i = uiRoot.GetChildIndex(_modalLayer);
}
else
{
i = cnt - 1;
}
if (i >= 0)
{
uiRoot.SetChildIndex(contentPane, i);
}
}
public bool IsTop(UIPanel uiPanel)
{
var parent = uiPanel.ContentPane.parent;
if (parent == null) return false;
var sortingOrder = uiPanel.ContentPane.sortingOrder;
var maxIndex = -1;
var panels = _uiArray.Values;
foreach (var panel in panels)
{
if (panel.IsShowing && panel.ContentPane.sortingOrder == sortingOrder)
{
//只判断同层级的
var index = parent.GetChildIndex(panel.ContentPane);
if (index > maxIndex)
{
maxIndex = index;
}
}
}
var uiIndex = parent.GetChildIndex(uiPanel.ContentPane);
return uiIndex >= maxIndex;
}
public void AdjustModalLayer()
{
if (_modalLayer == null || _modalLayer.isDisposed)
{
CreateModalLayer();
}
var showDic = new Dictionary<GObject, UIPanel>();
var panels = _uiArray.Values;
foreach (var panel in panels)
{
if (panel.IsShowing)
{
showDic[panel.ContentPane] = panel;
}
}
var cnt = _uiRoot.numChildren;
for (var i = cnt - 1; i >= 0; i--)
{
var g = _uiRoot.GetChildAt(i);
if (showDic.TryGetValue(g, out var panel))
{
if (panel.IsModal)
{
if (_modalLayer.parent == null)
_uiRoot.AddChildAt(_modalLayer, i);
else
{
_uiRoot.SetChildIndexBefore(_modalLayer, i);
}
return;
}
}
}
if (_modalLayer != null && _modalLayer.parent != null)
{
_uiRoot.RemoveChild(_modalLayer);
}
}
public bool IsOpen(string uiName)
{
UIPanel wind = GetUI(uiName);
return wind != null && wind.IsShowing;
}
#endregion
#region Package
public void AddPackage(string assetPath)
{
AddPackage(UIConst.UIPackRootUrl, assetPath);
}
public void AddPackage(string root, string assetPath)
{
var path = root + assetPath;
if (path.StartsWith("Assets/"))
{
UIPackage.AddPackage(path, (string name, string extension, Type type,
out DestroyMethod method) =>
{
method = DestroyMethod.None;
var pro = Assets.LoadAsset(name.Replace("\\", "/") + extension, type);
return pro?.Asset;
});
}
else
{
UIPackage.AddPackage(path);
}
}
#endregion
#region Language
public void SetUILanguage<T>() where T : UIComponentLanguagePack
{
_uiLanguageConfig = Activator.CreateInstance<T>();
}
public void TrySetComponentLanguage(GComponent component)
{
_uiLanguageConfig?.TrySetComponentLanguage(component);
}
public void TrySetPanelLanguage(GComponent component)
{
_uiLanguageConfig?.TrySetPanelLanguage(component);
}
#endregion
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 1e062ec5ffbb4339b33d1d75a965f4c2
timeCreated: 1607415282

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: bc014662f0324fc093a0fa05eed3b511
timeCreated: 1715247626

View File

@@ -1,122 +0,0 @@
using System.Collections.Generic;
using FairyGUI;
namespace NBC
{
public class UIComponentLanguage : Dictionary<string, string>
{
}
public abstract class UIComponentLanguagePack : Dictionary<string, UIComponentLanguage>
{
public bool Has(string url)
{
return ContainsKey(url);
}
public void TrySetComponentLanguage(GComponent component)
{
if (component.packageItem == null) return;
SetComponentFont(component);
if (!Has(component.resourceURL)) return;
SetComponentLanguage(component);
}
/// <summary>
/// 设置Panel时不判断配置中是否有数据
/// </summary>
/// <param name="component"></param>
public void TrySetPanelLanguage(GComponent component)
{
SetComponentFont(component);
SetComponentLanguage(component);
}
/// <summary>
/// 设置组件多语言
/// </summary>
/// <param name="component"></param>
public void SetComponentLanguage(GComponent component)
{
bool comHasLanConfig = false;
UIComponentLanguage componentLangeage = null;
if (component.packageItem != null && TryGetValue(component.resourceURL, out componentLangeage))
comHasLanConfig = true;
var count = component.numChildren;
for (var i = 0; i < count; i++)
{
var child = component.GetChildAt(i);
if (child.packageItem != null && child is GComponent childCom)
{
SetComponentLanguage(childCom);
}
else if (child is GList list)
{
SetComponentLanguage(list);
}
if (comHasLanConfig)
{
var id = child.id;
if (componentLangeage.TryGetValue(id, out var key))
{
if (child is GLoader gLoader)
{
gLoader.SetLanguageImage(key);
}
else
{
child.SetLanguage(key);
}
}
}
}
}
void SetComponentFont(GComponent component)
{
var count = component.numChildren;
for (var i = 0; i < count; i++)
{
var child = component.GetChildAt(i);
if (child is GComponent childCom)
{
SetComponentFont(childCom);
}
else
{
SetChildFont(child);
}
}
}
void SetChildFont(GObject child)
{
GTextField curField = null;
if (child is GRichTextField richTextField)
{
curField = richTextField;
}
else if (child is GButton button)
{
curField = button.GetTextField();
}
else if (child is GLabel label)
{
curField = label.GetTextField();
}
else if (child is GTextField gtextField)
{
curField = gtextField;
}
if (curField == null) return;
var textFormat = curField.textFormat;
var font = textFormat.GetCurLanguageFont();
if (font == null) return;
textFormat.font = font;
curField.textFormat = textFormat;
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: de429c9a72354bac8521f78835cda342
timeCreated: 1715247635

View File

@@ -1,23 +0,0 @@
using FairyGUI;
namespace NBC
{
/// <summary>
/// UI多语言
/// </summary>
public static class UILanguage
{
/// <summary>
/// 用于过滤界面设置语言时,避免导出脚本的组件重复设置语言
/// </summary>
public static bool isPanelSetting = false;
public static void TrySetComponentLanguage(GComponent component)
{
if (!isPanelSetting)
{
// UI.Inst.TrySetComponentLanguage(component);
}
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: f212c92129c344f2a73daa0f46b99010
timeCreated: 1715247696

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 553ce3a74f9346a2967b868fc9dec118
timeCreated: 1683269938

View File

@@ -1,16 +0,0 @@
namespace NBC
{
internal static class UIRunner
{
#region Static
public static readonly Runner Def = new Runner();
public static void Update()
{
Def.Process();
}
#endregion
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 43f3556ed98c4f62bcb1711410d01868
timeCreated: 1683269953