コード例 #1
0
    /// <summary>
    /// Stops the current process map generation, clears all buffers and completely redraws the map.
    /// </summary>
    public void RedrawImmediately()
    {
        OnlineMapsThreadManager.Dispose();

        if (renderInThread)
        {
            if (_buffer != null)
            {
                _buffer.Dispose();
                _buffer = null;
            }

#if NETFX_CORE
            if (renderThread != null)
            {
                renderThread.Dispose();
            }
#endif
#if !UNITY_WEBGL
            renderThread = null;
#endif
        }
        else
        {
            StartBuffer();
        }

        Redraw();
    }
コード例 #2
0
    private void OnDestroy()
    {
        OnlineMapsThreadManager.Dispose();

        if (_buffer != null)
        {
            _buffer.Dispose();
            _buffer = null;
        }
#if NETFX_CORE
        if (renderThread != null)
        {
            renderThread.Dispose();
        }
#endif
#if !UNITY_WEBGL
        renderThread = null;
#endif
        _control = null;

        if (defaultColors != null && texture != null)
        {
            if (texture.width * texture.height == defaultColors.Length)
            {
                texture.SetPixels(defaultColors);
                texture.Apply();
            }
        }
    }
コード例 #3
0
ファイル: OnlineMaps.cs プロジェクト: dimatti/maps_test
    private void OnDisable()
    {
        OnlineMapsThreadManager.Dispose();

        if (_buffer != null)
        {
            _buffer.Dispose();
            _buffer = null;
        }

#if NETFX_CORE
        if (renderThread != null)
        {
            renderThread.Dispose();
        }
#endif
#if !UNITY_WEBGL
        renderThread = null;
#endif

        if (tileManager != null)
        {
            tileManager.Dispose();
            tileManager = null;
        }

        _control = null;

        if (_instance == this)
        {
            _instance = null;
        }
    }
コード例 #4
0
ファイル: OnlineMaps.cs プロジェクト: dimatti/maps_test
    private void OnDestroy()
    {
        OnlineMapsThreadManager.Dispose();

        if (_buffer != null)
        {
            _buffer.Dispose();
            _buffer = null;
        }
#if NETFX_CORE
        if (renderThread != null)
        {
            renderThread.Dispose();
        }
#endif
#if !UNITY_WEBGL
        renderThread = null;
#endif
        if (tileManager != null)
        {
            tileManager.Dispose();
            tileManager = null;
        }

        _control = null;

        if (defaultColors != null && texture != null)
        {
            if (texture.width * texture.height == defaultColors.Length)
            {
                texture.SetPixels(defaultColors);
                texture.Apply();
            }
        }

        OnChangePosition = null;
        OnChangeZoom     = null;
        OnMapUpdated     = null;
        OnUpdateBefore   = null;
        OnUpdateLate     = null;
    }
コード例 #5
0
    private void OnDisable()
    {
        OnlineMapsThreadManager.Dispose();

        if (_buffer != null)
        {
            _buffer.Dispose();
            _buffer = null;
        }

#if NETFX_CORE
        if (renderThread != null)
        {
            renderThread.Dispose();
        }
#endif
#if !UNITY_WEBGL
        renderThread = null;
#endif

        _control         = null;
        OnChangePosition = null;
        OnChangeZoom     = null;
        OnMapUpdated     = null;
        OnMapUpdated     = null;
        OnUpdateBefore   = null;
        OnUpdateLate     = null;
        OnlineMapsTile.OnGetResourcesPath        = null;
        OnlineMapsTile.OnTileDownloaded          = null;
        OnlineMapsTile.OnTrafficDownloaded       = null;
        OnlineMapsMarkerBase.OnMarkerDrawTooltip = null;

        if (_instance == this)
        {
            _instance = null;
        }
    }
