using UnityEngine;
using System.Collections;
public class FloatingTextDriver : MonoBehaviour {
public GameObject target;
public GameObject Prefab;
public UIFont font;
public Transform parent;
public float duration;
public float height;
public float scale;
public string textValue;
public Color testColor;
public void OnClick() {
//aa
//FloatingText ft = Instantiate ( ftt ) as FloatingText;
GameObject ft1 = Instantiate( Prefab) as GameObject;
FloatingText ft = ft1.GetComponentInChildren<FloatingText>();
//Hashtable ht = new Hashtable();
//ht.Add("y", 200);
//ht.Add("oncomplete", "DestroyMe");
//iTween.MoveTo(ft1, ht);
Vector3 size =Prefab.transform.localScale * scale;
//ft.transform.parent = parent;
//ft.transform.localScale = size;
ft.SpawnAt ( target, size, parent );
// ft.Target = target;
// ft.Text = "text ok";
//
ft.Init ( textValue, testColor , target );
ft.FollowTarget = false;
ft.Following();
//animation
TweenPosition tp = ft.TweenPosition;
tp.duration = duration;
tp.from = ft.transform.localPosition;
tp.to = tp.from + Vector3.up * height;
StartCoroutine(Do (ft1));
//Invoke("DestroyMe", duration);
//TweenPosition.Begin(gameObject, 12, Vector3.zero);
// yield return new WaitForSeconds( 2.0f );
// ft.Font = font;
}
IEnumerator Do(GameObject a) {
yield return new WaitForSeconds
(duration
); Destroy(a);
}
public void showText ()
{
GameObject ft1 = Instantiate( Prefab) as GameObject;
FloatingText ft = ft1.GetComponentInChildren<FloatingText>();
Vector3 size =Prefab.transform.localScale * scale;
ft.SpawnAt ( target, size, parent );
ft.Init ( textValue, Color.black, target );
ft.FollowTarget = false;
ft.Following();//animation
TweenPosition tp = ft.TweenPosition;
tp.duration = duration;
tp.from = ft.transform.localPosition;
tp.to = tp.from + Vector3.up * height;
StartCoroutine(Do (ft1));
}
}