Topic: Best way to adapt map to phones resolutions

Hello,
I've made my project working fine with OnlineMaps, on WebGL it works well.

But now that I'm porting on android devices, i'm fighting with phone resolutions.
How to get a correct scale of the map between all the various phone resolutions?

I've tried to play with the Canvas scaler script (part of UI in unity) but it make the map disappear.
Someone got a solution to handle correctly these things?

Re: Best way to adapt map to phones resolutions

Hello.

Which control do you use?

In general, you need to create a script that will resize the map dynamically.
For tileset: use OnlineMapsTileSetControl.Resize.
Keep in mind that you need to use size - N * 256, so your map will be a little bit larger than the screen.
For target - texture: create a new texture of the required size, and use OnlineMapsControlBase.SetTexture.

Kind Regards,
Infinity Code Team.

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

Re: Best way to adapt map to phones resolutions

Ok thanks, I'll play with Screen.currentResolution and that.
BTW, now that I'll need to use the Tileset controls, I experience a weird problem : The map isn't showing anymore : just a gray rectangle instead of the map
(I try to insert the map with the wizard, as soon as I choose Tileset in 2Dmap, the idplay of the map will becom gray)
Does 2D map and Tileset are incompatible?

Re: Best way to adapt map to phones resolutions

You need to play with Screen.width and Screen.height.

Tileset is a dynamic mesh. You can use "Target-Tileset" only with Tileset Control.
Tileset is not UI element, so Canvas Scaler will not work.
You can make that tileset look like a 2D map. Simply set the camera perpendicular to the map.

Kind Regards,
Infinity Code Team.

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

5 (edited by raptorx81 2017-06-30 02:43:51)

Re: Best way to adapt map to phones resolutions

Hi there, I'm running into a strange issue. I'm trying to make the map texture the same size as the screen, but I'm getting tons of errors. This is my code :

Texture2D tex = new Texture2D(Screen.width, Screen.height);

OnlineMaps.instance.SetTexture(tex);

If I do that, I get a whole bunch of errors and the map just freezes up. I've also tried resizing the existing texture and it does the exact same thing. By doing this :

OnlineMaps.instance.texture.Resize(Screen.width, Screen.height);

Anyway, I've attached the error messages I am getting. If I leave the texture as is, the maps work fine. But I need the map texture to match the screen size. Any ideas?

Post's attachments

Attachment icon OnlineMapsError.jpg 203.1 kb, 80 downloads since 2017-06-30 

Re: Best way to adapt map to phones resolutions

Hello.

Thank you for bug report.
The problem with SetTexture is fixed.
The new version will be available soon.

P.S.
Not correct:

Texture2D tex = new Texture2D(Screen.width, Screen.height);

The size of the map should be N * 256.
The right way:

int w = Screen.width;
int h = Screen.height;
int ow = w % 256;
int oh = h % 256;
if (ow != 0) w += 256 - ow;
if (oh != 0) h += 256 - oh;
Texture2D texture = new Texture2D(w, h, TextureFormat.ARGB32, false);
Kind Regards,
Infinity Code Team.

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

Re: Best way to adapt map to phones resolutions

Thanks Alex, much appreciated!