Beispiel #1
0
    /// <summary>
    /// 调用处理
    /// </summary>
    private void HandleInvoke(ActionParameter parameter)
    {
        int handleType = 0;

        if (parameter.TryGetValue(ACTIONTYPE, ref handleType))
        {
            handles[handleType](parameter);
        }
    }
Beispiel #2
0
    /// <summary>
    /// 创建消息UI
    /// </summary>
    private void CreateMessage(ActionParameter parameter)
    {
        string message = null;

        if (messageContent == null || messageTextPrefab == null || !parameter.TryGetValue("message", ref message))
        {
            return;
        }

        Text messageText = Instantiate(messageTextPrefab);

        messageText.text = message;

        RectTransform messageRect = messageText.rectTransform;

        messageRect.SetParent(messageContent);
        messageRect.offsetMin        = new Vector2(0, messageRect.offsetMin.y);
        messageRect.offsetMax        = new Vector2(0, messageRect.offsetMax.y);
        messageRect.anchoredPosition = new Vector2(messageRect.anchoredPosition.x, 0);
        messageRect.sizeDelta        = new Vector2(messageRect.sizeDelta.x, messageText.preferredHeight);

        if (messagesText.Count >= maxMessageCount)
        {
            Destroy(messagesText[0].gameObject);
            messagesText.RemoveAt(0);
        }

        messagesText.Add(messageText);

        for (int i = 0; i < messagesText.Count - 1; i++)
        {
            float height = 0;
            for (int j = i + 1; j < messagesText.Count; j++)
            {
                height += messagesText[j].preferredHeight;
            }
            messagesText[i].rectTransform.anchoredPosition = new Vector2(messagesText[i].rectTransform.anchoredPosition.x, height);
        }

        float totalHeight = 0;

        for (int i = 0; i < messagesText.Count; i++)
        {
            totalHeight += messagesText[i].preferredHeight + messageSpace;
        }
        messageContent.sizeDelta = new Vector2(messageContent.sizeDelta.x, totalHeight);
    }
    private void UserList(ActionParameter parameter)
    {
        List <string> onlineList = null;

        if (!parameter.TryGetValue("onlineList", ref onlineList))
        {
            return;
        }

        onlineListUI.text = onlineList[0];
        for (int i = 1; i < onlineList.Count; i++)
        {
            onlineListUI.text += "\r\n" + onlineList[i];
        }

        RectTransform onlineRect = onlineListUI.rectTransform;

        onlineRect.sizeDelta = new Vector2(onlineRect.sizeDelta.x, onlineListUI.preferredHeight);
    }