Example #1
0
    //Add a text gameobject displaying the event
    public void AddTextEvent(string t, EventTextType tp)
    {
        Text g = Instantiate(textEvent, canvas.transform).GetComponent <Text>();

        //Set the event text
        g.text = t;
        //Set the text color
        switch (tp)
        {
        case EventTextType.Combat: g.color = Color.red; break;

        case EventTextType.Loot: g.color = Color.yellow; break;

        case EventTextType.Skill: g.color = Color.magenta; break;
        }
        //Set text position
        g.gameObject.GetComponent <RectTransform>().anchoredPosition = new Vector2(10, -(10 + (texts.Count * 20)));
        texts.Add(g.gameObject);
        StartCoroutine(RemoveTextGameobject(g.gameObject));
    }