Mateusz
Mateusz

Snippet: simple Unity comment component

I put this together a while ago. Maybe you’ll find it useful.

Overview

Unity label selection dropdown Unity label selection dropdown

  • Single script, plug-and-play.
  • Double-click the text area to edit.

Installation

Either paste the script below into your project, or install it as a package via the Unity Package Manager using this URL:0

https://gist.github.com/19c183d115953f26c62cbdced7fab5a2.git

Source

Optimization

  • During build, the [PostProcessScene] callback removes instances of the component from your scenes.
  • Since we can’t remove the entire component from prefabs at build time1, the ISerializationCallbackReceiver callback clears the comment content.
  • You can even use it with ECS since the component won’t be baked at all.
  1. Yes, you can install packages straight from GitHub Gists (if they’re set up with a package.json and an .asmdef). I’m as surprised as you are that this actually works, but Gists are built on top of regular Git repositories, so it makes sense. return ︿

  2. I looked, but couldn’t find any way to do this. If I recall correctly, deleting the component during serialization results in an error. I wish we had [PostProcessPrefab] or something… return ︿