コード例 #1
0
        /// <summary>
        /// Convert a string to a Color32; supports RasterPropMonitor COLOR_
        /// names.
        /// </summary>
        /// <param name="colorString">String to convert</param>
        /// <param name="comp">Reference to the MASFlightComputer</param>
        /// <returns>Color value.</returns>
        internal static UnityEngine.Color32 ParseColor32(string colorString, MASFlightComputer comp)
        {
            colorString = colorString.Trim();

            if (colorString.StartsWith("#"))
            {
                Color32 c;

                ParseHexColor(colorString, out c);

                return(c);
            }
            else if (colorString.StartsWith("COLOR_"))
            {
                // Using a RasterPropMonitor named color.
                return(comp.GetNamedColor(colorString));
            }
            else
            {
                int numCommas = colorString.Split(',').Length - 1;
                if (numCommas < 2 || numCommas > 3)
                {
                    Utility.LogStaticWarning("Parsing color string \"{0}\": it does not appear to have the right number of entries for an R,G,B{{,A}} entry.", colorString);
                }
                return(ConfigNode.ParseColor32(colorString));
            }
        }