/// <summary> /// Dispose of buffer. /// </summary> public void Dispose() { try { OnSortMarker = null; lock (OnlineMapsTile.tiles) { foreach (OnlineMapsTile tile in OnlineMapsTile.tiles) { tile.Dispose(); } OnlineMapsTile.tiles = null; } frontBuffer = null; backBuffer = null; smartBuffer = null; status = OnlineMapsBufferStatus.disposed; newTiles = null; disposed = true; } catch (Exception exception) { Debug.Log(exception.Message); } }
/// <summary> /// Dispose of buffer. /// </summary> public void Dispose() { try { map.tileManager.Reset(); frontBuffer = null; backBuffer = null; map = null; status = OnlineMapsBufferStatus.disposed; newTiles = null; disposed = true; } catch (Exception exception) { Debug.Log(exception.Message); } }
public void GenerateFrontBuffer() { try { api.GetPosition(out apiLongitude, out apiLatitude); apiZoom = api.zoom; while (true) { #if !UNITY_WEBGL while (status != OnlineMapsBufferStatus.start && api.renderInThread) { if (disposed) return; Thread.Sleep(1); } #endif status = OnlineMapsBufferStatus.working; double px = 0, py = 0; try { api.GetPosition(out px, out py); int zoom = api.zoom; bool fullRedraw = redrawType == OnlineMapsRedrawType.full; if (disposed) { fullRedraw = true; disposed = false; } else if (newTiles != null && api.target == OnlineMapsTarget.texture) ApplyNewTiles(); bool backBufferUpdated = UpdateBackBuffer(px, py, zoom, fullRedraw); if (api.target == OnlineMapsTarget.texture) { GetFrontBufferPosition(px, py, bufferPosition, zoom, api.width, api.height); if (backBufferUpdated) { foreach (OnlineMapsDrawingElement element in api.drawingElements) element.Draw(backBuffer, bufferPosition, width, height, zoom); SetMarkersToBuffer(api.markers); } if (!api.useSmartTexture || !generateSmartBuffer) UpdateFrontBuffer(api.width, api.height); else UpdateSmartBuffer(api.width, api.height); } } catch (Exception exception) { Debug.Log(exception.Message + "\n" + exception.StackTrace); } status = OnlineMapsBufferStatus.complete; apiLongitude = px; apiLatitude = py; apiZoom = api.zoom; if (needUnloadTiles) UnloadOldTiles(); if (!api.needGC) GC.Collect(); #if !UNITY_WEBGL if (!api.renderInThread) break; #else break; #endif } } catch { } }
/// <summary> /// Dispose of buffer. /// </summary> public void Dispose() { try { lock (OnlineMapsTile.tiles) { foreach (OnlineMapsTile tile in OnlineMapsTile.tiles) tile.Dispose(); OnlineMapsTile.tiles = null; } frontBuffer = null; backBuffer = null; smartBuffer = null; status = OnlineMapsBufferStatus.disposed; newTiles = null; zooms = null; disposed = true; } catch (Exception exception) { Debug.Log(exception.Message); } }
public void GenerateFrontBuffer() { try { api.GetPosition(out apiLongitude, out apiLatitude); apiZoom = api.zoom; while (!disposed) { #if !UNITY_WEBGL while (status != OnlineMapsBufferStatus.start && api.renderInThread) { if (disposed) { return; } #if NETFX_CORE OnlineMapsThreadWINRT.Sleep(1); #else Thread.Sleep(1); #endif } #endif status = OnlineMapsBufferStatus.working; double px = 0, py = 0; try { api.GetPosition(out px, out py); int zoom = api.zoom; bool fullRedraw = redrawType == OnlineMapsRedrawType.full; if (newTiles != null && api.target == OnlineMapsTarget.texture) { ApplyNewTiles(); } if (disposed) { return; } bool backBufferUpdated = UpdateBackBuffer(px, py, zoom, fullRedraw); if (disposed) { return; } if (api.target == OnlineMapsTarget.texture) { GetFrontBufferPosition(px, py, bufferPosition, zoom, api.width, api.height); if (backBufferUpdated) { for (int i = 0; i < api.drawingElements.Count; i++) { OnlineMapsDrawingElement element = api.drawingElements[i]; if (disposed) { return; } element.Draw(backBuffer, bufferPosition, width, height, zoom); } SetMarkersToBuffer(api.markers); } if (disposed) { return; } if (generateSmartBuffer && api.useSmartTexture) { UpdateSmartBuffer(api.width, api.height); } else { UpdateFrontBuffer(api.width, api.height); } } } catch (Exception exception) { if (disposed) { return; } Debug.Log(exception.Message + "\n" + exception.StackTrace); } status = OnlineMapsBufferStatus.complete; apiLongitude = px; apiLatitude = py; apiZoom = api.zoom; if (needUnloadTiles) { UnloadOldTiles(); } #if !UNITY_WEBGL if (!api.renderInThread) { break; } #else break; #endif } } catch { } }
public void GenerateFrontBuffer() { try { lastState = new StateProps { floatZoom = map.floatZoom, width = map.width, height = map.height }; map.GetPosition(out lastState.longitude, out lastState.latitude); map.GetCorners(out lastState.leftLongitude, out lastState.topLatitude, out lastState.rightLongitude, out lastState.bottomLatitude); while (!disposed) { #if !UNITY_WEBGL while (status != OnlineMapsBufferStatus.start && map.renderInThread) { if (disposed) { return; } OnlineMapsUtils.ThreadSleep(1); } #endif status = OnlineMapsBufferStatus.working; renderState = new StateProps { floatZoom = map.floatZoom, width = map.width, height = map.height }; try { map.GetPosition(out renderState.longitude, out renderState.latitude); map.GetCorners(out renderState.leftLongitude, out renderState.topLatitude, out renderState.rightLongitude, out renderState.bottomLatitude); if (newTiles != null && map.control.resultIsTexture) { ApplyNewTiles(); } if (disposed) { return; } UpdateBackBuffer(renderState.longitude, renderState.latitude, renderState.zoom); if (disposed) { return; } if (map.control.resultIsTexture) { GetFrontBufferPosition(renderState.longitude, renderState.latitude, bufferPosition, renderState.floatZoom, renderState.width, renderState.height); UpdateFrontBuffer(renderState.width, renderState.height, renderState.floatZoom); if (disposed) { return; } foreach (OnlineMapsDrawingElement element in OnlineMapsDrawingElementManager.instance) { if (disposed) { return; } element.Draw(frontBuffer, new Vector2(bufferPosition.x + (float)frontBufferPosition.x / OnlineMapsUtils.tileSize, bufferPosition.y + (float)frontBufferPosition.y / OnlineMapsUtils.tileSize), renderState.width, renderState.height, renderState.floatZoom); } if (map.control.OnDrawMarkers != null) { map.control.OnDrawMarkers(); } } } catch (Exception exception) { if (disposed) { return; } Debug.Log(exception.Message + "\n" + exception.StackTrace); } status = OnlineMapsBufferStatus.complete; lastState = renderState; #if !UNITY_WEBGL if (!map.renderInThread) { break; } #else break; #endif } } catch { } }
public void GenerateFrontBuffer() { apiPosition = api.position; apiZoom = api.zoom; while (true) { while (status != OnlineMapsBufferStatus.start) Thread.Sleep(1); status = OnlineMapsBufferStatus.working; try { Vector2 pos = api.position; int zoom = api.zoom; bool fullRedraw = redrawType == OnlineMapsRedrawType.full; if (disposed) { fullRedraw = true; disposed = false; } else if (newTiles != null) ApplyNewTiles(); bool backBufferUpdated = UpdateBackBuffer(pos, zoom, fullRedraw); GetFrontBufferPosition(pos, bufferPosition, zoom, api.width, api.height); if (backBufferUpdated) { foreach (OnlineMapsDrawingElement element in api.drawingElements) element.Draw(backBuffer, bufferPosition, width, height, zoom); SetMarkersToBuffer(api.markers); } if (api.target == OnlineMapsTarget.texture) { if (!api.useSmartTexture || !generateSmartBuffer) UpdateFrontBuffer(api.width, api.height); else UpdateSmartBuffer(api.width, api.height); } } catch (Exception exception) { Debug.Log(exception.Message + "\n" + exception.StackTrace); } GC.Collect(); status = OnlineMapsBufferStatus.complete; apiPosition = api.position; apiZoom = api.zoom; } }