Topic: Example Scene Request - Mobile Setup

Hello,

First off... great asset! I am really looking forward to working with Online Maps. I don't have much experience with Unity, so I am having trouble merely getting things setup correctly for mobile devices.

I have seen that this problem has come up several times on the forum...

http://forum.infinity-code.com/viewtopic.php?id=293
forum.infinity-code.com/viewtopic.php?id=334
forum.infinity-code.com/viewtopic.php?id=215

In those posts, there are several potential solutions, but sometimes they are for older versions of Online Maps, and some references to the API are different. I have tried getting things to work, but have had trouble putting all the pieces together. Sometimes the map doesn't show up fully on the screen, or the map quality is low, or both.

To help myself, and others starting out, I was wondering if the developers or someone on the forum could create an example scene that shows the best way to do the following:

1. Proper setup of camera (distance from map, orientation, position, etc.)
2. Proper setup of map in relation to camera, and best settings for mobile (tileset settings, caching, etc.)
3. Automatic adjustments for screen resolution, size, and rotation

This asset is really good, and I would imagine many people using it are looking to target mobile devices. It would be awesome if an example like this was included in the Atlas, and in the package examples folder so that users can get going right away on mobile, while following best practices using the latest features of Online Maps, and Unity.

Re: Example Scene Request - Mobile Setup

Hello.

All three of your points are very individual for each project.
Any recommendations that I can give, will be good for one project, but completely wrong for another.

For example, a good way to adjust the map to fit the screen (requires Camera / Projection - Orthoghaphic):

using UnityEngine;

public class AdjustMapToScreen : MonoBehaviour
{
    private int screenWidth;
    private int screenHeight;

    private void ResizeMap()
    {
        screenWidth = Screen.width;
        screenHeight = Screen.height;

        int mapWidth = screenWidth / 256 * 256;
        int mapHeight = screenHeight / 256 * 256;
        if (screenWidth % 256 != 0) mapWidth += 256;
        if (screenHeight % 256 != 0) mapHeight += 256;
        OnlineMapsTileSetControl.instance.Resize(mapWidth, mapHeight);
        OnlineMapsTileSetControl.instance.activeCamera.orthographicSize = screenHeight / 2;
    }

    private void Start()
    {
        ResizeMap();
    }

    private void Update()
    {
        if (screenWidth != Screen.width || screenHeight != Screen.height) ResizeMap();
    }
}

This way will give you an excellent result.
But if you use buildings, 3D markers or elevation, this is completely wrong.
In this case, you can use this way (requires Camera / Projection - Perspective):

using UnityEngine;

public class AdjustMapToScreen2 : MonoBehaviour
{
    private int screenWidth;
    private int screenHeight;

    private void ResizeMap()
    {
        screenWidth = Screen.width;
        screenHeight = Screen.height;

        int mapWidth = screenWidth / 256 * 256;
        int mapHeight = screenHeight / 256 * 256;
        if (screenWidth % 256 != 0) mapWidth += 256;
        if (screenHeight % 256 != 0) mapHeight += 256;
        OnlineMapsTileSetControl.instance.Resize(mapWidth, mapHeight);

        OnlineMapsTileSetControl.instance.cameraDistance = screenHeight * 0.9f;
    }

    private void Start()
    {
        ResizeMap();
    }

    private void Update()
    {
        if (screenWidth != Screen.width || screenHeight != Screen.height) ResizeMap();
    }
}

But still there are many situations where this way will also be wrong.
So, the right way always depends on your needs.

Settings of cache is best to use by default.

We are planning to soon make a big update the atlas of examples.
Currently we have several hundred scripts, some of which we will make as examples.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Example Scene Request - Mobile Setup

Thanks for the script examples! I will give them a try.