Our review
Provides a structured pattern for creating animated UI panels in Unity with DOTween, using UIBase and ITweenAnim.
Strengths
- Clearly separates UI lifecycle (show/hide) from animation via an ITweenAnim interface.
- Uses a DOTween animator configurable in the Inspector for flexible animations.
- Enforces a static singleton for easy access from any script.
- Includes concrete examples and a ready-to-use template.
Limitations
- Requires overriding all four UIBase callbacks, even if empty, which can be verbose.
- Depends on DOTween, an external library that must be imported.
- Animations are limited to predefined types (DOAnchorPos, Scale, Fade, PunchScale).
When you need to add a new animated UI panel or modify an existing one in a Unity project using DOTween.
For very simple UI interactions without animation, or if you want to avoid a dependency on DOTween.
Security analysis
SafeThe skill provides a UI coding pattern and template with no executable scripts or destructive instructions; it is purely informational.
No concerns found
Examples
Create a new UI panel for player settings using the UIBase/ITweenAnim pattern with a fade-in and scale-out animation, and a singleton accessor.Refactor the current score display panel to follow the UIBase pattern with DOTween animations for show/hide.Add a new UI panel that slides in from the left while fading in, using multiple AnimSettingDotween under one EAnimIDs in DoTweenUIAnimator.Use when: adding or modifying any UI panel, HUD element, or animated screen.
Pattern (3 layers — all required)
UIBase → show/hide lifecycle (_UIBaseShowUI / _UIBaseHideUI)
ITweenAnim → animation contract (playInAnim / playOutAnim)
DoTweenUIAnimator → DOTween driver, configured entirely in Inspector
Minimal implementation
public class UI_MyPanel : UIBase, ITweenAnim
{
public static UI_MyPanel s_Instance;
[SerializeField] DoTweenUIAnimator m_popUp;
void Awake() { if (s_Instance && s_Instance != this) { Destroy(gameObject); return; } s_Instance = this; }
public static void ShowUI_s() => s_Instance?._UIBaseShowUI(0.3f);
public static void HideUI_s() => s_Instance?._UIBaseHideUI(0.3f);
// UIBase — override all four, even if empty
protected override void OnCanvasShowBegin() { UpdateUI(); playInAnim(0.3f); }
protected override void OnCanvasShowEnd() { }
protected override void OnCanvasHideBegin() { playOutAnim(0.3f); }
protected override void OnCanvasHideEnd() { } // put post-close callbacks here
public void playInAnim(float d) => m_popUp.PlayAnimation(DoTweenUIAnimator.EAnimIDs.InAnim, d);
public void playOutAnim(float d) => m_popUp.PlayAnimation(DoTweenUIAnimator.EAnimIDs.OutAnim, d);
}
Full template with Inspector setup → /project:new-ui-panel
DoTweenUIAnimator quick ref
| Type | Needs | Use for |
|---|---|---|
| DOAnchorPos | RectTransform | slide in/out |
| Scale | RectTransform | pop in/out |
| Fade | CanvasGroup | fade in/out |
| PunchScale | RectTransform | attention/bounce |
Multiple AnimSettingDotween under one EAnimIDs → play simultaneously.
playOnStart = true on a step → auto-plays on scene load (idle loops, etc).
Reacting to game events in UI
void OnEnable() => GameManager.AddListener_s(GameConstants.E__GameScoreUpdated, OnScore);
void OnDestroy() => GameManager.RemoveListener_s(GameConstants.E__GameScoreUpdated, OnScore);
void OnScore(object d) { var data = (ScoreUpdateData)d; /* update text */ }
State-change driven UI
UI_ShowScore is the canonical example — OnCanvasHideEnd() calls SetGameState(ToBeStart).
Use this pattern when a panel's close action must drive a game state transition.
Existing singleton panels
| Class | Shows |
|---|---|
| UI_ShowScore | Post-rally score (static ShowUI_s(myScore, oppScore)) |
| UIPopUp | Generic message popup (ShowUI_s(text, onClose)) |
| UIGameplayControls | In-game HUD |
| UICurrenyHUD | Coin/gold display |
Gotchas
- Always override all four
UIBasecallbacks — leaving one unimplemented causes compile error Fadetype requires aCanvasGroupon the target —RectTransformalone won't work_UIBaseShowUI(duration)and_UIBaseHideUI(duration)are the only correct entry points — never callgameObject.SetActive()directly
Next.js App Router Expert
Development
A skill that turns Claude into a Next.js App Router expert.
README Generator
Development
Creates professional and comprehensive README.md files for your projects.
API Documentation Writer
Development
Generates comprehensive API documentation in OpenAPI/Swagger format.