Beispiel #1
0
    public static List <GameObject> GetOSMTileGameObjectsInBoundingBoxCutting(MapBounds bounds, int zoomLevel)
    {
        List <GameObject> tileGOs = new List <GameObject>();
        List <OSMTile>    tiles   = GetOSMTilesInBoundingBox(bounds, zoomLevel);

        foreach (OSMTile tile in tiles)
        {
            GameObject       tileGO        = GetOSMTileGameObject(tile);
            OSMTileBehaviour tileBehaviour = tileGO.GetComponent <OSMTileBehaviour>();
            tileBehaviour.InitializeCuttingBounds(bounds);
            tileGOs.Add(tileGO);
        }

        return(tileGOs);
    }
Beispiel #2
0
    public static GameObject GetOSMTileGameObject(OSMTile tile)
    {
        GameObject tilesParent = GameObject.Find("OSMTiles");

        if (tilesParent == null)
        {
            tilesParent = new GameObject("OSMTiles");
        }

        Vector2 coords = new Vector2(tile.X, tile.Y);

        if (!OSMTileProvider.tileBehaviours.ContainsKey(tile.ZoomLevel))
        {
            OSMTileProvider.tileBehaviours.Add(tile.ZoomLevel, new Dictionary <Vector2, OSMTileBehaviour>());
        }

        GameObject zoomLevelParent;

        if (!tilesParent.HasChildNamed(tile.ZoomLevel.ToString(), out zoomLevelParent))
        {
            zoomLevelParent = tilesParent.CreateChild(tile.ZoomLevel.ToString());
        }


        if (!OSMTileProvider.tileBehaviours[tile.ZoomLevel].ContainsKey(coords))
        {
            GameObject       tileGO           = zoomLevelParent.CreateRenderableChild("osmTile_" + tile.ZoomLevel + "_" + tile.X + "_" + tile.Y);
            OSMTileBehaviour osmTileBehaviour = tileGO.AddComponent <OSMTileBehaviour>();
            osmTileBehaviour.tile = GetOSMTile(tile.X, tile.Y, tile.ZoomLevel);

            OSMTileProvider.tileBehaviours[tile.ZoomLevel].Add(coords, osmTileBehaviour);
            osmTileBehaviour.Initialize();
        }

        return(OSMTileProvider.tileBehaviours[tile.ZoomLevel][coords].gameObject);
    }
Beispiel #3
0
 public void Awake()
 {
     osmTileBehaviour = (OSMTileBehaviour)target as OSMTileBehaviour;
 }