-
Notifications
You must be signed in to change notification settings - Fork 120
/
GameObjectExtensions.cs
46 lines (39 loc) · 1.25 KB
/
GameObjectExtensions.cs
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
using System.Collections.Generic;
using UnityEngine;
namespace UnityAtoms
{
public static class GameObjectExtensions
{
public static List<StringConstant> GetTags(this GameObject go)
{
return go.GetComponent<AtomicTags>() ? go.GetComponent<AtomicTags>().Tags : null;
}
public static bool HasTag(this GameObject go, string str)
{
var tags = go.GetComponent<AtomicTags>() ? go.GetComponent<AtomicTags>().Tags : null;
for (int i = 0; tags != null && i < tags.Count; ++i)
{
if (tags[i].Value == str)
{
return true;
}
}
return false;
}
public static bool HasTag(this GameObject go, StringConstant stringConstant)
{
return go.HasTag(stringConstant.Value);
}
public static bool HasAnyTag(this GameObject go, List<StringConstant> stringConstants)
{
for (int i = 0; stringConstants != null && i < stringConstants.Count; ++i)
{
if (go.HasTag(stringConstants[i].Value))
{
return true;
}
}
return false;
}
}
}