Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Added OnTagAdded and OnTagRemoved event handlers #415

Closed
wants to merge 8 commits into from
Closed

feature: Added OnTagAdded and OnTagRemoved event handlers #415

wants to merge 8 commits into from

Conversation

ThaungThanHan
Copy link

In this PR, I have added OnTagAdded and OnTagRemoved event handlers. Those two functions will fire whenever a tag is added or removed. In this procedure, I created a tagEventSubscriber script to connect the event listener to the AtomTags script in Tags package. Please review the code and feel free to pinpoint the area I am missing out on.
Fixes: #412

@soraphis soraphis changed the base branch from master to canary July 20, 2023 14:26
@soraphis
Copy link
Collaborator

please make yourself familiar with the https://github.com/unity-atoms/unity-atoms/blob/master/CONTRIBUTING.md

pull requests should target the canary branch, not the master.

Copy link
Collaborator

@soraphis soraphis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase branch onto canary please

Packages/Tags/Runtime/TagsEventsSub.cs Outdated Show resolved Hide resolved
Packages/Tags/Runtime/AtomTags.cs Outdated Show resolved Hide resolved
dkasfn Outdated Show resolved Hide resolved
Copy link
Collaborator

@soraphis soraphis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you try to get rid of the changes in docs/assets/mono-hooks/listener.png and docs/tutorials/mono-hooks.md ?
I think they come from the fact, that you developed on master, instead of canary.

you can probably resolve that via

git checkout origin/canary -- docs/assets/mono-hooks/listener.png
git checkout origin/canary -- docs/tutorials/mono-hooks.md

this will revert the file to the state it has on the origin/canary.

Comment on lines +20 to +21
public AtomEventString OnTagAdded;
public AtomEventString OnTagRemoved;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does the AtomEventString type come from? I can't find it in the project.
It should be StringEvent, shouldn't it?

https://github.com/unity-atoms/unity-atoms/blob/canary/Packages/BaseAtoms/Runtime/Events/StringEvent.cs

@@ -172,6 +175,9 @@ public void AddTag(StringConstant tag)
// Update static accessors:
if (!TaggedGameObjects.ContainsKey(tag.Value)) TaggedGameObjects.Add(tag.Value, new List<GameObject>());
TaggedGameObjects[tag.Value].Add(this.gameObject);

// Start TagAdded event
TagAdded?.Invoke(tag.Value);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using StringEvent, this will be Raise instead of Invoke.
Also StringEvent is a UnityEngine.Object type, so it must not be compared with ?. but instead using if(... == null) because the UnityEngine.Object == operator is overloaden and this is not taken into account when using ?. or is null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Tag Package, Events
3 participants