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.

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:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vincent Taylor

Vincent Taylor

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