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:

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Leetcode 3. Longest Substring Without Repeating Characters

Triton Service Nodes are now on the Public Testnet!

CRUD API using GO

Babylons INO in Strategic Partnership with Defly Ball on February 10th

Forthbox NFTs and Metabox

Build & Up Docker Image via Jenkins in Local

Electroacoustic Dasample Vst Download

HTTP Status Codes: The Ultimate Guide

A macbook pro screen, with a coding app open, on a table. The image has a title “HTTP Status Codes: The Ultimate Guide

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.

More from Medium

How to use Post Processing in Unity

C# LINQ — “OrderBy”

Tap & Hold & Rapid Prototyping w/ New Unity Input System

Did you just hit me! — Hitbox attack system in Unity2D