コード例 #6
0
    private void SetMarkerToBuffer(OnlineMapsMarker marker, OnlineMapsVector2i bufferPosition, int bufferZoom, OnlineMapsVector2i frontBufferPosition, double sx, double sy, double ex, double ey)
    {
        const int s = OnlineMapsUtils.tileSize;

        double mx, my;

        marker.GetPosition(out mx, out my);

        int maxX = 1 << bufferZoom;

        bool isEntireWorld       = map.buffer.renderState.width == maxX * s;
        bool isBiggestThatBuffer = map.buffer.renderState.width + 512 == maxX * s;

        if (isEntireWorld || isBiggestThatBuffer)
        {
        }
        else if (!(((mx > sx && mx < ex) || (mx + 360 > sx && mx + 360 < ex) || (mx - 360 > sx && mx - 360 < ex)) &&
                   my < sy && my > ey))
        {
            return;
        }

#if !UNITY_WEBGL
        int maxCount = 20;
        while (marker.locked && maxCount > 0)
        {
            OnlineMapsUtils.ThreadSleep(1);
            maxCount--;
        }
#endif

        marker.locked = true;

        double px, py;
        map.projection.CoordinatesToTile(mx, my, bufferZoom, out px, out py);
        px -= bufferPosition.x;
        py -= bufferPosition.y;

        if (isEntireWorld)
        {
            double tx, ty;
            map.projection.CoordinatesToTile(map.buffer.renderState.longitude, map.buffer.renderState.latitude, bufferZoom, out tx, out ty);
            tx -= map.buffer.renderState.width / s / 2;

            if (px < tx)
            {
                px += maxX;
            }
        }
        else
        {
            if (px < 0)
            {
                px += maxX;
            }
            else if (px > maxX)
            {
                px -= maxX;
            }
        }

        float zoomCoof = map.buffer.renderState.zoomCoof;

        px *= s;
        py *= s;

        int ipx = (int)((px - frontBufferPosition.x) / zoomCoof);
        int ipy = (int)((py - frontBufferPosition.y) / zoomCoof);

        OnlineMapsVector2i ip = marker.GetAlignedPosition(ipx, ipy);

        Color32[] markerColors = marker.colors;
        if (markerColors == null || markerColors.Length == 0)
        {
            return;
        }

        int markerWidth  = marker.width;
        int markerHeight = marker.height;

        OnlineMapsBuffer buffer = map.buffer;

        for (int y = 0; y < marker.height; y++)
        {
            if (ip.y + y < 0 || ip.y + y >= map.height)
            {
                continue;
            }

            int cy = (markerHeight - y - 1) * markerWidth;

            for (int x = 0; x < marker.width; x++)
            {
                if (ip.x + x < 0 || ip.x + x >= map.buffer.renderState.width)
                {
                    continue;
                }

                try
                {
                    buffer.SetColorToBuffer(markerColors[cy + x], ip, y, x);
                }
                catch
                {
                }
            }
        }

        if (isEntireWorld)
        {
            ip.x -= (int)(buffer.renderState.width / zoomCoof);
            for (int y = 0; y < marker.height; y++)
            {
                if (ip.y + y < 0 || ip.y + y >= map.height)
                {
                    continue;
                }

                int cy = (markerHeight - y - 1) * markerWidth;

                for (int x = 0; x < marker.width; x++)
                {
                    if (ip.x + x < 0 || ip.x + x >= map.buffer.renderState.width)
                    {
                        continue;
                    }

                    try
                    {
                        buffer.SetColorToBuffer(markerColors[cy + x], ip, y, x);
                    }
                    catch
                    {
                    }
                }
            }

            ip.x += (int)(buffer.renderState.width * 2 / zoomCoof);
            for (int y = 0; y < marker.height; y++)
            {
                if (ip.y + y < 0 || ip.y + y >= map.height)
                {
                    continue;
                }

                int cy = (markerHeight - y - 1) * markerWidth;

                for (int x = 0; x < marker.width; x++)
                {
                    if (ip.x + x < 0 || ip.x + x >= map.buffer.renderState.width)
                    {
                        continue;
                    }

                    try
                    {
                        buffer.SetColorToBuffer(markerColors[cy + x], ip, y, x);
                    }
                    catch
                    {
                    }
                }
            }
        }

        marker.locked = false;
    }
