unity3d - Use parameters for variable animation -


i'd animate score-gui text counting variable value there 2 things in way:

1: how can animate variable instead of fixed value?

2: why can't add own properties (like int) script , animate them?

for #2 created property in script. yet editor won't show in addproperty-dialog (as shown below):

enter image description here

public int currentscore = 0;  public int score {     { return currentscore; }     set { this.currentscore += value; } } 

edit: animator set in basic way:

enter image description here

since have 1 animation. animator irrelevant solution. tested , working. need make animation legacy type working because not going use animator.

click animation on project -> @ upper right section of inspector view, there little button there drop down selection. "debug" check legacy.

set animation whatever want. force wrapmode in script wrap mode once. play once.

now in animation component make sure select animation want default or wont work. cause use anim.play(); without parameters meaning, run default animation set.

i created text ui , added animation alpha 0 start , @ end point making 1. have on own.

using unityengine; using system.collections; using unityengine.ui;  public class myscore : monobehaviour {  // use initialization public int currentscore = 0; public gameobject myscore; // drag gameobject has animation score. public text myscoretext; //drag in inspector text object reference public animation anim;  public int score {     { return currentscore; }     set { this.currentscore += value; } } void start() {     anim = myscore.getcomponent<animation>(); // reference animation component.      anim.wrapmode = wrapmode.once; // legacy animation set play once     addscore(); } public void addscore() {     score += 10;     myscoretext.text = score.tostring();     anim.play();     debug.log("current score "+ score);     invoke("addscore", 2); }     } 

good luck.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -