I think I may have a similar or possible same bug as you guys:
What I am trying to do:I have a simple setup, a label that has a simple TweenAlpha on it. The base settings are setup so it will pingpong between 1 to 0, essentially blinking the label on and off smoothly over the course of 1 second. When I hit a certain key, I want it to take it's current value and set the TweenAlpha up so that it goes from current alpha value back to 1 over the course of a certain amount of time. For example possibly over 4 seconds ( this was just for testing ).
What happens:It seems to be failing on the reverse trip of TweenAlpha, if I run FinalAlpha() during the forward direction of the TweenAlpha, it fires off perfectly, if I ask it to run FinalAlpha() during the reverse direction of the TweenAlpha, it immediately completes my new settings in 0 seconds. I had tried to detect which direction the TweenAlpha was going when I wanted to run FinalAlpha(), but no matter if I did, and tried to .Toggle() the TweenAlpha or not, I can't get the behavior to work when the TweenAlpha was in the middle of the reverse direction when I called FinalAlpha(). Any ideas??
I am using the following code:using UnityEngine;
using System.Collections;
public class PressStart : MonoBehaviour {
private UILabel label;
private TweenAlpha alpha;
private bool startPressed = false;
private bool ranFinalAlpha = false;
private float startTime = 0.0f;
private float endTime = 0.0f;
// Use this for initialization
void Start() {
label = gameObject.GetComponent<UILabel>();
alpha = gameObject.GetComponent<TweenAlpha>();
Debug.Log(string.Format("Label: {0}", label.name));
Debug.Log(string.Format("ColorTint: {0}", label.color));
scale.Reset();
}
// Update is called once per frame
void Update() {
if (Input.GetButton("Win 360 Pad1 Start") && !startPressed) {
startPressed = true;
Debug.Log("Pressed Start button");
}
if (startPressed) {
if (!ranFinalAlpha) {
FinalAlpha();
}
}
}
void FinalAlpha() {
startTime = Time.time;
ranFinalAlpha = true;
Debug.Log("Entered final alpha");
float currentAlpha = alpha.alpha;
Debug.Log(string.Format("Alpha when called: {0}", currentAlpha));
alpha.from = currentAlpha;
alpha.to = 1.0f;
alpha.duration = 4.0f;
alpha.style = UITweener.Style.Once;
alpha.callWhenFinished = "CalledToFinish";
alpha.eventReceiver = gameObject;
alpha.Reset();
alpha.Play(true);
}
void CalledToFinish() {
endTime = Time.time;
Debug.Log("Was called at finish!");
Debug.Log(string.Format("Elapsed Time: {0}", endTime - startTime));
}
void OnGUI() {
GUILayout
.BeginArea(new Rect
(0,
0,
330,
700)); GUILayout.Label(string.Format("Current Alpha: {0}", alpha.alpha));
GUILayout.EndArea();
}
}