Nextrek
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
using UnityEngine;
/// <summary>
/// Very simple example of how to use a TextList with a UIInput for chat.
/// </summary>
[RequireComponent(typeof(UIInput))]
[AddComponentMenu("NGUI/Examples/Chat Input")]
public class ChatInput : MonoBehaviour
{
public UITextList textList;
public bool fillWithDummyData = false;
UIInput mInput;
/// <summary>
/// Add some dummy text to the text list.
/// </summary>
void Start ()
{
mInput = GetComponent<UIInput>();
mInput.label.maxLineCount = 1;
if (fillWithDummyData && textList != null)
{
for (int i = 0; i < 30; ++i)
{
textList.Add(((i % 2 == 0) ? "[FFFFFF]" : "[AAAAAA]") +
"This is an example paragraph for the text list, testing line " + i + "[-]");
}
}
}
/// <summary>
/// Submit notification is sent by UIInput when 'enter' is pressed or iOS/Android keyboard finalizes input.
/// </summary>
public void OnSubmit ()
{
if (textList != null)
{
// It's a good idea to strip out all symbols as we don't want user input to alter colors, add new lines, etc
string text = NGUIText.StripSymbols(mInput.value);
if (!string.IsNullOrEmpty(text))
{
textList.Add(text);
mInput.value = "";
mInput.isSelected = false;
}
}
}
}
|
Revision |
Author |
Commited |
Message |
83
|
FMMortaroli
|
Tue 13 May, 2014 11:32:51 +0000 |
|