2D Toolkit Forum
2D Toolkit => Support => Topic started by: atmuc on September 07, 2012, 12:59:59 pm
-
i try to dissolve a text mesh. i set animation keys and i see that color/alpha changes. it doesnt work on scene view. if i change alpha level manually it works on scene view. what is wrong with this? how can i see animation results on scene view?
-
You might need to commit the change, don't quote me on that though.
-
I believe what dotty says is right, after you've made changes in the code, you need to do a .Commit() for it to actually change. Same goes if you change the text.
-
I believe what dotty says is right, after you've made changes in the code, you need to do a .Commit() for it to actually change. Same goes if you change the text.
I dont have any code. I use unity animation system.
-
Easy way to do this: write a behaviour which monitors the color / scale and calls Commit if it changes. My main OS SSD has failed, so I can't find this until it is replaced - but if you haven't managed to do it, let me know and I'll post my version once I've recovered my OS.
-
Easy way to do this: write a behaviour which monitors the color / scale and calls Commit if it changes. My main OS SSD has failed, so I can't find this until it is replaced - but if you haven't managed to do it, let me know and I'll post my version once I've recovered my OS.
is there any case that i do not want to commit at current frame? if i change something it means i want to see some changes. should not 2dtk apply all changes on update phase? at least there should be autocommit option for unity animation system. cant you run commit as the last command of update method?
-
this code works
using UnityEngine;
using System.Collections;
using tk2dRuntime;
public class CommitObserver : MonoBehaviour
{
tk2dTextMesh textMesh;
float previousAlphaValue;
void Start ()
{
textMesh = GetComponent<tk2dTextMesh> ();
previousAlphaValue = textMesh.color.a;
}
void Update ()
{
if (textMesh.color.a != previousAlphaValue) {
previousAlphaValue = textMesh.color.a;
textMesh.Commit ();
}
}
}
-
The reasons this isn't a toggle on the textmesh/sprite is twofold:
1. Having an Update function increases overhead significantly, so having it only where absolutely necessary is a lot better.
2. The animation system can't update C# properties. For this, in the most trivial case, then a script like this works perfectly, but if you are animating a hierarchical character (eg. a skinned character, or entire UI) then this script is a lot more efficient, as it only has one Update function for all its children.
What I'll be doing -
1. I'll be adding an AutoCommit for usual use cases, i.e. from script. This can be done without an Update function.
2. I'll find this script I wrote and add it to the distribution as in a "Goodies" folder or something like that.