NBC修改

This commit is contained in:
bob
2025-07-03 14:16:18 +08:00
parent 4febfadd56
commit 800e96aac7
2083 changed files with 60081 additions and 2942 deletions

View File

@@ -1,42 +0,0 @@
using UnityEngine;
namespace NBC
{
public interface IUIPanel
{
FairyGUI.GComponent ContentPane { get; }
// string UILayer { get; }
/// <summary>
/// 模块id
/// </summary>
int Id { get; }
bool IsTop { get; }
bool IsShowing { get; }
bool IsCanVisible { get; }
bool IsDotDel { get; }
/// <summary>
/// 不能返回
/// </summary>
bool IsDontBack { get; }
bool IsModal { get; }
bool IsShowCursor { get; }
void SetUIManager(UIManager kit);
void SetData(object args);
object GetData();
string[] GetDependPackages();
void Init();
void Show();
void Hide();
void Update();
void HideImmediately();
void Refresh();
void Dispose();
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 85e70ef2de904307919fe91865311fc1
timeCreated: 1606989126

View File

@@ -1,308 +0,0 @@
using System;
using System.Collections.Generic;
using FairyGUI;
using UnityEngine;
namespace NBC
{
public abstract class UIPanel : IUIPanel
{
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 NTask ShowAnim = null;
/// <summary>
/// 面板关闭动画
/// </summary>
public NTask HideAnim = null;
private object _paramData;
private bool _isInited;
public GComponent ContentPane { get; protected set; }
protected UIManager _ui;
public void SetUIManager(UIManager 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.name = UIResName;
panelObj.SetSize(GRoot.inst.width, GRoot.inst.height);
panelObj.position = Vector3.zero;
panelObj.ToSafeArea();
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;
}
}
public void Show()
{
try
{
if (!IsShowing)
{
GRoot.inst.AddChild(ContentPane);
_ui.AdjustModalLayer();
}
else
{
if (!IsTop) _ui.BringToFront(this);
}
OpenAnimBegin();
if (ShowAnim != null)
{
ShowAnim.OnCompleted(OpenAnimFinished, true);
ShowAnim.Run(UIRunner.Def);
}
else
{
OpenAnimFinished(null);
}
}
catch (Exception e)
{
Log.Error($"UIPackName={UIPackName} UIResName={UIResName} e={e}");
throw;
}
}
public void Hide()
{
if (!IsShowing) return;
if (HideAnim != null)
{
HideAnim.OnCompleted(HideAnimFinished);
HideAnim.Run(UIRunner.Def);
}
else
{
HideAnimFinished(null);
}
}
public void Update()
{
OnUpdate();
}
public void Refresh()
{
Show();
}
/// <summary>
/// 设置刷新多语言
/// </summary>
public void SetLanguage()
{
_ui.TrySetPanelLanguage(ContentPane);
OnSetLanguage();
}
public void HideImmediately()
{
// ContentPane.visible = false;
if (ContentPane.parent != null)
{
// UIKit.
GRoot.inst.RemoveChild(ContentPane);
_ui.AdjustModalLayer();
_ui?.DispatchEventWith(UIEvents.UIHide, this);
// UIKit.LayerManager.RemoveChild(this);
}
OnHide();
}
public void Dispose()
{
if (!IsDotDel)
{
HideImmediately();
ContentPane.Dispose();
OnDestroy();
}
else
{
Log.Error("当前panel标记为不可删除name=" + UIResName);
}
}
private void OpenAnimBegin()
{
OnShow();
SetLanguage();
_ui?.DispatchEventWith(UIEvents.UIShow, this);
}
/// <summary>
/// 打开动画播放完成
/// </summary>
/// <param name="task"></param>
private void OpenAnimFinished(ITask task)
{
OnShowed();
}
/// <summary>
/// 关闭动画播放完成
/// </summary>
/// <param name="task"></param>
private void HideAnimFinished(ITask task)
{
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,139 +0,0 @@
using FairyGUI;
using UnityEngine;
namespace NBC
{
/// <summary>
/// ui界面默认动画
/// </summary>
public class PanelAnimationDef : NTask
{
public enum AnimType
{
CenterScaleBig = 0,
/// <summary>
/// 上往中滑动--
/// </summary>
UpToSlide = 1,
/// <summary>
/// //下往中滑动
/// </summary>
DownToSlide = 2,
/// <summary>
/// 左往中--
/// </summary>
LeftToSlide = 3,
/// <summary>
/// 右往中--
/// </summary>
RightToSlide = 4,
/// <summary>
/// 透明度
/// </summary>
Fade = 5
}
private bool _isClose;
private GComponent _node;
private AnimType _animType;
public PanelAnimationDef(GComponent node, AnimType animType = AnimType.CenterScaleBig, bool close = false)
{
_node = node;
_isClose = close;
_animType = animType;
}
protected override void OnStart()
{
if (_animType == AnimType.CenterScaleBig)
{
var strat = _isClose ? Vector3.one : Vector3.zero;
var end = _isClose ? Vector3.zero : Vector3.one;
var easeType = _isClose ? EaseType.BackIn : EaseType.BackOut;
GTween.To(strat, end, 0.5f)
.SetEase(easeType)
.SetTarget(_node, TweenPropType.Scale)
.OnComplete(Finish);
}
else if (_animType == AnimType.UpToSlide || _animType == AnimType.DownToSlide)
{
var hight = GRoot.inst.viewHeight;
var y = _animType == AnimType.UpToSlide ? -hight : hight;
var strat = _isClose ? 0 : y;
var end = _isClose ? y : 0;
GTween.To(strat, end, 0.5f)
.SetEase(EaseType.CubicOut)
.SetTarget(_node, TweenPropType.Y)
.OnComplete(Finish);
}
else if (_animType == AnimType.LeftToSlide || _animType == AnimType.RightToSlide)
{
var width = GRoot.inst.viewWidth;
var x = _animType == AnimType.LeftToSlide ? -width : width;
var strat = _isClose ? 0 : x;
var end = _isClose ? x : 0;
GTween.To(strat, end, 0.5f)
.SetEase(EaseType.CubicOut)
.SetTarget(_node, TweenPropType.X)
.OnComplete(Finish);
}
else if (_animType == AnimType.Fade)
{
var s = _isClose ? 1 : 0;
var end = _isClose ? 0 : 1;
_node.alpha = s;
GTween.To(s, end, 0.5f)
.SetEase(EaseType.Linear)
.SetTarget(_node, TweenPropType.Alpha)
.OnStart(() => { })
.OnComplete(Finish);
}
}
}
public static class UIPanelAnimation
{
public static NTask GetCenterScaleBig(IUIPanel panel, bool close = false)
{
return new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.CenterScaleBig, close);
}
public static NTask GetUpToSlide(IUIPanel panel, bool close = false)
{
return new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.UpToSlide, close);
}
public static NTask GetDownToSlide(IUIPanel panel, bool close = false)
{
return new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.DownToSlide, close);
}
public static NTask GetLeftToSlide(IUIPanel panel, bool close = false)
{
return new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.LeftToSlide, close);
}
public static NTask GetRightToSlide(IUIPanel panel, bool close = false)
{
return new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.RightToSlide, close);
}
public static NTask GetFade(IUIPanel panel, bool close = false)
{
return new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.Fade, close);
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 506db39b69774ef7bcafb6f744370e81
timeCreated: 1607328227