What is the relation between the scaling(unit) and pixels

I want to scale something based on the screen resolution.So I want to scale the gameobject to the pixels.which is in general done in units. like

transform.localScale = new Vector3(9.5f,12f,1);

i want to use pixel valuesin place of 9.5f and 12f.

so can anyone please tell me how to convert these values to pixels…

there’s no relation at all, you need to compute it from camera

Screen.width and Screen.height gives you screen dimensions in pixels. Camera.orthographicSize is the half size of height in units. So;

  • set the orthographic size to, let’s say, 5. Then Screen.height would be 10 units.
  • set scale of the object to = (95f / Screen.height, 120f / Screen.height, 1f)

of course there are other ways, such as Camera.ScreenToWorldPoint. But above will help you understand the basics better.

hope this helps.