private void UserList(ActionParameter parameter) { List <string> onlineList = parameter.GetValue <List <string> >("onlineList"); 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); }
/// <summary> /// 创建消息UI /// </summary> private void CreateMessage(ActionParameter parameter) { if (messageContent == null || messageTextPrefab == null) { return; } Text messageText = Instantiate(messageTextPrefab); messageText.text = parameter.GetValue <string>("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); }
/// <summary> /// 调用处理 /// </summary> private void HandleInvoke(ActionParameter parameter) { int handleType = parameter.GetValue <int>(ACTIONTYPE); handles[handleType](parameter); }