- Home /
How to create 3D game object in specified pixel size?
I want to create an game object in some specified size. For example to create an 3d cube in 250x350 pixel size. I am new for unity. If anyone know help me, thank.
What is the unit of your size? Unity units? pixels? centimeters? inches? miles? yards? ....
Answer by HarshadK · Dec 16, 2014 at 07:16 AM
On unit in Unity is one meter. Convert meters to inches and create an object with that size. If scale of your Unity objects represents 1 meter to 1 scale unit then you can create object with scale value representing the 1 meter to 1 inch otherwise you have to take scale also into consideration.
Thank for reply, i have another question 1 units = how many pixels.
That is not pre-defined in 3D view as Unity adjusts the camera viewport to match the screen resolution of the device.
If want to make 350 x 250 pixel cube means then how can i scale it(in units).
From one point on the screen find the point in the world using Camera.ScreenToWorldPoint and perform the same step for another point which is say 350 pixels away. Now the difference between these two points in world space is the length for your cube with its side in 350 pixels. Similarly you can do it for 250. Now you have the world space values for these which you can use for creating your cube.
Answer by Robert-Paulson · Dec 16, 2014 at 07:19 AM
You can use Scale parameter of transform. By default cube is 1x1x1 unity unite, Scale is multiplier
Thank for reply but i can't understand. I want to create an 3d cube in 250x350 pixel size
oh man, it's like asking how big should be the cube so on photo it will be 250x350 pixels. It's a matter of other things like resolution of the screen, how far the camera from the cube and etc.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
C# Preserving GameObjects' Previous Meshes 1 Answer
C# Gameobject Rigidbody Mouse Collision 1 Answer
Populate game objects from a list?? (C#) 1 Answer
C# Child GameObject Disabled Script SetActive(false) 1 Answer