Assets/FlexibleColorPicker/Scripts/FlexibleColorPicker.cs
/// <summary>
/// Santiive a given string so that it encodes a valid hex color string
/// </summary>
/// <param name="input">Input string</param>
/// <param name="full">Insert zeroes to match #RRGGBB format </param>
Santiive a given string so that it encodes a valid hex color string
Santiive a given string so that it encodes a valid hex color string
public static string GetSanitizedHex(string input, bool full) {
        if(string.IsNullOrEmpty(input))
            return "#";
        List<char> toReturn = new List<char>();
        toReturn.Add('#');
        int i = 0;
        char[] chars = input.ToCharArray();
        while(toReturn.Count < 7 && i < input.Length) {
            char nextChar = char.ToUpper(chars[i++]);
            if(IsValidHexChar(nextChar))
                toReturn.Add(nextChar);
        }
        while(full && toReturn.Count < 7)
            toReturn.Insert(1, '0');
        return new string(toReturn.ToArray());
    }
public static string GetSanitizedHex ( string input , bool full ) { if ( string . IsNullOrEmpty ( input ) ) return " " ; List < char > toReturn = new List < char > ( ) ; toReturn . Add ( ' ' ) ; int i = 0 ; char [ ] chars = input . ToCharArray ( ) ; while ( toReturn . Count < 7 && i < input . Length ) { char nextChar = char . ToUpper ( chars [ i ++ ] ) ; if ( IsValidHexChar ( nextChar ) ) toReturn . Add ( nextChar ) ; } while ( full && toReturn . Count < 7 ) toReturn . Insert ( 1 , ' ' ) ; return new string ( toReturn . ToArray ( ) ) ; }
Santiive a given string so that it encodes a valid hex color string
Santiive a given string so that it encodes a valid hex color string
input
string
None
full
bool
Insert zeroes to match #RRGGBB format
Insert zeroes to match #RRGGBB format