Exemplo n.º 1
0
    /// <summary>
    /// Example of how to add custom lines to the map
    /// Similar to the AddMarker functionality, you need two spherical coordinates and then call AddLine
    /// </summary>
    void AddTrajectories()
    {
        // In this example we will add random lines from 5 cities to another cities (see AddMaker example above for other options to get locations)

        for (int line = 0; line < 5; line++)
        {
            // Get two random cities
            int city1 = Random.Range(0, map.cities.Count);
            int city2 = Random.Range(0, map.cities.Count);

            // Get their sphere-coordinates
            Vector2 start = map.cities[city1].unity2DLocation;
            Vector2 end   = map.cities[city2].unity2DLocation;

            // Add lines with random color, speeds and elevation
            Color color           = new Color(Random.Range(0.5f, 1), Random.Range(0.5f, 1), Random.Range(0.5f, 1));
            float elevation       = Random.Range(0, 0.5f);              // elevation is % relative to the Earth radius
            float drawingDuration = 4.0f;
            float lineWidth       = 1.0f;
            float fadeAfter       = 2.0f;       // line stays for 2 seconds, then fades out - set this to zero to avoid line removal
            map.AddLine(start, end, color, elevation, drawingDuration, lineWidth, fadeAfter);
        }
    }