PersistentTrails.Utilities.makeColor C# (CSharp) Method

makeColor() public static method

public static makeColor ( string colorString ) : Color
colorString string
return Color
        public static Color makeColor(string colorString)
        {
            string[] split = colorString.Split(';');

            double r, g, b, a;
            r = Double.Parse(split[0]);
            g = Double.Parse(split[1]);
            b = Double.Parse(split[2]);
            a = Double.Parse(split[3]);

            return new Color((float)r, (float)g, (float)b, (float)a);
        }

Usage Example

        private void parseLegacyTrack(StreamReader reader)
        {
            Debug.Log("parsing legacy track");

            this.TrackName   = reader.ReadLine();
            this.Description = reader.ReadLine();
            string visString = reader.ReadLine();

            string refBodyName = reader.ReadLine();

            //Debug.Log("reading celestialbody = " + refBodyName);
            this.referenceBody = Utilities.CelestialBodyFromName(refBodyName);
            //Debug.Log("reading + parsing samplingFactor");
            this.SamplingFactor = int.Parse(reader.ReadLine());
            //Debug.Log("samplingString = " + samplingString + ", parsed to samplingFactor = " + samplingFactor);

            string colorString = reader.ReadLine();

            this.LineColor = Utilities.makeColor(colorString);
            LineWidth      = float.Parse(reader.ReadLine());

            string numString = reader.ReadLine();

            this.ConeRadiusToLineWidthFactor = float.Parse(numString);
            numString = reader.ReadLine();
            this.NumDirectionMarkers = int.Parse(numString);

            //Debug.Log("Header reading complete");



            //Debug.Log("read waypoints");
            reader.ReadLine();               //WAYPOINTS
            string line = reader.ReadLine(); //first waypoint

            while (line != "[LOGENTRIES]" && !reader.EndOfStream)
            {
                //Debug.Log("reading waypointline = " + line);
                string[] split = line.Split(';');
                double   lat, lon, alt, time;
                Double.TryParse(split[0], out lat);
                Double.TryParse(split[1], out lon);
                Double.TryParse(split[2], out alt);
                Double.TryParse(split[3], out time);
                waypoints.Add(new Waypoint(lat, lon, alt, Quaternion.identity, new Vector3(), time));
                line = reader.ReadLine();
            }


            //Debug.Log("read logentries");
            line = reader.ReadLine();//first entry
            while (!reader.EndOfStream)
            {
                string trimmed = line;
                trimmed = trimmed.Trim();
                if (!string.IsNullOrEmpty(trimmed))
                {
                    //Debug.Log("reading logentryline = " + line);
                    string[] split = line.Split(';');
                    double   lat, lon, alt, time;
                    Double.TryParse(split[0], out lat);
                    Double.TryParse(split[1], out lon);
                    Double.TryParse(split[2], out alt);
                    Double.TryParse(split[3], out time);
                    logEntries.Add(new LogEntry(lat, lon, alt, Quaternion.identity, new Vector3(), time, split[4], split[5]));
                }
                line = reader.ReadLine();
            }



            Debug.Log("Created track from file containing " + waypoints.Count + "waypoints and " + logEntries.Count + " log entries");
            Visible  = (visString == "1");
            Modified = true; //legacy tracks are marked as modified for conversion
        }
All Usage Examples Of PersistentTrails.Utilities::makeColor