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 Cjmarkham · Jul 13, 2014 at 03:08 PM · animationguitexture

Animating GUITexture scale

When you complete a level on my game I have a 3 star rating.

Lets say you get 3 stars. I have it so each star is rendered after 2 seconds. (one after the other).

What I wanted is so that the star appears larger and decreases in size. Something like from 120px to 75px.

I have tried this by setting the width and height of the star over a given time but this didn't work since it's being called from OnGUI.

I also thought about using a Plane and using that as the star texture but since this is being called in OnGUI I cannot just Instantiate the stars as it would create alot.

Does anyone have any ideas?

This is my current code:

 GUITimer -= Time.deltaTime;
        
         for (int s = 0; s < stars; s++) {
 
             Vector2 starOffset = new Vector2(25, 60);
            
             starOffset.x += s * 100;
 
             GUILayout.BeginArea(Helper.OffsetRect(-160, -220, 500, 150)); {
 
                 Vector2 size = new Vector2(115, 115);
                 if (size.x > 75) {
                     size.x -= Time.deltaTime;
                     size.y -= Time.deltaTime;
                    
                     Debug.Log (size.x);
                 }
 
                 if (s == 0) {
                     if (GUITimer <= 8f) {
                         GUI.DrawTexture(new Rect(0 + starOffset.x, 0 + starOffset.y, size.x, size.y), starTexture);
                     }
                 }
 
                 if (s == 1) {
                     if (GUITimer <= 6f) {
                         GUI.DrawTexture(new Rect(0 + starOffset.x, 0 + starOffset.y, size.x, size.y), starTexture);
                     }
                 }
 
                 if (s == 2) {
                     if (GUITimer <= 3f) {
                         GUI.DrawTexture(new Rect(0 + starOffset.x, 0 + starOffset.y, size.x, size.y), starTexture);
                     }
                 }
             }
             GUILayout.EndArea();
         }

Comment
Add comment · Show 2
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 MarioAGOrdiano · Jul 13, 2014 at 08:09 PM 1
Share

You could use a coorutine, spawn the start then in a while loop change the size, keep rendering it in OnGUI.

avatar image Firedan1176 · Jul 13, 2014 at 10:04 PM 0
Share

iTween also has some simple GUI animation examples. On their website, you can click on the squares to the right to view the scenes.

0 Replies

· Add your reply
  • Sort: 

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

A node in a childnode? 1 Answer

How to Show / Hide a GUI Texture 1 Answer

Maya animations not playing in Unity 3 correctly 0 Answers

why does the animation looks different when imported into unity 2 Answers

Third Person Help 4 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