Search Unity

World Space Unit?

Discussion in 'General Graphics' started by zhutianlun810, Jun 10, 2019.

  1. zhutianlun810

    zhutianlun810

    Joined:
    Sep 17, 2017
    Posts:
    172
    Hello,

    I am confused on the distance unit in world space. I have the code:
    Code (CSharp):
    1. public float voxelSpaceSize = 25.0f;    
    2.  
    3. Gizmos.color = new Color(1.0f, 0.25f, 0.0f, 0.5f);
    4.  
    5. Gizmos.DrawCube(voxelSpaceOrigin, new Vector3(voxelSpaceSize, voxelSpaceSize, voxelSpaceSize));
    And the result is like:


    It nearly cover the whole scene. And I find the distance between two trees in the map is larger than 100?

    The distance is around 160 units...
     

    Attached Files:

  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,445
    For 3D world space, one unit is *typically* 1 meter, but can be whatever you want. It's best to choose a scale where the entire scene is within about 1000 units, or numerical precision erodes.

    For 2D screen space, one unit is intended to represent 1 pixel on the game play mode screen.

    If you want text and other 2D elements on a canvas in your world space, set the canvas to world space.
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Also, the positions shown in the inspector are their parent relative positions. If they’re children of a scaled object, so too will be their transforms.
     
  4. zhutianlun810

    zhutianlun810

    Joined:
    Sep 17, 2017
    Posts:
    172
    Thank you, I have solved this problem.