Search Unity

Color.TryParseHexString missing?

Discussion in 'Linux Editor' started by NathanWarden, Aug 26, 2015.

  1. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    662
    When importing a project I got the error:

    'UnityEngine.Color' does not contain a definition for 'TryParseHexString'
     
  2. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    662
    Nevermind, I just looked through the release notes for a few other versions and found that it was added in 5.1.1 whereas this build is 5.1.0 :)
     
  3. atti

    atti

    Joined:
    Feb 22, 2011
    Posts:
    77
    Hmm, seems like it vanished again in 5.2.0
    strange, can someone confirm this?

    edit:

    should have read the release notes:

    • Scripting: Removed hexadecimal color string support from Color and replaced with ColorUtility
     
    SebastianErler, K0jo and kobyle like this.
  4. findujanvier

    findujanvier

    Joined:
    May 9, 2014
    Posts:
    15
    I have upgraded to unity 5.2.0 ,
    and I can confirmed that it was missing from UnityEngine and script reference,
     
  5. K0jo

    K0jo

    Joined:
    Aug 23, 2013
    Posts:
    8
    Yup, it's gone again in 5.2.0
     
  6. atti

    atti

    Joined:
    Feb 22, 2011
    Posts:
    77
    No it's not!

    As I mentioned, they moved it to

    UnityEngine.ColorUtility.TryParseHtmlString

    hth
     
    NinjaISV likes this.
  7. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    1,048
    Unfortunately I think ColorUtility.TryParseHtmlString depends on # being at start for a hex color, yet ColorUtility.ToHtmlStringRGB does not place the hash at the start so this is an issue (which was not there with 5.1)
     
  8. atti

    atti

    Joined:
    Feb 22, 2011
    Posts:
    77
    They really changed it? That's not really consistent. But should be easily fixed like that:
    Code (CSharp):
    1. return string.Format("#{0}",ColorUtility.ToHtmlStringRGB(color));
    or
    Code (CSharp):
    1.  ColorUtility.TryParseHtmlString(value.TrimStart('#'),out color);