-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathTags.cs
More file actions
142 lines (124 loc) · 3.51 KB
/
Tags.cs
File metadata and controls
142 lines (124 loc) · 3.51 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* @author Valentin Simonov / http://va.lent.in/
*/
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using UnityEngine;
namespace TouchScript
{
/// <summary>
/// Tags collection for touches.
/// </summary>
[Serializable]
public sealed class Tags
{
/// <summary>
/// Touch.
/// </summary>
public const string INPUT_TOUCH = "Touch";
/// <summary>
/// Mouse.
/// </summary>
public const string INPUT_MOUSE = "Mouse";
/// <summary>
/// Pen.
/// </summary>
public const string INPUT_PEN = "Pen";
/// <summary>
/// Object.
/// </summary>
public const string INPUT_OBJECT = "Object";
/// <summary>
/// Windows native touch source.
/// </summary>
public const string SOURCE_WINDOWS = "Windows";
/// <summary>
/// TUIO touch source.
/// </summary>
public const string SOURCE_TUIO = "TUIO";
/// <summary>
/// List of tags.
/// </summary>
public ICollection<string> TagList
{
get { return new ReadOnlyCollection<string>(tagList); }
}
/// <summary>
/// Number of tags in this collection.
/// </summary>
public int Count
{
get { return tagList.Count; }
}
[SerializeField]
private List<string> tagList = new List<string>();
/// <summary>
/// Creates an instance of Tags.
/// </summary>
/// <param name="tags">Tags collection to copy.</param>
public Tags(Tags tags) : this()
{
if (tags == null) return;
foreach (var tag in tags.tagList)
{
AddTag(tag);
}
}
/// <summary>
/// Creates an instance of Tags.
/// </summary>
/// <param name="tags">Tags collection to copy.</param>
public Tags(IEnumerable<string> tags) : this()
{
foreach (var tag in tags)
{
AddTag(tag);
}
}
/// <summary>
/// Creates an instance of Tags.
/// </summary>
/// <param name="tag">Tag to add to the new collection.</param>
public Tags(string tag) : this()
{
tagList.Add(tag);
}
/// <summary>
/// Creates an instance of Tags.
/// </summary>
public Tags() {}
/// <summary>
/// Adds a tag to this collection.
/// </summary>
/// <param name="tag">Tag to add.</param>
public void AddTag(string tag)
{
if (string.IsNullOrEmpty(tag)) return;
if (tagList.Contains(tag)) return;
tagList.Add(tag);
}
/// <summary>
/// Removes a tag from this collection.
/// </summary>
/// <param name="tag">Tag to remove.</param>
public void RemoveTag(string tag)
{
tagList.Remove(tag);
}
/// <summary>
/// Checks if this collection contains a tag.
/// </summary>
/// <param name="tag">Tag.</param>
/// <returns>True if tag is in this collection; false otherwise.</returns>
public bool HasTag(string tag)
{
return tagList.Contains(tag);
}
/// <inheritdoc />
public override string ToString()
{
return String.Join(", ", tagList.ToArray());
}
}
}