How to animate your UI with code in Unity | UI Tweening

Опубликовано: 19 Февраль 2026
на канале: Christina Creates Games
7,339
285

Animate your UI elements in Unity by code! We'll use tweening for this, but won't use any outside asset and instead write our own. We write a script that handles the animation of an element's position and alpha and go a step further by visualizing the locations it will end up in with Gizmos. That takes a lot off guesswork out of finding the correct distances and placements when creating your UI.

You will learn:
How to move a UI element by code (tweening)
How to animate position and alpha by code
How to work with Gizmos (Visualisation Helpers)
How to use the [Button] and [ShowIf] attribute of Odin Inspector in case you have the asset (it is not needed for this tutorial, but I enjoy working with it and maybe you do, too)
How to use [ContextMenu] to create quick access to methods in the inspector for testing

Get Odin Inspector here:
https://assetstore.unity.com/packages... [affiliate]

✍️ Github
https://github.com/Maraakis/Christina...

🔖 Chapters ℹ️
00:00 The results of this tutorial
00:53 Core setup
01:21 Creating the animation script
08:27 Testing the ui animation results
09:06 Preview of the visualizations
09:33 Creating the visualizations with OnDrawGizmo
14:31 Conclusions

📁 Get the PDF Version of my tutorials
Would you rather read a book? I have a collection of eBooks on the Unity UGUI System here:
📘 Itch: https://christinacreatesgames.itch.io/

💬 Join the Discord
You are very welcome to join   / discord   !

🎮 Play My Games
🎲 https://christinacreatesgames.itch.io

🛍️ Recommended Assets
https://assetstore.unity.com/lists/hi... [affiliate]
📖 List of books all around Gamedev and Design I recommend: https://www.christinacreatesgames.com...
Otherwise, using my affiliate codes for these stores helps to support my channel:
🛒 Unity Asset Store: https://assetstore.unity.com/?aid=110... [affiliate]
🏪 Synty Store: https://syntystore.com/christinacreat... [affiliate]
🪸 Envato Elements: https://1.envato.market/ChristinaCrea... [affiliate]
🔖Humble Bundle: https://humblebundleinc.sjv.io/xLGLNR [affiliate]

🌟 Actionable UI Feedback for Your Game
I offer UI consulting for gamedev projects! With 15+ years of design experience and a background of a teacher, I’m here to help:
👉 Learn more: https://www.vennegerts.com/en/gamedev...

☕ Support Me on Ko-fi
If you enjoy the content and want to support my work:
💛 Buy me a cocoa: https://ko-fi.com/christinacreatesgames

#unitytutorial #unity3d #gamedev #indiedev