Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

XKCD Colors in Unity!

Discussion in 'Scripting' started by HarvesteR, Apr 15, 2011.

  1. HarvesteR

    HarvesteR

    Joined:
    May 22, 2009
    Posts:
    525
    Hello,

    Just thought I'd share a simple, but very entertaining and possible even somewhat useful script :D

    Some time ago, Randall Munroe of xkcd did an online survey asking people to name randomly selected colors from the RGB spectrum.

    http://blog.xkcd.com/2010/05/03/color-survey-results/

    The submissions were analyzed, averaged and turned into a huge list of color names.
    One developer called Rune Grimstad, compiled that list into a .NET class.

    I grabbed that class, and did a quick conversion so that the color strings are translated into something Unity will understand.

    Here it is. The XKCDColors class, ported to Unity:

    View attachment $XKCDColors.cs
    (I wanted to post the code, but it's way too long and the forum won't let me, so here's the file)

    There are over 900 colors there, all listed as static properties. The internal class is my unity conversion, that translates the strings into actual color values.

    So, if you're tired of the old Color.grey, and Color.magenta from the default Unity color constants, and would like something better, like XKCDColors.LightPeriwinkle or XKCDColors.BabyPoopGreen, this is for you!

    Have fun!

    Cheers
     
    Last edited: Apr 15, 2011
  2. HarvesteR

    HarvesteR

    Joined:
    May 22, 2009
    Posts:
    525
  3. cupsster

    cupsster

    Joined:
    Apr 14, 2009
    Posts:
    363
    Thank You @HarvesteR! :)
     
  4. Divinux

    Divinux

    Joined:
    Jul 5, 2011
    Posts:
    205
    Is that the default Kerbal color? :cool:

    Great work, thanks.
     
    Last edited: Sep 15, 2013
  5. lorenalexm

    lorenalexm

    Joined:
    Dec 14, 2012
    Posts:
    307
    You, HarvesteR, are a gentleman and a scholar.