Beispiel #1
0
    /// <summary>
    /// Creates Floating Text from the FloatingText prefab at a specified location.
    /// </summary>
    /// <param name="text">The text to display. </param>
    /// <param name="location">The location to display the text. </param>
    /// <param name="color">The color of the text. </param>
    public static void Create_Floating_Text(string text, Transform location, Color color)
    {
        FloatingText instance        = Instantiate(popup);
        Vector2      screen_position = Camera.main.WorldToScreenPoint(new Vector3(location.position.x + UnityEngine.Random.Range(-.5f, .5f),
                                                                                  location.position.y + UnityEngine.Random.Range(1.5f, 1.7f), location.position.z));

        instance.transform.SetParent(canvas.transform, false);
        instance.transform.position = screen_position;
        instance.Set_Text(text);
        instance.Set_Color(color);
    }