diff --git a/Assets/ResRaw/Fgui/Common/Common_atlas0.png b/Assets/ResRaw/Fgui/Common/Common_atlas0.png index 1389df8ec..6664fa457 100644 Binary files a/Assets/ResRaw/Fgui/Common/Common_atlas0.png and b/Assets/ResRaw/Fgui/Common/Common_atlas0.png differ diff --git a/Assets/ResRaw/Fgui/Common/Common_fui.bytes b/Assets/ResRaw/Fgui/Common/Common_fui.bytes index 851345b43..86628dc05 100644 Binary files a/Assets/ResRaw/Fgui/Common/Common_fui.bytes and b/Assets/ResRaw/Fgui/Common/Common_fui.bytes differ diff --git a/Assets/ResRaw/Fgui/Main/Main_fui.bytes b/Assets/ResRaw/Fgui/Main/Main_fui.bytes index 421f881a4..24743e199 100644 Binary files a/Assets/ResRaw/Fgui/Main/Main_fui.bytes and b/Assets/ResRaw/Fgui/Main/Main_fui.bytes differ diff --git a/Assets/Scripts/Common/Common/Services/Input/InputCursorExtension.cs b/Assets/Scripts/Common/Common/Services/Input/InputCursorExtension.cs index 52a6b0b6d..2ea86631b 100644 --- a/Assets/Scripts/Common/Common/Services/Input/InputCursorExtension.cs +++ b/Assets/Scripts/Common/Common/Services/Input/InputCursorExtension.cs @@ -38,7 +38,7 @@ namespace NBF break; } } - Log.Error($"showCursor={showCursor}"); + Log.Info($"showCursor={showCursor}"); InputManager.IsUIStopInput = showCursor; InputManager.SetMouseCursor(showCursor); } diff --git a/Assets/Scripts/Game.cs b/Assets/Scripts/Game.cs index 51c2a9d57..812abaa77 100644 --- a/Assets/Scripts/Game.cs +++ b/Assets/Scripts/Game.cs @@ -153,13 +153,14 @@ namespace NBF private void InitUI() { + UI.Inst.SetUITween(); Binder.BindAll(); UIObjectFactory.SetLoaderExtension(typeof(XGLoader)); UIConst.UIPackRootUrl = UIDef.UIRoot; UIConfig.verticalScrollBar = "ui://6hgkvlauoomej"; UIConfig.defaultFont = "AlibabaPuHuiTi-3-Medium"; UI.Inst.SetUILanguage(); - UIConfig.modalLayerColor = new Color(0, 0, 0, 0.99f); + UIConfig.modalLayerColor = new Color(1, 1, 1, 0.2f); AddUIPackages(); } diff --git a/Assets/Scripts/Init.cs b/Assets/Scripts/Init.cs index c432bfea3..a5454178f 100644 --- a/Assets/Scripts/Init.cs +++ b/Assets/Scripts/Init.cs @@ -61,7 +61,9 @@ namespace NBF // await Task.Delay(100); CommonTopPanel.Show(); // SettingPanel.Show(); - LoginPanel.Show(); + // LoginPanel.Show(); + // MessageBox.Show(); + FishingShopPanel.Show(); // PreviewPanel.Show(); } } diff --git a/Assets/Scripts/NBC/Core/Runtime/Task/Interface/IRunner.cs b/Assets/Scripts/NBC/Core/Runtime/Task/Interface/IRunner.cs index 8a8dc9e23..74dd508cf 100644 --- a/Assets/Scripts/NBC/Core/Runtime/Task/Interface/IRunner.cs +++ b/Assets/Scripts/NBC/Core/Runtime/Task/Interface/IRunner.cs @@ -27,7 +27,7 @@ /// /// 任务对象 void Run(ITask task); - + void Process(); /// diff --git a/Assets/Scripts/NBC/Core/Runtime/Task/Runner/Runner.cs b/Assets/Scripts/NBC/Core/Runtime/Task/Runner/Runner.cs index c6521f32b..1508c495b 100644 --- a/Assets/Scripts/NBC/Core/Runtime/Task/Runner/Runner.cs +++ b/Assets/Scripts/NBC/Core/Runtime/Task/Runner/Runner.cs @@ -33,6 +33,7 @@ namespace NBC { ReadyTask.Enqueue(task); } + public virtual void Process() { diff --git a/Assets/Scripts/NBC/UI/Runtime/Component/UIPanel.cs b/Assets/Scripts/NBC/UI/Runtime/Component/UIPanel.cs index 96786947a..67bea353b 100644 --- a/Assets/Scripts/NBC/UI/Runtime/Component/UIPanel.cs +++ b/Assets/Scripts/NBC/UI/Runtime/Component/UIPanel.cs @@ -24,7 +24,6 @@ namespace NBC 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; } @@ -43,12 +42,12 @@ namespace NBC /// /// 面板打开动画 /// - public NTask ShowAnim = null; + public UIAnimTask ShowAnim = null; /// /// 面板关闭动画 /// - public NTask HideAnim = null; + public UIAnimTask HideAnim = null; private object _paramData; private bool _isInited; @@ -141,16 +140,23 @@ namespace NBC if (!IsShowing) { GRoot.inst.AddChild(ContentPane); + ContentPane.visible = true; _ui.AdjustModalLayer(); } else { if (!IsTop) _ui.BringToFront(this); + if (IsModal) + { + _ui.AdjustModalLayer(); + } } + _ui.TryPlayPanelTween(ContentPane); OpenAnimBegin(); if (ShowAnim != null) { + ShowAnim.SetDefaultInfo(); ShowAnim.OnCompleted(OpenAnimFinished, true); ShowAnim.Run(UIRunner.Def); } @@ -171,6 +177,7 @@ namespace NBC if (!IsShowing) return; if (HideAnim != null) { + HideAnim.SetDefaultInfo(); HideAnim.OnCompleted(HideAnimFinished); HideAnim.Run(UIRunner.Def); } diff --git a/Assets/Scripts/NBC/UI/Runtime/Component/UIPanelAnimation.cs b/Assets/Scripts/NBC/UI/Runtime/Component/UIPanelAnimation.cs deleted file mode 100644 index c4e21404e..000000000 --- a/Assets/Scripts/NBC/UI/Runtime/Component/UIPanelAnimation.cs +++ /dev/null @@ -1,139 +0,0 @@ -using FairyGUI; -using UnityEngine; - -namespace NBC -{ - /// - /// ui界面默认动画 - /// - public class PanelAnimationDef : NTask - { - public enum AnimType - { - CenterScaleBig = 0, - - /// - /// 上往中滑动-- - /// - UpToSlide = 1, - - /// - /// //下往中滑动 - /// - DownToSlide = 2, - - /// - /// 左往中-- - /// - LeftToSlide = 3, - - /// - /// 右往中-- - /// - RightToSlide = 4, - - /// - /// 透明度 - /// - 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); - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/NBC/UI/Runtime/UIManager.cs b/Assets/Scripts/NBC/UI/Runtime/UIManager.cs index 8ca43353e..f86bffd5d 100644 --- a/Assets/Scripts/NBC/UI/Runtime/UIManager.cs +++ b/Assets/Scripts/NBC/UI/Runtime/UIManager.cs @@ -16,8 +16,12 @@ namespace NBC private GGraph _modalLayer; private GRoot _uiRoot; + private UIComponentLanguagePack _uiLanguageConfig; + // 新增 Tween 配置 + private UIComponentTweenPack _uiTweenConfig; + public void Start() { Log.Info("UI 模块初始化"); @@ -55,6 +59,7 @@ namespace NBC } else { + ApplyPanelRootTween(panel); // 根动效设置为 ShowAnim panel.Show(); } } @@ -94,6 +99,51 @@ namespace NBC #endregion + #region 动画 + + public void SetUITween() where T : UIComponentTweenPack + { + _uiTweenConfig = Activator.CreateInstance(); + } + + public void TryPlayComponentTween(GComponent component) + { + _uiTweenConfig?.TryPlayComponentTween(component); + } + + public void TryPlayPanelTween(GComponent component) + { + _uiTweenConfig?.TryPlayPanelTween(component); + } + + private void ApplyPanelRootTween(IUIPanel panel) + { + if (panel?.ContentPane == null || _uiTweenConfig == null) return; + var url = panel.ContentPane.resourceURL; + if (string.IsNullOrEmpty(url)) return; + var tweenName = _uiTweenConfig.GetRootTween(url); + if (string.IsNullOrEmpty(tweenName)) return; + if (panel is not UIPanel upPanel) return; // 需要具体 UIPanel 才能设置 ShowAnim + + if (upPanel.ShowAnim != null) return; + switch (tweenName) + { + case "Fade": upPanel.ShowAnim = UIPanelAnimation.GetFade(upPanel); break; + case "Scale": upPanel.ShowAnim = UIPanelAnimation.GetCenterScaleBig(upPanel); break; + case "Pop": upPanel.ShowAnim = UIPanelAnimation.GetCenterPopScaleFade(upPanel); break; + case "SlideInL": upPanel.ShowAnim = UIPanelAnimation.GetLeftToSlideFade(upPanel); break; + case "SlideInR": upPanel.ShowAnim = UIPanelAnimation.GetRightToSlideFade(upPanel); break; + case "SlideInT": upPanel.ShowAnim = UIPanelAnimation.GetUpToSlideFade(upPanel); break; + case "SlideInB": upPanel.ShowAnim = UIPanelAnimation.GetDownToSlideFade(upPanel); break; + case "Bounce": upPanel.ShowAnim = UIPanelAnimation.GetBounceVertical(upPanel); break; + case "Rotate": upPanel.ShowAnim = UIPanelAnimation.GetRotate(upPanel); break; + case "Shake": upPanel.ShowAnim = UIPanelAnimation.GetShake(upPanel); break; + default: break; + } + } + + #endregion + public void OpenUI(object param = null) { Type type = typeof(T); diff --git a/Assets/Scripts/NBC/UI/Runtime/UITween.meta b/Assets/Scripts/NBC/UI/Runtime/UITween.meta new file mode 100644 index 000000000..4aaab6eff --- /dev/null +++ b/Assets/Scripts/NBC/UI/Runtime/UITween.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b2fcace3b3ca4e21948ba0bce5002c82 +timeCreated: 1770173105 \ No newline at end of file diff --git a/Assets/Scripts/NBC/UI/Runtime/UITween/UIAnimTask.cs b/Assets/Scripts/NBC/UI/Runtime/UITween/UIAnimTask.cs new file mode 100644 index 000000000..87cb994c8 --- /dev/null +++ b/Assets/Scripts/NBC/UI/Runtime/UITween/UIAnimTask.cs @@ -0,0 +1,7 @@ +namespace NBC +{ + public abstract class UIAnimTask : NTask + { + public abstract void SetDefaultInfo(); + } +} \ No newline at end of file diff --git a/Assets/Scripts/NBC/UI/Runtime/UITween/UIAnimTask.cs.meta b/Assets/Scripts/NBC/UI/Runtime/UITween/UIAnimTask.cs.meta new file mode 100644 index 000000000..1951cb724 --- /dev/null +++ b/Assets/Scripts/NBC/UI/Runtime/UITween/UIAnimTask.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 22a6b4eac2614a4e9d0872508f9f7249 +timeCreated: 1770179810 \ No newline at end of file diff --git a/Assets/Scripts/NBC/UI/Runtime/UITween/UIPackageTween.cs b/Assets/Scripts/NBC/UI/Runtime/UITween/UIPackageTween.cs new file mode 100644 index 000000000..7843b8436 --- /dev/null +++ b/Assets/Scripts/NBC/UI/Runtime/UITween/UIPackageTween.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using FairyGUI; + +namespace NBC +{ + public class UIComponentTween : Dictionary + { + } + + /// + /// 组件动效配置包。与 UIComponentLanguagePack 结构类似,根据 resourceURL 映射到每个组件的子节点动效名称。 + /// + public abstract class UIComponentTweenPack : Dictionary + { + public bool Has(string url) + { + return ContainsKey(url); + } + + public void TryPlayComponentTween(GComponent component) + { + if (component == null || component.packageItem == null) return; + if (!Has(component.resourceURL)) return; + PlayComponentTween(component); + } + + /// + /// 面板调用,不判断是否存在,根节点如果配置了 __root__ 会播放。 + /// + public void TryPlayPanelTween(GComponent component) + { + if (component == null) return; + PlayComponentTween(component); + } + + public string GetRootTween(string url) + { + if (TryGetValue(url, out var cfg) && cfg != null && cfg.TryGetValue("__root__", out var tween)) + return tween; + return null; + } + + public void PlayComponentTween(GComponent component) + { + if (component == null) return; + bool comHasTweenConfig = false; + UIComponentTween tweenCfg = null; + if (component.packageItem != null && TryGetValue(component.resourceURL, out tweenCfg)) + { + comHasTweenConfig = 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) + { + PlayComponentTween(childCom); // 先递归子组件 + } + + if (comHasTweenConfig) + { + var id = child.id; + if (tweenCfg.TryGetValue(id, out var tweenName)) + { + PlayTween(child, tweenName); + } + } + } + + // 顶层UIPanel根节点动效改由 UIManager 设置 ShowAnim,不在这里直接播放 + if (component.parent == GRoot.inst) return; + // if (comHasTweenConfig && tweenCfg.TryGetValue("__root__", out var rootTween)) + // { + // PlayTween(component, rootTween); + // } + } + + private static readonly Dictionary> TweenMap = + new() + { + ["Fade"] = o => o.TweenFadeShow(), + ["Scale"] = o => o.TweenScaleShow(), + ["Pop"] = o => o.TweenPopShow(), + ["SlideInL"] = o => o.TweenSlideInLeft(), + ["SlideInR"] = o => o.TweenSlideInRight(), + ["SlideInT"] = o => o.TweenSlideInTop(), + ["SlideInB"] = o => o.TweenSlideInBottom(), + ["Bounce"] = o => o.TweenBounceShow(), + ["Rotate"] = o => o.TweenRotateShow(), + ["Shake"] = o => o.TweenShake() + }; + + private void PlayTween(GObject target, string tweenName) + { + if (target == null || string.IsNullOrEmpty(tweenName)) return; + if (TweenMap.TryGetValue(tweenName, out var act)) + act(target); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/NBC/UI/Runtime/UITween/UIPackageTween.cs.meta b/Assets/Scripts/NBC/UI/Runtime/UITween/UIPackageTween.cs.meta new file mode 100644 index 000000000..08891885a --- /dev/null +++ b/Assets/Scripts/NBC/UI/Runtime/UITween/UIPackageTween.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7cd2e8cf13594c1fbef585689b1fbffa +timeCreated: 1770173219 \ No newline at end of file diff --git a/Assets/Scripts/NBC/UI/Runtime/UITween/UIPanelAnimation.cs b/Assets/Scripts/NBC/UI/Runtime/UITween/UIPanelAnimation.cs new file mode 100644 index 000000000..e6053739f --- /dev/null +++ b/Assets/Scripts/NBC/UI/Runtime/UITween/UIPanelAnimation.cs @@ -0,0 +1,266 @@ +using FairyGUI; +using UnityEngine; + +namespace NBC +{ + /// + /// ui界面默认动画 + /// + public class PanelAnimationDef : UIAnimTask + { + public enum AnimType + { + CenterScaleBig = 0, + + /// 上往中滑动-- + UpToSlide = 1, + + /// //下往中滑动 + DownToSlide = 2, + + /// 左往中-- + LeftToSlide = 3, + + /// 右往中-- + RightToSlide = 4, + + /// 透明度 + Fade = 5, + + // + CenterPopScaleFade = 6, + UpToSlideFade = 7, + DownToSlideFade = 8, + LeftToSlideFade = 9, + RightToSlideFade = 10, + BounceVertical = 11, + Rotate = 12, + Shake = 13, + } + + private bool _isClose; + private GComponent _node; + private AnimType _animType; + private float _animTime; + + + public PanelAnimationDef(GComponent node, AnimType animType = AnimType.CenterScaleBig, bool close = false, + float animTime = 0.5F) + { + _node = node; + _isClose = close; + _animType = animType; + _animTime = animTime; + } + + protected override void OnStart() + { + if (_node == null) + { + Finish(); + return; + } + + // 直接使用 UITweenDynamic 扩展方法处理新增复合效果 + switch (_animType) + { + case AnimType.CenterPopScaleFade: + if (!_isClose) + _node.TweenPopShow(callback: Finish); + else + _node.TweenPopHide(callback: Finish); + return; + case AnimType.UpToSlideFade: + if (!_isClose) + _node.TweenSlideInTop(callback: Finish); + else + _node.TweenSlideOutTop(callback: Finish); + return; + case AnimType.DownToSlideFade: + if (!_isClose) + _node.TweenSlideInBottom(callback: Finish); + else + _node.TweenSlideOutBottom(callback: Finish); + return; + case AnimType.LeftToSlideFade: + if (!_isClose) + _node.TweenSlideInLeft(callback: Finish); + else + _node.TweenSlideOutLeft(callback: Finish); + return; + case AnimType.RightToSlideFade: + if (!_isClose) + _node.TweenSlideInRight(callback: Finish); + else + _node.TweenSlideOutRight(callback: Finish); + return; + case AnimType.BounceVertical: + if (!_isClose) + _node.TweenBounceShow(callback: Finish); // 向上偏移进入 + else + _node.TweenBounceHide(callback: Finish); + return; + case AnimType.Rotate: + if (!_isClose) + _node.TweenRotateShow(callback: Finish); + else + _node.TweenRotateHide(callback: Finish); + return; + case AnimType.Shake: + // shake 只在打开时使用,关闭直接结束 + if (_isClose) + { + Finish(); + return; + } + + _node.TweenShakeShow(callback: Finish); + return; + } + + + 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, _animTime) + .SetEase(easeType) + .SetTarget(_node, TweenPropType.Scale) + .OnComplete(Finish); + } + else if (_animType == AnimType.UpToSlide || _animType == AnimType.DownToSlide) + { + var safeAreaY = UI.Inst.GetSafeArea().y; + var hight = GRoot.inst.viewHeight; + var y = _animType == AnimType.UpToSlide ? -hight : hight; + var strat = _isClose ? 0 : y; + var end = _isClose ? y : safeAreaY; + GTween.To(strat, end, _animTime) + .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, _animTime) + .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, _animTime) + .SetEase(EaseType.Linear) + .SetTarget(_node, TweenPropType.Alpha) + .OnComplete(Finish); + } + } + + /// + /// 设置默认的状态 + /// + public override void SetDefaultInfo() + { + switch (_animType) + { + case AnimType.CenterScaleBig: + _node.scale = _isClose ? Vector2.one : Vector2.zero; + break; + case AnimType.UpToSlide: + case AnimType.DownToSlide: + var hight = GRoot.inst.viewHeight; + var y = _animType == AnimType.UpToSlide ? -hight : hight; + _node.y = _isClose ? 0 : y; + break; + case AnimType.LeftToSlide: + case AnimType.RightToSlide: + var width = GRoot.inst.viewWidth; + var x = _animType == AnimType.LeftToSlide ? -width : width; + _node.x = _isClose ? 0 : x; + break; + case AnimType.Fade: + _node.alpha = _isClose ? 1 : 0; + break; + case AnimType.CenterPopScaleFade: + _node.scale = _isClose ? Vector2.one : new Vector2(0.8f, 0.8f); + _node.alpha = _isClose ? 1 : 0; + break; + case AnimType.UpToSlideFade: + + break; + case AnimType.DownToSlideFade: + + break; + case AnimType.LeftToSlideFade: + + break; + case AnimType.RightToSlideFade: + + break; + case AnimType.BounceVertical: + + break; + case AnimType.Rotate: + + break; + case AnimType.Shake: + + break; + } + } + } + + public static class UIPanelAnimation + { + public static UIAnimTask GetCenterScaleBig(IUIPanel panel, bool close = false, float animTime = 0.5F) + => new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.CenterScaleBig, close, animTime); + + public static UIAnimTask GetUpToSlide(IUIPanel panel, bool close = false, float animTime = 0.5F) + => new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.UpToSlide, close, animTime); + + public static UIAnimTask GetDownToSlide(IUIPanel panel, bool close = false, float animTime = 0.5F) + => new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.DownToSlide, close, animTime); + + public static UIAnimTask GetLeftToSlide(IUIPanel panel, bool close = false, float animTime = 0.5F) + => new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.LeftToSlide, close, animTime); + + public static UIAnimTask GetRightToSlide(IUIPanel panel, bool close = false, float animTime = 0.5F) + => new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.RightToSlide, close, animTime); + + public static UIAnimTask GetFade(IUIPanel panel, bool close = false, float animTime = 0.5F) + => new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.Fade, close, animTime); + + // 新增复合动效获取方法 + public static UIAnimTask GetCenterPopScaleFade(IUIPanel panel, bool close = false) + => new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.CenterPopScaleFade, close); + + public static UIAnimTask GetUpToSlideFade(IUIPanel panel, bool close = false) + => new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.UpToSlideFade, close); + + public static UIAnimTask GetDownToSlideFade(IUIPanel panel, bool close = false) + => new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.DownToSlideFade, close); + + public static UIAnimTask GetLeftToSlideFade(IUIPanel panel, bool close = false) + => new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.LeftToSlideFade, close); + + public static UIAnimTask GetRightToSlideFade(IUIPanel panel, bool close = false) + => new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.RightToSlideFade, close); + + public static UIAnimTask GetBounceVertical(IUIPanel panel, bool close = false) + => new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.BounceVertical, close); + + public static UIAnimTask GetRotate(IUIPanel panel, bool close = false) + => new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.Rotate, close); + + public static UIAnimTask GetShake(IUIPanel panel, bool close = false) + => new PanelAnimationDef(panel.ContentPane, PanelAnimationDef.AnimType.Shake, close); + } +} \ No newline at end of file diff --git a/Assets/Scripts/NBC/UI/Runtime/Component/UIPanelAnimation.cs.meta b/Assets/Scripts/NBC/UI/Runtime/UITween/UIPanelAnimation.cs.meta similarity index 100% rename from Assets/Scripts/NBC/UI/Runtime/Component/UIPanelAnimation.cs.meta rename to Assets/Scripts/NBC/UI/Runtime/UITween/UIPanelAnimation.cs.meta diff --git a/Assets/Scripts/NBC/UI/Runtime/UITween/UITweenDynamic.cs b/Assets/Scripts/NBC/UI/Runtime/UITween/UITweenDynamic.cs new file mode 100644 index 000000000..39cad0a94 --- /dev/null +++ b/Assets/Scripts/NBC/UI/Runtime/UITween/UITweenDynamic.cs @@ -0,0 +1,840 @@ +using System; +using System.Collections.Generic; +using FairyGUI; +using UnityEngine; + +namespace NBC +{ + public enum UISlideDirection + { + Left, + Right, + Top, + Bottom + } + + public static class UITweenDynamic + { + private class TweenContext + { + public GObject target; + public float alpha; + public float scaleX; + public float scaleY; + public Vector3 position; + public float rotation; + public bool visible; + public Action callback; + } + + private static readonly Dictionary _contexts = new Dictionary(); + + private static TweenContext Capture(GObject target, Action callback) + { + return new TweenContext + { + target = target, + alpha = target.alpha, + scaleX = target.scaleX, + scaleY = target.scaleY, + position = target.position, + rotation = target.rotation, + visible = target.visible, + callback = callback + }; + } + + // 启动新动画:如存在旧动画,先还原并调用旧回调,再杀死旧 tweens,注册新上下文 + private static TweenContext StartNewAnimation(GObject target, Action newCallback) + { + if (target == null) return null; + if (_contexts.TryGetValue(target, out var oldCtx)) + { + // 还原旧动画状态 + if (oldCtx.target != null) + { + oldCtx.target.alpha = oldCtx.alpha; + oldCtx.target.SetScale(oldCtx.scaleX, oldCtx.scaleY); + oldCtx.target.position = oldCtx.position; + oldCtx.target.rotation = oldCtx.rotation; + oldCtx.target.visible = oldCtx.visible; + } + + // 调用旧动画的回调 + oldCtx.callback?.Invoke(); + _contexts.Remove(target); + } + + GTween.Kill(target); + var ctx = Capture(target, newCallback); + _contexts[target] = ctx; + return ctx; + } + + private static void FinishAnimation(GObject target) + { + if (target == null) return; + if (_contexts.TryGetValue(target, out var ctx)) + { + _contexts.Remove(target); + ctx.callback?.Invoke(); + } + } + + #region UIPanel UI动效 (wrappers) + + public static void TweenFadeShow(this T self, float duration = 0.45f, Action callback = null) + where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenFadeShow(duration, callback); + } + + public static void TweenFadeHide(this T self, float duration = 0.3f, Action callback = null) + where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenFadeHide(duration, callback); + } + + public static void TweenScaleShow(this T self, float duration = 0.3f, + float fromScale = 0.8f, EaseType ease = EaseType.BackOut, Action callback = null) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + // GComponent.TweenScaleShow signature: (duration, callback, fromScale, ease) + pane.TweenScaleShow(duration, callback, fromScale, ease); + } + + public static void TweenScaleHide(this T self, float duration = 0.2f, + float toScale = 0.8f, EaseType ease = EaseType.QuadIn, bool resetAfter = true, bool setInvisible = true, + Action callback = null) + where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + // GComponent.TweenScaleHide signature: (duration, callback, toScale, ease, resetAfter, setInvisible) + pane.TweenScaleHide(duration, callback, toScale, ease, resetAfter, setInvisible); + } + + public static void TweenPopShow(this T self, float duration = 0.2f, + float fromScale = 0.8f, EaseType ease = EaseType.BackOut, Action callback = null) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenPopShow(duration, callback, fromScale, ease); + } + + public static void TweenPopHide(this T self, float duration = 0.2f, Action callback = null, + float toScale = 0.8f, EaseType ease = EaseType.QuadIn, bool setInvisible = true) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenPopHide(duration, callback, toScale, ease, setInvisible); + } + + public static void TweenSlideInLeft(this T self, float moveTime = 0.5f, float startFadeTimeRate = 0.42f, + float startAlpha = 0, float alphaTime = 0.1f, float extraOffset = 0f, EaseType ease = EaseType.CubicOut, + Action callback = null) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenSlideInLeft(moveTime, startFadeTimeRate, startAlpha, alphaTime, extraOffset, ease, callback); + } + + public static void TweenSlideOutLeft(this T self, float moveTime = 0.3f, float startFadeTimeRate = 0, + float alphaTime = 0.08f, float extraOffset = 0f, EaseType ease = EaseType.QuadIn, + bool resetAfter = true, bool setInvisible = true, Action callback = null) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenSlideOutLeft(moveTime, startFadeTimeRate, alphaTime, extraOffset, ease, resetAfter, setInvisible, + callback); + } + + public static void TweenSlideInRight(this T self, float moveTime = 0.5f, float startFadeTimeRate = 0.42f, + float startAlpha = 0, float alphaTime = 0.1f, float extraOffset = 0f, EaseType ease = EaseType.CubicOut, + Action callback = null) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenSlideInRight(moveTime, startFadeTimeRate, startAlpha, alphaTime, extraOffset, ease, callback); + } + + public static void TweenSlideOutRight(this T self, float moveTime = 0.3f, float startFadeTimeRate = 0, + float alphaTime = 0.08f, float extraOffset = 0f, EaseType ease = EaseType.QuadIn, + bool resetAfter = true, bool setInvisible = true, Action callback = null) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenSlideOutRight(moveTime, startFadeTimeRate, alphaTime, extraOffset, ease, resetAfter, setInvisible, + callback); + } + + public static void TweenSlideInTop(this T self, float moveTime = 0.35f, float startFadeTimeRate = 0.3f, + float startAlpha = 0, float alphaTime = 0.1f, float extraOffset = 0f, EaseType ease = EaseType.CubicOut, + Action callback = null) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenSlideInTop(moveTime, startFadeTimeRate, startAlpha, alphaTime, extraOffset, ease, callback); + } + + public static void TweenSlideOutTop(this T self, float moveTime = 0.3f, float startFadeTimeRate = 0, + float alphaTime = 0.1f, float extraOffset = 0f, EaseType ease = EaseType.QuadIn, + bool resetAfter = true, bool setInvisible = true, Action callback = null) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenSlideOutTop(moveTime, startFadeTimeRate, alphaTime, extraOffset, ease, resetAfter, setInvisible, + callback); + } + + public static void TweenSlideInBottom(this T self, float moveTime = 0.35f, float startFadeTimeRate = 0.3f, + float startAlpha = 0, float alphaTime = 0.1f, float extraOffset = 0f, EaseType ease = EaseType.CubicOut, + Action callback = null) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenSlideInBottom(moveTime, startFadeTimeRate, startAlpha, alphaTime, extraOffset, ease, callback); + } + + public static void TweenSlideOutBottom(this T self, float moveTime = 0.3f, float startFadeTimeRate = 0, + float alphaTime = 0.1f, float extraOffset = 0f, EaseType ease = EaseType.QuadIn, bool resetAfter = true, + bool setInvisible = true, Action callback = null) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenSlideOutBottom(moveTime, startFadeTimeRate, alphaTime, extraOffset, ease, resetAfter, + setInvisible, callback); + } + + public static void TweenSlideIn(this T self, UISlideDirection direction, float moveTime = 0.35f, + float startFadeTimeRate = 0.1f, + float startAlpha = 0, float alphaTime = 0.2f, float extraOffset = 0f, EaseType ease = EaseType.QuadOut, + Action callback = null) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenSlideIn(direction, moveTime, startFadeTimeRate, startAlpha, alphaTime, extraOffset, ease, + callback); + } + + public static void TweenSlideOut(this T self, UISlideDirection direction, float moveTime = 0.35f, + float startFadeTimeRate = 0.1f, + float alphaTime = 0.2f, float extraOffset = 0f, EaseType ease = EaseType.QuadIn, bool resetAfter = true, + bool setInvisible = true, Action callback = null) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenSlideOut(direction, moveTime, startFadeTimeRate, alphaTime, extraOffset, ease, resetAfter, + setInvisible, callback); + } + + public static void TweenBounceShow(this T self, float duration = 0.4f, Action callback = null, + float fromYOffset = -100f) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenBounceShow(duration, callback, fromYOffset); + } + + public static void TweenBounceHide(this T self, float duration = 0.25f, Action callback = null, + float toYOffset = 100f, bool resetAfter = true, bool setInvisible = true) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenBounceHide(duration, callback, toYOffset, resetAfter, setInvisible); + } + + public static void TweenRotateShow(this T self, float duration = 0.2f, Action callback = null, + float fromRotation = -90f, EaseType ease = EaseType.BackOut) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenRotateShow(duration, callback, fromRotation, ease); + } + + public static void TweenRotateHide(this T self, float duration = 0.2f, Action callback = null, + float toRotation = -90f, EaseType ease = EaseType.QuadIn, bool resetAfter = true, bool setInvisible = true) + where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenRotateHide(duration, callback, toRotation, ease, resetAfter, setInvisible); + } + + public static void TweenShake(this T self, float duration = 0.4f, Action callback = null, + float amplitude = 12f, bool horizontal = true, int vibrato = 6) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenShake(duration, callback, amplitude, horizontal, vibrato); + } + + public static void TweenShakeShow(this T self, float durationScale = 0.2f, float ScaleStart = 0.3f, + float ScaleEnd = 1f, int shake = 4, + float shakeRotation = 18f, float duration = 1, Action callback = null) where T : IUIPanel + { + var pane = self?.ContentPane; + if (pane == null) + { + callback?.Invoke(); + return; + } + + pane.TweenShakeShow(durationScale, ScaleStart, ScaleEnd, shake, shakeRotation, duration, callback); + } + + #endregion + + #region GComponent UI动效 + + public static void TweenFadeShow(this GObject self, float duration = 0.45f, Action callback = null) + { + if (self == null || duration <= 0f) + { + callback?.Invoke(); + return; + } + + StartNewAnimation(self, callback); + self.alpha = 0f; + self.TweenFade(1f, duration).OnComplete(() => { FinishAnimation(self); }); + } + + public static void TweenFadeHide(this GObject self, float duration = 0.3f, Action callback = null) + { + if (self == null || duration <= 0f) + { + callback?.Invoke(); + return; + } + + StartNewAnimation(self, callback); + self.alpha = 1f; + self.TweenFade(0f, duration).OnComplete(() => { FinishAnimation(self); }); + } + + public static void TweenScaleShow(this GObject self, float duration = 0.3f, Action callback = null, + float fromScale = 0f, EaseType ease = EaseType.BackOut) + { + if (self == null || duration <= 0f) + { + callback?.Invoke(); + return; + } + + StartNewAnimation(self, callback); + self.SetPivot(0.5f, 0.5f, false); + self.SetScale(0, 0); + var ox = self.scaleX; + var oy = self.scaleY; + self.visible = true; + self.SetScale(fromScale, fromScale); + self.TweenScale(new Vector2(ox, oy), duration).SetEase(ease).OnComplete(() => { FinishAnimation(self); }); + } + + public static void TweenScaleHide(this GObject self, float duration = 0.2f, Action callback = null, + float toScale = 0.8f, EaseType ease = EaseType.QuadIn, bool resetAfter = true, bool setInvisible = true) + { + if (self == null || duration <= 0f) + { + callback?.Invoke(); + return; + } + + StartNewAnimation(self, callback); + self.SetPivot(0.5f, 0.5f, false); + self.SetScale(1, 1); + var ox = self.scaleX; + var oy = self.scaleY; + self.TweenScale(new Vector2(toScale, toScale), duration).SetEase(ease).OnComplete(() => + { + if (resetAfter) self.SetScale(ox, oy); + if (setInvisible) self.visible = false; + FinishAnimation(self); + }); + } + + public static void TweenPopShow(this GObject self, float duration = 0.2f, Action callback = null, + float fromScale = 0.8f, EaseType ease = EaseType.BackOut) + { + if (self == null || duration <= 0f) + { + callback?.Invoke(); + return; + } + + StartNewAnimation(self, callback); + var ox = self.scaleX; + var oy = self.scaleY; + self.visible = true; + self.SetScale(fromScale, fromScale); + self.alpha = 0f; + int remain = 2; + + void Done() + { + if (--remain == 0) FinishAnimation(self); + } + + self.TweenScale(new Vector2(ox, oy), duration).SetEase(ease).OnComplete(Done); + self.TweenFade(1f, duration * 0.9f).SetEase(EaseType.QuadOut).OnComplete(Done); + } + + public static void TweenPopHide(this GObject self, float duration = 0.2f, Action callback = null, + float toScale = 0.8f, EaseType ease = EaseType.QuadIn, bool setInvisible = true) + { + if (self == null || duration <= 0f) + { + callback?.Invoke(); + return; + } + + StartNewAnimation(self, callback); + var ox = self.scaleX; + var oy = self.scaleY; + int remain = 2; + + void Done() + { + if (--remain == 0) + { + self.SetScale(ox, oy); + if (setInvisible) self.visible = false; + FinishAnimation(self); + } + } + + self.TweenScale(new Vector2(toScale, toScale), duration).SetEase(ease).OnComplete(Done); + self.TweenFade(0f, duration * 0.9f).SetEase(EaseType.QuadIn).OnComplete(Done); + } + + public static void TweenSlideInLeft(this GObject self, float moveTime = 0.5f, float startFadeTimeRate = 0.42f + , float startAlpha = 0, float alphaTime = 0.1f + , float extraOffset = 0f, EaseType ease = EaseType.CubicOut, + Action callback = null) + { + TweenSlideIn(self, UISlideDirection.Left, moveTime, startFadeTimeRate, startAlpha, alphaTime, extraOffset, + ease, callback); + } + + public static void TweenSlideOutLeft(this GObject self, float moveTime = 0.3f, float startFadeTimeRate = 0 + , float alphaTime = 0.08f, + float extraOffset = 0f, EaseType ease = EaseType.QuadIn, + bool resetAfter = true, bool setInvisible = true, + Action callback = null) + { + TweenSlideOut(self, UISlideDirection.Left, moveTime, startFadeTimeRate, alphaTime, extraOffset, ease, + resetAfter, setInvisible, callback); + } + + public static void TweenSlideInRight(this GObject self, float moveTime = 0.5f, float startFadeTimeRate = 0.42f + , float startAlpha = 0, float alphaTime = 0.1f + , float extraOffset = 0f, EaseType ease = EaseType.CubicOut, + Action callback = null) + { + TweenSlideIn(self, UISlideDirection.Right, moveTime, startFadeTimeRate, startAlpha, alphaTime, extraOffset, + ease, callback); + } + + public static void TweenSlideOutRight(this GObject self, float moveTime = 0.3f, float startFadeTimeRate = 0 + , float alphaTime = 0.08f, + float extraOffset = 0f, EaseType ease = EaseType.QuadIn, + bool resetAfter = true, bool setInvisible = true, + Action callback = null) + { + TweenSlideOut(self, UISlideDirection.Right, moveTime, startFadeTimeRate, alphaTime, extraOffset, ease, + resetAfter, setInvisible, callback); + } + + public static void TweenSlideInTop(this GObject self, float moveTime = 0.35f, float startFadeTimeRate = 0.3f + , float startAlpha = 0, float alphaTime = 0.1f + , float extraOffset = 0f, EaseType ease = EaseType.CubicOut, + Action callback = null) + { + TweenSlideIn(self, UISlideDirection.Top, moveTime, startFadeTimeRate, startAlpha, alphaTime, extraOffset, + ease, callback); + } + + public static void TweenSlideOutTop(this GObject self, float moveTime = 0.3f, float startFadeTimeRate = 0 + , float alphaTime = 0.1f, + float extraOffset = 0f, EaseType ease = EaseType.QuadIn, + bool resetAfter = true, bool setInvisible = true, + Action callback = null) + { + TweenSlideOut(self, UISlideDirection.Top, moveTime, startFadeTimeRate, alphaTime, extraOffset, ease, + resetAfter, setInvisible, callback); + } + + public static void TweenSlideInBottom(this GObject self, float moveTime = 0.35f, float startFadeTimeRate = 0.3f + , float startAlpha = 0, float alphaTime = 0.1f + , float extraOffset = 0f, EaseType ease = EaseType.CubicOut, + Action callback = null) + { + TweenSlideIn(self, UISlideDirection.Bottom, moveTime, startFadeTimeRate, startAlpha, alphaTime, extraOffset, + ease, callback); + } + + public static void TweenSlideOutBottom(this GObject self, float moveTime = 0.3f, float startFadeTimeRate = 0 + , float alphaTime = 0.1f, + float extraOffset = 0f, EaseType ease = EaseType.QuadIn, + bool resetAfter = true, bool setInvisible = true, + Action callback = null) + { + TweenSlideOut(self, UISlideDirection.Bottom, moveTime, startFadeTimeRate, alphaTime, extraOffset, ease, + resetAfter, setInvisible, callback); + } + + + public static void TweenSlideIn(this GObject self, UISlideDirection direction, float moveTime = 0.35f, + float startFadeTimeRate = 0.1f + , float startAlpha = 0, float alphaTime = 0.2f + , float extraOffset = 0f, EaseType ease = EaseType.QuadOut, + Action callback = null) + { + if (self == null || moveTime <= 0f) + { + callback?.Invoke(); + return; + } + + StartNewAnimation(self, callback); + var ori = self.position; + float startX = ori.x; + float startY = ori.y; + switch (direction) + { + case UISlideDirection.Left: startX = startX + (-self.width / 2) - Math.Max(0f, extraOffset); break; + case UISlideDirection.Right: startX = startX + (self.width / 2) + Math.Max(0f, extraOffset); break; + case UISlideDirection.Top: startY = startY + (-self.height / 2) - Math.Max(0f, extraOffset); break; + case UISlideDirection.Bottom: startY = startY + (self.height / 2) + Math.Max(0f, extraOffset); break; + } + + self.visible = true; + self.alpha = startAlpha; + self.position = new Vector3(startX, startY, ori.z); + float startFadeTime = moveTime * startFadeTimeRate; + int remain = 3; + + void Done() + { + if (--remain == 0) FinishAnimation(self); + } + + GTweener moveTweener = (direction == UISlideDirection.Left || direction == UISlideDirection.Right) + ? self.TweenMoveX(ori.x, moveTime) + : self.TweenMoveY(ori.y, moveTime); + moveTweener.SetEase(ease).OnComplete(Done); + self.TweenFade(startAlpha, startFadeTime).OnComplete(() => + { + Done(); + self.TweenFade(1, alphaTime).SetEase(EaseType.QuadOut).OnComplete(Done); + }); + } + + public static void TweenSlideOut(this GObject self, UISlideDirection direction, float moveTime = 0.35f, + float startFadeTimeRate = 0.1f + , float alphaTime = 0.2f, + float extraOffset = 0f, EaseType ease = EaseType.QuadIn, + bool resetAfter = true, bool setInvisible = true, + Action callback = null) + { + if (self == null || moveTime <= 0f) + { + callback?.Invoke(); + return; + } + + StartNewAnimation(self, callback); + var ori = self.position; + float endX = ori.x; + float endY = ori.y; + switch (direction) + { + case UISlideDirection.Left: endX = endX + (-self.width / 2) - Math.Max(0f, extraOffset); break; + case UISlideDirection.Right: endX = endX + (self.width / 2) + Math.Max(0f, extraOffset); break; + case UISlideDirection.Top: endY = endX + (-self.height / 2) - Math.Max(0f, extraOffset); break; + case UISlideDirection.Bottom: endY = endX + (self.height / 2) + Math.Max(0f, extraOffset); break; + } + + float startAlpha = self.alpha; + float startFadeTime = moveTime * startFadeTimeRate; + int remain = 3; + + void Done() + { + if (--remain == 0) + { + if (resetAfter) self.position = ori; + if (setInvisible) self.visible = false; + FinishAnimation(self); + } + } + + GTweener moveTweener = (direction == UISlideDirection.Left || direction == UISlideDirection.Right) + ? self.TweenMoveX(endX, moveTime) + : self.TweenMoveY(endY, moveTime); + moveTweener.SetEase(ease).OnComplete(Done); + + self.TweenFade(startAlpha, startFadeTime).OnComplete(() => + { + Done(); + self.TweenFade(0, alphaTime).SetEase(EaseType.QuadOut).OnComplete(Done); + }); + } + + public static void TweenBounceShow(this GObject self, float duration = 0.4f, Action callback = null, + float fromYOffset = -100f) + { + if (self == null || duration <= 0f) + { + callback?.Invoke(); + return; + } + + StartNewAnimation(self, callback); + var ori = self.position; + self.visible = true; + self.position = new Vector3(ori.x, ori.y + fromYOffset, ori.z); + self.TweenMoveY(ori.y, duration).SetEase(EaseType.BounceOut).OnComplete(() => { FinishAnimation(self); }); + } + + public static void TweenBounceHide(this GObject self, float duration = 0.25f, Action callback = null, + float toYOffset = 100f, bool resetAfter = true, bool setInvisible = true) + { + if (self == null || duration <= 0f) + { + callback?.Invoke(); + return; + } + + StartNewAnimation(self, callback); + var ori = self.position; + self.TweenMoveY(ori.y + toYOffset, duration).SetEase(EaseType.QuadIn).OnComplete(() => + { + if (resetAfter) self.position = ori; + if (setInvisible) self.visible = false; + FinishAnimation(self); + }); + } + + public static void TweenRotateShow(this GObject self, float duration = 0.2f, Action callback = null, + float fromRotation = -90f, EaseType ease = EaseType.BackOut) + { + if (self == null || duration <= 0f) + { + callback?.Invoke(); + return; + } + + StartNewAnimation(self, callback); + float ori = self.rotation; + self.visible = true; + self.rotation = fromRotation; + self.TweenRotate(ori, duration).SetEase(ease).OnComplete(() => { FinishAnimation(self); }); + } + + public static void TweenRotateHide(this GObject self, float duration = 0.2f, Action callback = null, + float toRotation = -90f, EaseType ease = EaseType.QuadIn, bool resetAfter = true, bool setInvisible = true) + { + if (self == null || duration <= 0f) + { + callback?.Invoke(); + return; + } + + StartNewAnimation(self, callback); + float ori = self.rotation; + self.TweenRotate(toRotation, duration).SetEase(ease).OnComplete(() => + { + if (resetAfter) self.rotation = ori; + if (setInvisible) self.visible = false; + FinishAnimation(self); + }); + } + + public static void TweenShake(this GObject self, float duration = 0.4f, Action callback = null, + float amplitude = 12f, bool horizontal = true, int vibrato = 6) + { + if (self == null || vibrato <= 0 || amplitude <= 0f || duration <= 0f) + { + callback?.Invoke(); + return; + } + + StartNewAnimation(self, callback); + var ori = self.position; + float single = duration / (vibrato * 2f); + var end = horizontal + ? new Vector3(ori.x + amplitude, ori.y, ori.z) + : new Vector3(ori.x, ori.y + amplitude, ori.z); + self.TweenMove(end, single).SetEase(EaseType.Linear).SetRepeat(vibrato * 2, true).OnComplete(() => + { + self.position = ori; + FinishAnimation(self); + }); + } + + public static void TweenShakeShow(this GObject self, float durationScale = 0.2f, float ScaleStart = 0.3f, + float ScaleEnd = 1f, int shake = 4, + float shakeRotation = 18f, float duration = 1, Action callback = null) + { + if (self == null) + { + callback?.Invoke(); + return; + } + + StartNewAnimation(self, callback); + + int remain = 4; + + void Done() + { + if (--remain == 0) + { + FinishAnimation(self); + } + } + + self.scale = Vector2.one * ScaleStart; + self.rotation = -shakeRotation; + + float scaleEndTime = 0.2f; + float rotaEndTime = 0.1f; + float allIns = durationScale + scaleEndTime + rotaEndTime; + duration = allIns > duration ? allIns : duration; + + float rotaTime = (duration - durationScale - scaleEndTime - rotaEndTime) / shake; + self.TweenScale(Vector2.one * ScaleEnd * 1.1f, durationScale) + .OnComplete(() => + { + FinishAnimation(self); + self.TweenRotate(shakeRotation, rotaTime).SetRepeat(shake, true) + .OnComplete(() => + { + FinishAnimation(self); + self.TweenRotate(0, rotaEndTime).OnComplete(() => + { + FinishAnimation(self); + self.TweenScale(Vector2.one * ScaleEnd, scaleEndTime).OnComplete(() => + { + FinishAnimation(self); + }); + }); + }); + }); + } + + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/NBC/UI/Runtime/UITween/UITweenDynamic.cs.meta b/Assets/Scripts/NBC/UI/Runtime/UITween/UITweenDynamic.cs.meta new file mode 100644 index 000000000..8fcecb623 --- /dev/null +++ b/Assets/Scripts/NBC/UI/Runtime/UITween/UITweenDynamic.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d0b1d4565de947b99f0a88d7753e8897 +timeCreated: 1770172925 \ No newline at end of file diff --git a/Assets/Scripts/UI/Binders/CommonBinder.cs b/Assets/Scripts/UI/Binders/CommonBinder.cs index 06a277773..672c7eeee 100644 --- a/Assets/Scripts/UI/Binders/CommonBinder.cs +++ b/Assets/Scripts/UI/Binders/CommonBinder.cs @@ -16,7 +16,6 @@ namespace NBF UIObjectFactory.SetPackageItemExtension(ClassifyList.URL, typeof(ClassifyList)); UIObjectFactory.SetPackageItemExtension(CommonMenu.URL, typeof(CommonMenu)); UIObjectFactory.SetPackageItemExtension(MarqueeTag.URL, typeof(MarqueeTag)); - UIObjectFactory.SetPackageItemExtension(BtnSubMenuLeft.URL, typeof(BtnSubMenuLeft)); UIObjectFactory.SetPackageItemExtension(BtnTextInputControl.URL, typeof(BtnTextInputControl)); UIObjectFactory.SetPackageItemExtension(CommonItemList.URL, typeof(CommonItemList)); UIObjectFactory.SetPackageItemExtension(BtnTitleInputControl.URL, typeof(BtnTitleInputControl)); diff --git a/Assets/Scripts/UI/Common/Panel/MessageBox.Designer.cs b/Assets/Scripts/UI/Common/Panel/MessageBox.Designer.cs index f5d32adcc..26755b825 100644 --- a/Assets/Scripts/UI/Common/Panel/MessageBox.Designer.cs +++ b/Assets/Scripts/UI/Common/Panel/MessageBox.Designer.cs @@ -18,14 +18,16 @@ namespace NBF public Controller MessageStyle; [AutoFind(Name = "back")] public GImage back; - [AutoFind(Name = "box")] - public GImage box; [AutoFind(Name = "TextTitle")] public GTextField TextTitle; + [AutoFind(Name = "TextContent")] + public GTextField TextContent; [AutoFind(Name = "BtnCancel")] public BtnTitleInputControl BtnCancel; [AutoFind(Name = "BtnConfirm")] public BtnTitleInputControl BtnConfirm; + [AutoFind(Name = "t0")] + public Transition t0; public override string[] GetDependPackages(){ return new string[] {}; } public static void Show(object param = null){ UI.Inst.OpenUI(param); } diff --git a/Assets/Scripts/UI/Common/Panel/MessageBox.cs b/Assets/Scripts/UI/Common/Panel/MessageBox.cs index 5c7c15340..3a7be12b0 100644 --- a/Assets/Scripts/UI/Common/Panel/MessageBox.cs +++ b/Assets/Scripts/UI/Common/Panel/MessageBox.cs @@ -47,10 +47,8 @@ namespace NBF protected override void OnInit() { this.AutoAddClick(OnClick); - // HideAnim = this.HideCenterScaleBig; - // ShowAnim = this.ShowCenterScaleBig; IsModal = true; - IsDontBack = true; + HideAnim = UIPanelAnimation.GetCenterPopScaleFade(this, true); InputManager.OnUICanceled += OnUICanceled; } diff --git a/Assets/Scripts/UI/Fishing/FishingPanel.cs b/Assets/Scripts/UI/Fishing/FishingPanel.cs index 002e7f314..6e2691e4f 100644 --- a/Assets/Scripts/UI/Fishing/FishingPanel.cs +++ b/Assets/Scripts/UI/Fishing/FishingPanel.cs @@ -11,7 +11,6 @@ namespace NBF protected override void OnInit() { IsShowCursor = false; - IsDontBack = true; } protected override void OnShow() diff --git a/Assets/Scripts/UI/Home/HomePanel.Designer.cs b/Assets/Scripts/UI/Home/HomePanel.Designer.cs index 7abe3440b..2fd25f6d9 100644 --- a/Assets/Scripts/UI/Home/HomePanel.Designer.cs +++ b/Assets/Scripts/UI/Home/HomePanel.Designer.cs @@ -15,7 +15,7 @@ namespace NBF public override string UIResName => "HomePanel"; [AutoFind(Name = "Back")] - public GLabel Back; + public UIBlurBackground Back; [AutoFind(Name = "Pages")] public GComponent Pages; [AutoFind(Name = "Menu")] diff --git a/Assets/Scripts/UI/Login/LoginPanel.Designer.cs b/Assets/Scripts/UI/Login/LoginPanel.Designer.cs index 58981c650..9844f2283 100644 --- a/Assets/Scripts/UI/Login/LoginPanel.Designer.cs +++ b/Assets/Scripts/UI/Login/LoginPanel.Designer.cs @@ -15,7 +15,7 @@ namespace NBF public override string UIResName => "LoginPanel"; [AutoFind(Name = "Back")] - public GLabel Back; + public UIBlurBackground Back; [AutoFind(Name = "InputAccount")] public CommonInput InputAccount; [AutoFind(Name = "BtnLogin")] diff --git a/Assets/Scripts/UI/Login/LoginPanel.cs b/Assets/Scripts/UI/Login/LoginPanel.cs index 988ee0745..82f32b5c6 100644 --- a/Assets/Scripts/UI/Login/LoginPanel.cs +++ b/Assets/Scripts/UI/Login/LoginPanel.cs @@ -22,7 +22,9 @@ namespace NBF { if (btn == BtnLogin) { - OnLoginClick().Coroutine(); + // OnLoginClick().Coroutine(); + Debug.LogError("test"); + MessageBox.Show(); } } @@ -30,7 +32,7 @@ namespace NBF { await LoginHelper.Login(InputAccount.text); - await Fishing.Instance.Go(RoleModel.Instance.Info.MapId); + // await Fishing.Instance.Go(RoleModel.Instance.Info.MapId); // await MapHelper.EnterMap(mapId, role.RoomCode); // BagPanel.Show(); diff --git a/Assets/Scripts/UI/Settings/SettingPanel.cs b/Assets/Scripts/UI/Settings/SettingPanel.cs index df5d89f85..9e383e087 100644 --- a/Assets/Scripts/UI/Settings/SettingPanel.cs +++ b/Assets/Scripts/UI/Settings/SettingPanel.cs @@ -22,7 +22,6 @@ namespace NBF { base.OnInit(); IsShowCursor = true; - IsDontBack = true; //TEXT_SETTINGS_ var groupNames = Settings.Instance.GetAllTabs(); foreach (var group in groupNames) diff --git a/Assets/Scripts/UI/Shops/ShopGearItem.Designer.cs b/Assets/Scripts/UI/Shops/ShopGearItem.Designer.cs index c867a0a45..2133add1e 100644 --- a/Assets/Scripts/UI/Shops/ShopGearItem.Designer.cs +++ b/Assets/Scripts/UI/Shops/ShopGearItem.Designer.cs @@ -11,7 +11,7 @@ namespace NBF { public const string URL = "ui://hxr7rc7poome9"; - public GImage back; + public GImage select; public GTextField TextPrice; public GImage Quality; public GTextField TextAmount; @@ -20,7 +20,7 @@ namespace NBF { base.ConstructFromXML(xml); - back = (GImage)GetChild("back"); + select = (GImage)GetChild("select"); TextPrice = (GTextField)GetChild("TextPrice"); Quality = (GImage)GetChild("Quality"); TextAmount = (GTextField)GetChild("TextAmount"); diff --git a/Assets/Scripts/UI/Tween.meta b/Assets/Scripts/UI/Tween.meta new file mode 100644 index 000000000..d8c83c1fc --- /dev/null +++ b/Assets/Scripts/UI/Tween.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 034e1664c8564ba4985717b0ac055420 +timeCreated: 1770175824 \ No newline at end of file diff --git a/Assets/Scripts/UI/Tween/UITweenConfig.cs b/Assets/Scripts/UI/Tween/UITweenConfig.cs new file mode 100644 index 000000000..8ab4c14d0 --- /dev/null +++ b/Assets/Scripts/UI/Tween/UITweenConfig.cs @@ -0,0 +1,27 @@ +/**注册组件动效绑定。本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/ + +using System.Collections.Generic; +using FairyGUI; +using NBC; + +namespace NBF +{ + public class UITweenConfig : UIComponentTweenPack + { + public UITweenConfig() + { + AddData(); + } + + private void AddData() + { + // Common + Add("ui://6hgkvlauips61", new UIComponentTween() + { + { "__root__", "Fade" }, + } + ); + + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/UI/Tween/UITweenConfig.cs.meta b/Assets/Scripts/UI/Tween/UITweenConfig.cs.meta new file mode 100644 index 000000000..de8708006 --- /dev/null +++ b/Assets/Scripts/UI/Tween/UITweenConfig.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 290ed26c6e28f694b95cdb9c6ebd14d5 \ No newline at end of file diff --git a/FGUIProject/assets/Common/Com/Back/UIBlurBackground.xml b/FGUIProject/assets/Common/Com/Back/UIBlurBackground.xml index afe2299d7..83a24f7f2 100644 --- a/FGUIProject/assets/Common/Com/Back/UIBlurBackground.xml +++ b/FGUIProject/assets/Common/Com/Back/UIBlurBackground.xml @@ -2,14 +2,8 @@ - + - - - - - - \ No newline at end of file diff --git a/FGUIProject/assets/Common/Com/Buttons/BtnClose.xml b/FGUIProject/assets/Common/Com/Buttons/BtnClose.xml index 17b6cc951..4b0a115e9 100644 --- a/FGUIProject/assets/Common/Com/Buttons/BtnClose.xml +++ b/FGUIProject/assets/Common/Com/Buttons/BtnClose.xml @@ -1,9 +1,9 @@ - + -