コード例 #1
0
ファイル: UIChat.cs プロジェクト: Patryk-S-W/PG-Explorer
    public void AddMessage(ChatMessage message)
    {
        if (content.childCount >= keepHistory)
        {
            Destroy(content.GetChild(0).gameObject);
        }
        GameObject go = Instantiate(message.textPrefab, content.transform, false);

        go.GetComponent <Text>().text           = message.Construct();
        go.GetComponent <UIChatEntry>().message = message;
        AutoScroll();
    }
コード例 #2
0
ファイル: UIChat.cs プロジェクト: dstoffels/Theia
    public void AddMessage(ChatMessage message)
    {
        // delete old messages so the UI doesn't eat too much performance.
        // => every Destroy call causes a lag because of a UI rebuild
        // => it's best to destroy a lot of messages at once so we don't
        //    experience that lag after every new chat message
        if (content.childCount >= keepHistory)
        {
            for (int i = 0; i < content.childCount / 2; ++i)
            {
                Destroy(content.GetChild(i).gameObject);
            }
        }

        // instantiate and initialize text prefab with parent
        GameObject go = Instantiate(message.textPrefab, content.transform, false);

        go.GetComponent <Text>().text           = message.Construct();
        go.GetComponent <UIChatEntry>().message = message;

        AutoScroll();
    }