Skip to content

tpelham42/Unity_NB_ColorExt

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

NB ColorExt For Unity Game Engine

Description

Unity NB ColorExt is a set of C# extension methods for the Unity Color class that adds the ability to easily go to/from Html Hex Color or HSV (Hue, Saturation, Color).

Demo

Sample Demo

Usage

NB ColorExt is available under the NB.ColorUtil namespace. The following code snippet shows how to use the included functions.

//Use following namespace in scripts
using NB.ColorExt;

//Normal Color creation
Color c = Color.red;

//From HEX Value
c = c.FromHexStr("#FF0000"); //Red Color

//To HEX Value
string hexStr = c.ToHexStr();

//Hue (float): 0 - 359
//Saturation (float): 0 - 1
//Vibrance (float): 0 - 1

//From HSV
c = c.FromHSV(0f, 1f, 1f); //Red Color

//To HSV
float[3] hsv = c.HSV();
//hsv[0] = Hue, hsv[1] = Saturation, hsv[2] = Vibrance

float hue = c.Hue();
float saturation = c.Saturation();
float vibrance = c.Vibrance();

The only required file is the 'Assets/NB.ColorExt/NB.ColorExt.cs'. Example project included in repository.

About

HEX/HSV Extension Methods for Unity Color Class

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages