generated from pancake-llc/package
-
Notifications
You must be signed in to change notification settings - Fork 16
Tag
yenmoc edited this page Jul 3, 2023
·
3 revisions
Implement a gameobject identifier with a tag based ScriptableObject
A MonoBehaviour that adds tags the ScriptableObject way to a GameObject.
- Properties
-
Tags
: Get the tags associated with this GameObject asStringConstants
in a ReadOnlyList. You can createStringConstant
to use as tag via menuCreate
>Pancake
>Scriptable
>ScriptableConstants
>string
-
- Methods
-
HasTag(string)
: Check if the tag provided is associated with this GameObject. return true if the tag exists, otherwise false. -
RemoveTag(string)
: Remove a tag from this GameObject. -
FindByTag(string)
: Find first GameObject that has the tag provided. Return the first GameObject with the provided tag found. If no GameObjects found, it returns null. -
FindAllByTag(string)
: Find all GameObjects that have the tag provided. Return an array of GameObjects with the provided tag. If not found it returns null. -
FindAllByTagNoAlloc(string, List<GameObject>)
: Find all GameObjects that have the tag provided. Mutates the output List and adds the GameObjects found to it. -
GetTagsForGameObject(GameObject)
: A faster alternative togameObject.GetComponent<Tag>()
. Returns the Tag component. Returns null if the GameObject does not have a Tag component or if the GameObject is disabled. -
GetTags(GameObject)
: Retrieves all tags for a given GameObject. A faster alternative togameObject.GetComponents<Tag>().Tags
. Return aReadOnlyList<T>
of tags stored as StringContants. Returns null if the GameObject does not have any tags or if the GameObject is disabled.
-
GameObject extensions related to tags
-
Methods
-
GetTags(GameObject)
: Retrieves all tags for a given GameObject. A faster alternative togameObject.GetComponent<Tag>().Tags
. A ReadOnlyList of tags stored as StringContants. Returns null if the GameObject does not have any tags or if the GameObject is disabled.
Now you can use method GetTags directly from gameObject
var results = gameObject.GetTags();
-
HasTag(GameObject, string)
: Check if the tag provided is associated with this GameObject. Return true if the tag exists, otherwise false. -
HasAnyTag(GameObject, List<string>)
: Check if any of the tags provided are associated with this GameObject. Return true if any of the tags exist, otherwise false.
-