コード例 #7
0
    /// <summary>
    /// Stops the current process map generation, clears all buffers and completely redraws the map.
    /// </summary>
    public void RedrawImmediately()
    {
#if !UNITY_WEBGL
        if (renderThread != null)
        {
#if UNITY_IOS
            renderThread.Interrupt();
#else
            renderThread.Abort();
#endif
        }
        renderThread = null;
#endif

        OnlineMapsThreadManager.Dispose();

        if (_buffer != null)
        {
            _buffer.Dispose();
            _buffer = null;
        }

        GCCollect();

        Redraw();
    }
コード例 #8
0
// ReSharper disable once UnusedMember.Local
    private void OnDestroy()
    {
        OnlineMapsThreadManager.Dispose();

        if (_buffer != null)
        {
            _buffer.Dispose();
            _buffer = null;
        }
        
        if (defaultColors != null && texture != null)
        {
            texture.SetPixels(defaultColors);
            texture.Apply();
        }

#if !UNITY_WEBGL
        if (renderThread != null)
        {
#if UNITY_IOS
            renderThread.Interrupt();
#else
            renderThread.Abort();
#endif
        }
        renderThread = null;
#endif

        drawingElements = null;
        markers = null;

        GCCollect();
    }
コード例 #9
0
    private void CheckBaseProps()
    {
        if (mapType != _mapType)
        {
            activeType = OnlineMapsProvider.FindMapType(mapType);
            _mapType   = mapType = activeType.fullID;
            if (_buffer != null)
            {
                _buffer.UnloadOldTypes();
            }
            Redraw();
        }

        if (_language != language || _labels != labels)
        {
            _labels   = labels;
            _language = language;

            if (_buffer != null)
            {
                _buffer.Dispose();
                _buffer = null;
#if NETFX_CORE
                if (renderThread != null)
                {
                    renderThread.Dispose();
                }
#endif
#if !UNITY_WEBGL
                renderThread = null;
#endif
            }

            Redraw();
        }
        if (traffic != _traffic || trafficProviderID != _trafficProviderID)
        {
            _traffic = traffic;

            _trafficProviderID = trafficProviderID;
            trafficProvider    = OnlineMapsTrafficProvider.GetByID(trafficProviderID);

            OnlineMapsTile[] tiles;
            lock (OnlineMapsTile.lockTiles)
            {
                tiles = OnlineMapsTile.tiles.ToArray();
            }
            if (traffic)
            {
                foreach (OnlineMapsTile tile in tiles)
                {
                    OnlineMapsRasterTile rTile = tile as OnlineMapsRasterTile;
                    rTile.trafficProvider        = trafficProvider;
                    rTile.trafficWWW             = new OnlineMapsWWW(rTile.trafficURL);
                    rTile.trafficWWW["tile"]     = tile;
                    rTile.trafficWWW.OnComplete += OnlineMapsTileManager.OnTrafficWWWComplete;
                    if (rTile.trafficTexture != null)
                    {
                        OnlineMapsUtils.Destroy(rTile.trafficTexture);
                        rTile.trafficTexture = null;
                    }
                }
            }
            else
            {
                foreach (OnlineMapsTile tile in tiles)
                {
                    OnlineMapsRasterTile rTile = tile as OnlineMapsRasterTile;
                    if (rTile.trafficTexture != null)
                    {
                        OnlineMapsUtils.Destroy(rTile.trafficTexture);
                        rTile.trafficTexture = null;
                    }
                    rTile.trafficWWW = null;
                }
            }
            Redraw();
        }
    }
コード例 #10
0
ファイル: OnlineMaps.cs プロジェクト: juliancruz87/transpp
// ReSharper disable once UnusedMember.Local
    private void OnDestroy()
    {
        buffer.Dispose();
        _buffer = null;
        if (defaultColors != null)
        {
            texture.SetPixels(defaultColors);
            texture.Apply();
        }
        if (renderThread != null && renderThread.IsAlive) renderThread.Abort();
        renderThread = null;
        Resources.UnloadUnusedAssets();
        GC.Collect();
    }