private void FloatingText(Color color, string message, int font = 10, float speed = 1f) { FloatingText text = Instantiate(floatingTextPrefab); text.SetPosition(transform.position); text.SetColor(color); text.SetText(message); text.SetFont(font); text.SetLifeTime(1f); text.SetVelocity(new Vector2(0, speed)); }
public static void CreateFloatingText(string text, Transform location, Color color) { FloatingText instance = Instantiate(popupText); if (instance != null) { instance.SetPosition(location.position); Vector2 screenPosition = Camera.main.WorldToScreenPoint(location.position); instance.transform.SetParent(canvas.transform, false); instance.transform.position = screenPosition; instance.SetText(text); instance.gameObject.transform.GetChild(0).gameObject.GetComponent <Text> ().color = color; } }