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();
}
}