修改ui样式
This commit is contained in:
@@ -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<T>() where T : UIComponentTweenPack
|
||||
{
|
||||
_uiTweenConfig = Activator.CreateInstance<T>();
|
||||
}
|
||||
|
||||
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<T>(object param = null)
|
||||
{
|
||||
Type type = typeof(T);
|
||||
|
||||
Reference in New Issue
Block a user