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
0
Question by Kalu · Nov 04, 2011 at 10:24 PM · guiscalingeasing

ReScaling with easing?!

Hello, I use a piece of code that is supposed to enlarge a small tab in a larger area of information (all hover). The code works but also by reducing the value of magnification tab moves from position to position "unfolded" instantly ... GUI does not run to the enterFrame?

 private float _Wacceuil = 40;//valeurs références par défaut
     private float _Hacceuil = 50;
     private float _WacceuilOFF = 40;//valeurs références d'origines, position plié
     private float _HacceuilOFF = 50;
     private float _WacceuilON = 100;//valeurs références d'origines, position déplié
     private float _HacceuilON = 250;
 
 GUI.Button(new Rect(0, 60, _Wacceuil, _Hacceuil), "Acceuil");    
 if (Input.mousePosition.x>0&&Input.mousePosition.y<Screen.height-60 &&
     Input.mousePosition.x<0+_Wacceuil &&
     Input.mousePosition.y>Screen.height-60-_Hacceuil)
     {
             while(_Wacceuil < _WacceuilON)
             {
                 _Wacceuil += .1f;
             }
             while(_Hacceuil < _HacceuilON)
             {
                 _Hacceuil += .1ff;
             }
         }
         else
         {
             if(_Wacceuil > _WacceuilOFF)
             {
                 while(_Wacceuil > _WacceuilOFF)
                 {
                     _Wacceuil -= .1f;
                 }
             }
             if(_Hacceuil > _HacceuilOFF)
             {
                 while(_Hacceuil > _HacceuilOFF)
                 {
                     _Hacceuil -= .1f;
                 }
             }
         }
Comment
Add comment · Show 1
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 syclamoth · Nov 04, 2011 at 11:21 PM 0
Share

while loops inside of repeated functions will execute instantly! You should put all of this logic inside a coroutine, and run that ins$$anonymous$$d, using

 yield return null;

in between executions.

I'd give you a code example, but I'm pressed for time- I'm sure one of the other helpful folks here will be able to solve this one.

1 Reply

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

Answer by DaveA · Nov 04, 2011 at 11:20 PM

Change all these 'while' statements, like

 while(_Wacceuil < _WacceuilON)

to 'if' statements like

 if (_Wacceuil < _WacceuilON)

I assume this is all in an OnGUI function, which it should not be. Move it to an Update function, except for the GUI.Button line

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 Kalu · Nov 05, 2011 at 12:03 AM 0
Share

Thx a lot. It work perfectly

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Is this the correct way to scale my GUI? 1 Answer

Unity3d GUI Element Scaling 1 Answer

GUI scaling on mobile 1 Answer

UI Constant Physical Size, rect sizes not corresponding to real sizes 0 Answers

Interface relative scaling 0 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