UATags -> AtomTags

This commit is contained in:
AdamRamberg 2019-10-17 12:57:00 +02:00
parent 6b6cdf62ee
commit d5e7303483
6 changed files with 15 additions and 15 deletions

View File

@ -12,12 +12,12 @@
# 2.0.0 (September 3, 2019)
The release notes were introduced halfway through the work with version `2.0.0`. The list below might therefore not me 100% complete.
_The release notes were introduced halfway through the work with version `2.0.0`. The list below might therefore not me 100% complete._
## 💥 Breaking changes
- The repo has been split up to 6 different packages: core, mobile, mono-hooks, scene-mgmt, tags and ui
- Changed name on Atomic Tags to UA Tags.
- Changed name on Atomic Tags to Atom Tags.
## 📝 Documentation

View File

@ -12,7 +12,7 @@ namespace UnityAtoms.Tags
/// </summary>
[EditorIcon("atom-icon-delicate")]
[AddComponentMenu("Unity Atoms/Tags")]
public sealed class UATags : MonoBehaviour, ISerializationCallbackReceiver
public sealed class AtomTags : MonoBehaviour, ISerializationCallbackReceiver
{
/// <summary>
/// Get the tags associated with this GameObject as `StringConstants` in a `ReadOnlyList&lt;T&gt;`.
@ -28,8 +28,8 @@ namespace UnityAtoms.Tags
private static readonly Dictionary<string, List<GameObject>> TaggedGameObjects
= new Dictionary<string, List<GameObject>>();
private static readonly Dictionary<GameObject, UATags> TagInstances
= new Dictionary<GameObject, UATags>();
private static readonly Dictionary<GameObject, AtomTags> TagInstances
= new Dictionary<GameObject, AtomTags>();
#region Serialization
@ -194,7 +194,7 @@ namespace UnityAtoms.Tags
/// <returns>
/// Returns the `UATags` component. Returns `null` if the `GameObject` does not have a `UATags` component or if the `GameObject` is disabled.
/// </returns>
public static UATags GetTagsForGameObject(GameObject go)
public static AtomTags GetTagsForGameObject(GameObject go)
{
if (!TagInstances.ContainsKey(go)) return null;
return TagInstances[go];

View File

@ -18,7 +18,7 @@ namespace UnityAtoms.Tags
/// </returns>
public static ReadOnlyList<StringConstant> GetTags(this GameObject go)
{
return UATags.GetTags(go);
return AtomTags.GetTags(go);
}
/// <summary>
@ -29,7 +29,7 @@ namespace UnityAtoms.Tags
/// <returns>`true` if the tag exists, otherwise `false`.</returns>
public static bool HasTag(this GameObject go, string tag)
{
var tags = UATags.GetTagsForGameObject(go);
var tags = AtomTags.GetTagsForGameObject(go);
if (tags == null) return false;
return tags.HasTag(tag);
}
@ -54,7 +54,7 @@ namespace UnityAtoms.Tags
/// <returns>`true` if any of the tags exist, otherwise `false`.</returns>
public static bool HasAnyTag(this GameObject go, List<string> tags)
{
var goTags = UATags.GetTagsForGameObject(go);
var goTags = AtomTags.GetTagsForGameObject(go);
if (goTags == null) return false;
for (var i = 0; i < tags.Count; i++)
@ -74,7 +74,7 @@ namespace UnityAtoms.Tags
{
// basically same method as above, the code is mostly copy and pasted because its not preferable to convert
// stringconstants to strings and calling the other method, because of memory allocation
var tags = UATags.GetTagsForGameObject(go);
var tags = AtomTags.GetTagsForGameObject(go);
if (tags == null) return false;
for (var i = 0; i < stringConstants.Count; i++)

View File

@ -15,14 +15,14 @@ using Random = UnityEngine.Random;
namespace UnityAtoms.Tags.Tests
{
public class UnityAtomsTagsTests
public class AtomTagsTests
{
[UnityTest]
public IEnumerator TestingAndProfiling()
{
var go = new GameObject();
var atomicTags = go.AddComponent<UATags>();
var atomicTags = go.AddComponent<AtomTags>();
List<string> random_tags_raw = new List<string>() { "a", "c", "e", "g", "i", "k", "m" };
random_tags_raw.OrderBy((s => Random.value)).ToList();
@ -52,10 +52,10 @@ namespace UnityAtoms.Tags.Tests
Assert.That(() => { var t1 = atomicTags.Tags[2].Value; }, Is.Not.AllocatingGCMemory());
Assert.That(() => { atomicTags.HasTag(null); }, Is.Not.AllocatingGCMemory());
Assert.AreSame(go, UATags.FindByTag("e"));
Assert.AreSame(go, AtomTags.FindByTag("e"));
using (new ProfilerMarker("MySystem.FindByTag").Auto())
{
UATags.FindByTag("e");
AtomTags.FindByTag("e");
}
// THIS:
// Assert.That(() => { var t1 = AtomicTags.FindByTag("e"); }, Is.AllocatingGCMemory());
@ -71,7 +71,7 @@ namespace UnityAtoms.Tags.Tests
using (new ProfilerMarker("MySystem.GetGlobal").Auto())
{
UATags.GetTagsForGameObject(go);
AtomTags.GetTagsForGameObject(go);
}
Assert.AreEqual(random_tags_raw.Count, atomicTags.Tags.Count);