Hello.
Full example below.
This example is made for Online Maps v2.4. The new method is much shorter, faster and easier.
So, if you use Online Maps v2.3, please update through the built-in update system.
Why do you want to use it as an overlay?
This overlay completely hide the map, and can be used as base tiles.
Example:
using System.Collections.Generic;
using UnityEngine;
namespace InfinityCode.OnlineMapsExamples
{
public class TilesetMapTilerOverlayExample3 : MonoBehaviour
{
private List<OverlayItem> loadingOverlays;
private void CheckDownloadComplete()
{
bool hasComplete = false;
foreach (OverlayItem data in loadingOverlays)
{
if (data.www.isDone)
{
if (string.IsNullOrEmpty(data.www.error))
{
Texture2D texture = new Texture2D(256, 256, TextureFormat.ARGB32, false);
data.www.LoadImageIntoTexture(texture);
data.tile.overlayBackTexture = texture;
}
data.Dispose();
hasComplete = true;
}
}
if (hasComplete) loadingOverlays.RemoveAll(d => d.tile == null);
}
private void OnStartDownloadTile(OnlineMapsTile tile)
{
loadingOverlays.Add(new OverlayItem(tile));
OnlineMaps.instance.StartDownloadTile(tile);
}
private void Start()
{
loadingOverlays = new List<OverlayItem>();
OnlineMaps.instance.OnStartDownloadTile += OnStartDownloadTile;
}
private void Update()
{
CheckDownloadComplete();
}
internal class OverlayItem
{
public OnlineMapsWWW www;
public OnlineMapsTile tile;
public OverlayItem(OnlineMapsTile tile)
{
this.tile = tile;
www = OnlineMapsUtils.GetWWW(string.Format("http://tile2.opencyclemap.org/Outdoors/{0}/{1}/{2}.png", tile.zoom, tile.x, tile.y));
}
public void Dispose()
{
www.Dispose();
www = null;
tile = null;
}
}
}
}
Kind Regards,
Infinity Code Team.
Boost your productivity a lot and immediately using
Ultimate Editor Enhancer.
Trial and non-commerce versions available.