Creating Custom Unity Attributes: Divider/Horizontal Line

Today I’m creating a simple horizontal line which can be used to cleanly separate areas on the Unity Inspector, similar to the Header attribute.

Vincent Taylor
Sep 16, 2021

Today’s Objective: Create a simple Horizontal Line attribute which will allow nice dividing of shown fields in the Unity Inspector.

NOTE: I’ve just started learning how to create my own custom Attributes very recently, so if you see any improvements that could be made, please let me know! :)

The Code:

I’ll write 3 classes to create this attribute. The attribute, the editor drawer, and a compile-time constant for the color.

HorizontalLineAttribute:

HorizontalLineDecoratorDrawer:

This is an Editor script so it must go in an “Editor” folder in the project files.

EColor:

The result:

--

--

Vincent Taylor
Vincent Taylor

Written by Vincent Taylor

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.

No responses yet