12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using System;
- using UnityEngine;
- [RequireComponent(typeof(UIInput))]
- [AddComponentMenu("NGUI/Examples/Chat Input")]
- public class ChatInput : MonoBehaviour
- {
- private void Start()
- {
- this.mInput = base.GetComponent<UIInput>();
- this.mInput.label.maxLineCount = 1;
- if (this.fillWithDummyData && this.textList != null)
- {
- for (int i = 0; i < 30; i++)
- {
- this.textList.Add(string.Concat(new object[]
- {
- (i % 2 != 0) ? "[AAAAAA]" : "[FFFFFF]",
- "This is an example paragraph for the text list, testing line ",
- i,
- "[-]"
- }));
- }
- }
- }
- public void OnSubmit()
- {
- if (this.textList != null)
- {
- string text = NGUIText.StripSymbols(this.mInput.value);
- if (!string.IsNullOrEmpty(text))
- {
- this.textList.Add(text);
- this.mInput.value = string.Empty;
- this.mInput.isSelected = false;
- }
- }
- }
- public UITextList textList;
- public bool fillWithDummyData;
- private UIInput mInput;
- }
|