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
2
Question by kaiyum · Jan 06, 2014 at 04:38 PM · animationmecanimtimescale

mecanim animation while timescale is zero

Hi there, In pause menu, we set timescale to zero. It causes severe problem when we want some sprite animations for buttons. I am using mecanim for GUI sprite animations. So when I go to pause menu, every animation just stops. I do not want that. I want every animation in pause menu to play, even though timescale is zero. Is there any solution for this problem? Thanks.

Comment
Add comment · Show 9
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 kaiyum · Jan 06, 2014 at 05:52 PM 0
Share

though not a solution by mecanim, I think we can do sprite animation while we are in pause menu. The way I thought was: having an array of sprites and an script attached to it the button gameobject. When we are in pause menu, we can turn renderer on(vice versa). and in script we update sprite index according to elapsed time. Lets say for a 4fps animation having 4 sprites. Each one must remain 1/4=0.25seconds. So we constantly check the interval.(Here we trace time by Time.realtimeSinceStartup). When interval passed, we update renderer's sprite property by changing index. I havn't test it yet but my sixth sense tells me it is gonna work. What do you think guys?

avatar image kaiyum · Jan 06, 2014 at 07:18 PM 0
Share

Just as I said. It worked perfectly on the other way!!

avatar image $$anonymous$$ · Jan 15, 2014 at 09:58 AM 0
Share

I can't upvote but this is an issue for me too. Nothing posted on the web works, nothing from the Unity docs works.

avatar image kaiyum · Jan 15, 2014 at 12:47 PM 0
Share

maul, here is the class I developed for this purpose.

copy the codes to a C# script, name the script as the class name. Lets say you need a blinking button. So you have made four sprites of same hight-width(important for visually aesthetic quality). Now you put the array size of "sprites" to 4. You assign your sprite sequentially. You can adjust fps-turnOn-turnOff-pause$$anonymous$$enukey etc if necessary. Boom!

 using UnityEngine;
 using System.Collections;
 
 public class pauseAnim : $$anonymous$$onoBehaviour {
     
     public Sprite[] sprites;
     public float fps=4;
     public $$anonymous$$eyCode turnOn$$anonymous$$ey=$$anonymous$$eyCode.A;
     public $$anonymous$$eyCode turnOff$$anonymous$$ey=$$anonymous$$eyCode.D;
     public $$anonymous$$eyCode pause$$anonymous$$enuButton=$$anonymous$$eyCode.Escape;
     private float interval;
     private float activeTime;
     private int index;
     // Use this for initialization
     void Start () {
         
 
 
         gameObject.renderer.enabled=false;
         
     }
     
     // Update is called once per frame
     void Update () {
         if(Input.Get$$anonymous$$eyDown(pause$$anonymous$$enuButton)){Time.timeScale=0;}
         interval=1/fps;
         if(Input.Get$$anonymous$$eyDown(turnOff$$anonymous$$ey)) 
         {
             gameObject.renderer.enabled=false;
         }
         if(Input.Get$$anonymous$$eyDown(turnOn$$anonymous$$ey)) //we are in pause menu
         {
             activeTime=Time.realtimeSinceStartup;
             if(Time.timeScale==0)
             {gameObject.renderer.enabled=true;}
             gameObject.GetComponent<SpriteRenderer>().sprite=sprites[0];
             index=0;
         }
         if(gameObject.renderer.enabled==true)
         {
             if(Time.realtimeSinceStartup>=(activeTime+interval))
             {
                 activeTime=Time.realtimeSinceStartup;
                 gameObject.GetComponent<SpriteRenderer>().sprite=sprites[index+1];
                 index=index+1;
                 if(index==(sprites.Length-1))
                 {
                     index=0;
                 }
             }
         }
         
         
     }
 }
 
avatar image $$anonymous$$ · Jan 15, 2014 at 12:48 PM 0
Share

Thanks but I meant the mecanim system.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by flyingbanana · Nov 21, 2015 at 08:58 PM

alt text


screen-shot-2015-11-21-at-35537-pm.png (38.9 kB)
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

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

20 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

Related Questions

Mecanim mirror mode is doing...things. 0 Answers

Sharing some but not all animator states between characters 0 Answers

Is there a way to abstract sprite from animation clip? 0 Answers

Animation Preview 0 Answers

Playing 2 Animations at once. *Please Help* 2 Answers


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