Archived on 2026-10-24. This is a historical implementation note, not current setup instructions or an active task list. Original claims, code examples, file paths, and completion statements have not all been revalidated. Use the current documentation and issue register for maintenance decisions.
DOTween Animation Migration Guide¶
Overview¶
The page animation system has been migrated from custom coroutine-based animations to DOTween, providing better performance, cleaner code, and more flexibility for testing different easing functions.
Changes Made¶
1. MenuController.cs¶
Added configurable ease settings for testing:
[Header("Page Animation Eases")]
[Tooltip("Ease function for page entry animations")]
public Ease PageEntryEase = Ease.OutQuart;
[Tooltip("Ease function for page exit animations")]
public Ease PageExitEase = Ease.InQuart;
Purpose: Allows you to test different easing functions in the Unity Inspector before finalizing the values.
2. AnimFunc.cs¶
Completely refactored to use DOTween instead of manual while loops:
Before (Custom Implementation):¶
float time = 0;
while (time < 1)
{
Transform.localScale = Vector3.one * EaseFunc.EaseOutQuart(0, 1, time);
yield return null;
time += Time.deltaTime * Speed;
}
Transform.localScale = Vector3.one;
After (DOTween):¶
Transform.DOKill();
float duration = 1f / Speed;
Ease ease = GetEntryEase();
Tween tween = Transform
.DOScale(Vector3.one, duration)
.From(Vector3.zero)
.SetEase(ease)
.OnComplete(() =>
{
if (InvokeEvent)
OnEnd?.Invoke();
});
yield return tween.WaitForCompletion();
Benefits of DOTween¶
1. Performance¶
- Optimized animation system
- Uses Unity's built-in animation infrastructure
- Better memory management
2. Code Clarity¶
- Less boilerplate code
- More readable and maintainable
- Easier to understand animation intent
3. Rich Feature Set¶
- 30+ built-in easing functions
- Sequences, delays, and callbacks
- Advanced tween controls (pause, resume, kill, etc.)
4. Testing Flexibility¶
- Easy to change easing functions
- Visual feedback in Inspector
- No code changes needed to test different eases
5. Consistency¶
- Already used extensively in MenuController (gate animations, hyperspace transition)
- Standard approach in Unity development
Available Animation Methods¶
All methods maintain the same API for backward compatibility:
ZoomIn¶
Animates RectTransform from scale 0 to scale 1.
AnimFunc.ZoomIn(rectTransform, speed, onCompleteEvent);
ZoomOut¶
Animates RectTransform from scale 1 to scale 0.
AnimFunc.ZoomOut(rectTransform, speed, onCompleteEvent);
FadeIn¶
Fades CanvasGroup from alpha 0 to alpha 1.
AnimFunc.FadeIn(canvasGroup, speed, onCompleteEvent);
FadeOut¶
Fades CanvasGroup from alpha 1 to alpha 0.
AnimFunc.FadeOut(canvasGroup, speed, onCompleteEvent);
SlideIn¶
Slides RectTransform from off-screen to center position.
AnimFunc.SlideIn(rectTransform, Direction.UP, speed, onCompleteEvent);
SlideOut¶
Slides RectTransform from center position to off-screen.
AnimFunc.SlideOut(rectTransform, Direction.LEFT, speed, onCompleteEvent);
Ease Testing Guide¶
Step 1: Open MenuController¶
Select the MenuController GameObject in your scene.
Step 2: Locate Ease Settings¶
Find the "Page Animation Eases" header in the Inspector.
Step 3: Test Different Eases¶
Click on the dropdown for PageEntryEase or PageExitEase and try different options:
- OutQuart: Fast start, slow end (default for entry)
- InQuart: Slow start, fast end (default for exit)
- OutBack: Overshoots slightly before settling
- OutElastic: Bouncy effect
- InOutQuad: Smooth acceleration and deceleration
- And many more...
Step 4: Test in Play Mode¶
- Enter Play mode
- Navigate through menu pages
- Observe the animations
- Adjust eases as needed
Step 5: Finalize¶
Once you find the best combination:
- Option A: Keep as public fields for future adjustments
- Option B: Make them private static const to lock in values
Popular Easing Functions¶
For Entry Animations (pages appearing):¶
- OutQuart: Classic, snappy feel (recommended)
- OutExpo: Very fast start, very slow end
- OutBack: Adds a little overshoot for emphasis
- OutElastic: Bouncy, playful feel
- OutCubic: Smooth, balanced feel
For Exit Animations (pages disappearing):¶
- InQuart: Quick exit (recommended)
- InExpo: Very slow start, very fast end
- InBack: Pulls back slightly before exiting
- InCubic: Smooth, balanced feel
- InOutSine: Gentle acceleration throughout
Technical Details¶
Duration Calculation¶
Speed parameter is converted to duration: duration = 1f / Speed
Conflict Prevention¶
All animations call DOKill() before starting to prevent conflicts with existing tweens.
Ease Retrieval¶
private static Ease GetEntryEase()
{
if (MenuController.instance != null)
return MenuController.instance.PageEntryEase;
return Ease.OutQuart; // Fallback
}
private static Ease GetExitEase()
{
if (MenuController.instance != null)
return MenuController.instance.PageExitEase;
return Ease.InQuart; // Fallback
}
Migration Notes¶
What Changed:¶
- ✅ AnimFunc.cs now uses DOTween internally
- ✅ Added configurable ease settings to MenuController
- ✅ Same API maintained for backward compatibility
- ✅ All existing Page animations work without changes
What Didn't Change:¶
- ✅ Page.cs API remains the same
- ✅ Animation modes (SLIDE, ZOOM, FADE) unchanged
- ✅ Direction enum unchanged
- ✅ Speed parameter interpretation unchanged
- ✅ Event callbacks work identically
EaseFunc.cs¶
Still used in game logic (enemy AI, companions, items). Only removed from AnimFunc.cs.
Troubleshooting¶
Issue: Animations not playing - Check if DOTween is installed (should be, used elsewhere) - Verify MenuController.instance is available - Check Unity Console for errors
Issue: Eases not changing in Inspector - Make sure you're modifying MenuController values, not Page settings - Enter Play mode to test changes - Check if multiple MenuController instances exist
Issue: Animations feel wrong
- Try different ease combinations
- Consider using different eases for entry vs exit
- Test with OutBack or OutElastic for more dramatic effects
Issue: Conflicts with other animations
- DOTween's DOKill() prevents conflicts
- If issues persist, check for other scripts animating the same objects
Future Enhancements¶
Once testing is complete:
-
Lock in values: Change ease fields to
private static constprivate static const Ease DEFAULT_ENTRY_EASE = Ease.OutQuart; private static const Ease DEFAULT_EXIT_EASE = Ease.InQuart; -
Add ease presets: Create named presets for different page types
public enum PageAnimationPreset { Standard, Bouncy, Snappy, Smooth } -
Per-page customization: Allow individual pages to override default eases
-
Animation curve support: Add option to use custom AnimationCurves for unique effects
Code Examples¶
Adding a new animation type:¶
public static IEnumerator RotateIn(
RectTransform Transform,
float Speed,
UnityEvent OnEnd,
bool InvokeEvent = false
)
{
Transform.DOKill();
float duration = 1f / Speed;
Ease ease = GetEntryEase();
Tween tween = Transform
.DORotate(Vector3.zero, duration)
.From(Vector3.forward * 180)
.SetEase(ease)
.OnComplete(() =>
{
if (InvokeEvent)
OnEnd?.Invoke();
});
yield return tween.WaitForCompletion();
}
Using custom AnimationCurve:¶
AnimationCurve customCurve = new AnimationCurve(
new Keyframe(0, 0),
new Keyframe(0.5f, 1.2f), // Overshoot
new Keyframe(1, 1)
);
Tween tween = Transform
.DOScale(Vector3.one, duration)
.SetEase(customCurve);
Resources¶
- DOTween Documentation: http://dotween.demigiant.com/
- Ease Visualizer: https://easings.net/ (visual reference for easing functions)
- DOTween Examples: Included in DOTween package
Conclusion¶
The DOTween migration provides a solid foundation for page animations with: - Better performance - Easier testing and iteration - Cleaner, more maintainable code - Flexibility for future enhancements
Take time to test different easing combinations to find what feels best for your game!