- Home /
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();
}
You could use a coorutine, spawn the start then in a while loop change the size, keep rendering it in OnGUI.
iTween also has some simple GUI animation examples. On their website, you can click on the squares to the right to view the scenes.
Your answer
Follow this Question
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