Search Unity

Get the relative size of game objects of two different canvases

Discussion in 'Editor & General Support' started by AzeExMachina, Dec 12, 2018.

  1. AzeExMachina

    AzeExMachina

    Joined:
    Jan 30, 2016
    Posts:
    14
    I have an issue that I still wasn't able to solve. In my application I have two canvases:

    • the main one, which is a screen space-camera canvas with the main camera attached on it
    • the second one is child of a Game Object in a far world position, like (4000, -15, 4000) and it's a world space canvas, this canvas also has a camera on it, which has a certain position (0, 200, 0) relative to the game object container.
    With my second canvas I'm creating a RenderTexture that I'm passing on my main canvas, inside the raw image, to visualize the things I have on my canvas and also on the other children of the container.

    Now, the question is, how can I calculate properly the size of the objects on the second canvas? Like I need to understand how many pixels they are, relative to my UI canvas. As of now all the sizes are different, like, a 100x100 object on my first canvas results way more little than a 100x100 object on my second one.

    Thanks for your help, I hope I was clear in explaining the issue and the setup.