ObjectTag - BluePixelDev/utilkit GitHub Wiki

ObjectTag is a serializable struct that integrates with Unity's tag system and allows selecting a tag from the Inspector.

Overview

Unity does not directly support tagging in structs or custom classes via the Inspector. ObjectTag solves this using a custom property drawer.

Features

  • Unity tag selection UI
  • Serializable and inspector-friendly
  • Implicit conversion to string

Code Example

[SerializeField] private ObjectTag tagRef;

void Start()
{
    GameObject.FindGameObjectWithTag(tagRef);
}

Members

Fields

  • string tag — stores the tag name.

Methods

  • implicit operator string(ObjectTag) — allows direct use as a string.
  • override ToString() — returns the tag value.

Editor Integration

A CustomPropertyDrawer renders the Unity tag dropdown in the Inspector for selecting from existing tags.