#### Topic: The scale of the canvas in the "World Space" mode as in the "Overlay"

Hey.
Tell me, how can I get a value for the canvas scale that is inside the marker on the map, so that this canvas looks like a normal canvas in the "Overlay"mode?

When I was making my map, I used the "height/width" factor, I remember that it was used to set the scale.
But in your map type "Tileset" is the height of the camera.
Tell me, please, how to get the scale given the height of the camera?

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

Hello.

Unfortunately, I did not understand your question.

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

Now for a phone with a screen resolution of 720-1480, so that the canvas that is in the marker is real size, I set the camera to a height of ~1610.
Hence the marker size = 1000/1610 = 0.62. The marker then becomes the correct size when the camera height is 1000.
But we need a formula to calculate the coefficient, which in this case is 0.62.

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

For resolution 1080h1920 need the height of the camera 1325. Then the marker scale at the camera height 1000 will be 1000/1325 = 0.75.

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

What is the height of the camera?
I know: fov, orthographic size, screen height, and many other similar fields.
But, I do not know what is "height of the camera".
The most similar is "Canvas Scales / UI Scale Mode - Scale With Screen Size / Reference Resolution".
But this is not available for Canvas / Render Mode - World Space.

For screen height 1480, you are using a camera height of 1610.
For screen height 1920, you are using a camera height of 1325.
I do not see the logic in these values.

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

The height of the camera - "Camera Distance" to "OnlineMapsTileSetControl".
Sorry I wasn't accurate.

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

For "Canvas / Render Mode - World Space" you need to set "scale" in the "transform"

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

1. Get the tile position of the marker.
If you use regular markers:
OnlineMapsMarkerBase.GetTilePosition
http://infinity-code.com/doxygen/online … 7f668a7e68
If you are using custom marker engine:
OnlineMaps.instance.projection.CoordinatesToTile

2. Subtract from Tile Y the height of the marker texture in pixels divided by 256.
double ty2 = ty - markerHeight / 256.

3. Convert the new tile position to geographical coordinates.
OnlineMaps.instance.projection.TileToCoordinates

4. Convert the original and new coordinates to the screen positions.
OnlineMapsControlBase.GetScreenPosition
http://infinity-code.com/doxygen/online … b35214c35b

5. Subtract the second screen position from the first screen position to calculate the screen height of the marker when scale = 1.

6. Use this value to calculate the required scale.

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

Thank you very much!
You are a miracle!

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

I did this.
When the camera is installed at the distance of 1610, the resolution 720х1480, I have to get a result, which is sent to the input(the value markerHeight). I pass 40 and get -77. Must be -40, right?

What's wrong?

``````        public void CalculateScaleByResolution() {
if (OnlineMaps.instance == null) {
return;
}
float lon = 38;
float lat = 45;
int zoom = OnlineMaps.instance.zoom;
OnlineMaps.instance.projection.CoordinatesToTile(lon, lat, zoom, out double tx, out double ty);
float markerHeight = JourneyObject.instance.sizeElement;
double ty2 = ty - markerHeight / 256;

OnlineMaps.instance.projection.TileToCoordinates(tx, ty2, zoom, out double lon2, out double lat2);

var res1 = OnlineMapsControlBase.instance.GetScreenPosition(new Vector2(lon, lat));
var res2 = OnlineMapsControlBase.instance.GetScreenPosition(new Vector2((float)lon2, (float)lat2));

Debug.Log("res1 = " + res1);
Debug.Log("res2 = " + res2);

res1 -= res2;
Debug.Log("res3 = " + res1);

var val = markerHeight / res1.y;
Debug.Log("val = " + val);
}``````

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

I tested your code and it works correctly.
Except that it returns a negative value.

Why should it be -40?
This can be any value that the marker occupies on the screen when scale = 1.
If you move the camera very close to the map, it will show you very big value.

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

[image]
https://pp.userapi.com/c849136/v8491366 … Whupgg.jpg
[/image]

There are objects on the map. When the object is beyond the boundaries of sight of the camera, it is attached to the edge of the screen, passing in the Canvas UI.
The picture shows that the objects that are visible to the camera are markers on the map and their scale is ~2 times larger than it should be.
This screenshot is made at a distance of the camera = 1000, with a screen resolution of 720 x 1480

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

In the end, we have to multiply the result by 2 more. Thank you!)

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

Each zoom has a different scale. I need the object on which the "Canvas" with the "World Space" mode, on any zoom, be of such a scale that it is exactly the same size as the object, but is in the Canvas hierarchy.
In NGUI, this is done using the ScreenHeight / ScreenWidth coefficient. But the map also takes into account "Distance a camera".

Help!)

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

Please send to support (support@infinity-code.com) a scene (as a package), that shows the problem.
I will check it out and give you advice how to fix this.

I do not need your working project.
I need ANY scene where I can check it out.

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

The project has a CanvasMapObj prefab, there is a picture in it.
Copies of this prefab: # 1 is in the canvas, and # 2 is inside the card.

URL removed. Please do not post asset on the forum.

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

At a screen resolution of 1080x1920, object number 2 needs to set the scale to 0.6, and then both objects will have the same size for the UI canvas

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

Sent a project to you in PM

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

I think I understand what you are trying to do.

Unity has a vertical field of view.
So let's supose that for Screen Height is 1080, the scale should be equal to 1.
When starting the application and resizing the screen, set scale = 1080 / New Screen Height.

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

#### Re: The scale of the canvas in the "World Space" mode as in the "Overlay"

Excellent. Many thanks!)