Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by d2 · Mar 04, 2015 at 09:43 PM · c#animation2dprogramming

Animation or programming?

Hi guys, Im making a 2d game, i want an animated UI (e.g. the start button sliding from the top), what will be more optimal, make this with animations or via Script?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by cybergoogle · Mar 05, 2015 at 01:29 AM

you should use the animator in unity if it is dropping a button down into the center try looking at the ui transitions tutorial video to see how this is done http://unity3d.com/learn/tutorials/modules/beginner/ui/ui-transitions

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Tekksin · Mar 04, 2015 at 10:04 PM

Animations for sure. Lerping through script is archaic in comparison, especially for things as automated and boring as ui.

GUI things can't be animated unless you're super experienced. And even then the control is minimal.

I suggest using 2d sprites, and then some touch logic based on what a raycast hits.

As far as animating 2D sprites: drag the sprite into a 2d field > add an animation component > open the animation window (ctrl + 6) > add a curve (transform position / scale / rotation / w/e) > key frame it > control it through script:

(java)

 var animateUI : boolean;
 if(animateUI){
   GetComponent(Animator).SetBool("AnimateUI", true);
 }

(After adding an Animator component and creating a new clip in the animation tab, go into the Animator Tab and set up your bool (bottom left) and make appropriate transition links.)

of course make an instance of the component and bool for optimization reasons via script. It's infinitely easier and more flexible than lerping values with mechanical results. Some scripting such as the example above would be necessary, but it will pale in comparison to animating without the Animator component.

edit - Even better:

 var animateUI : boolean;
 private var anim : Animator;
 
 anim.SetBool("AnimateUI", animateUI);
 
 if(somethingHappens)
    animateUI = true;

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image d2 · Mar 04, 2015 at 10:10 PM 0
Share

Im talking about the new ui, no the OnGUI stuff, i mean the ui introduced in 4.6, is better the lerping logic or the animator stuff?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

How to let death animation play when enemy dies, and stop player from taking damage 1 Answer

Collision on specific Frames 1 Answer

While loop ignores conditions in coroutine 1 Answer

How can I code an enemy attack? (Top Down Melee Attack) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges