Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Problems with Object Scaling in AR

Discussion in 'AR/VR (XR) Discussion' started by Jon-at-Kaio, Jan 12, 2018.

  1. Jon-at-Kaio

    Jon-at-Kaio

    Joined:
    Oct 17, 2007
    Posts:
    185
    Hi there
    When running in the editor we're setting up our object and code to size a cube to fit between our UI.
    Works fine when not running AR either on device or via the AR Remote solution. i.e. the cube stays the right size.
    Once we connect to the test device (iOS for the moment) we're seeing the cube distort (seemingly increase in size) it seems to be happening (thanks to being able to iterate & test using the remote) when we hit this code

    m_camera.projectionMatrix = m_session.GetCameraProjection ();

    in the Update Method of UnityArCameraManager.cs

    Any ideas on how we can get consistency between the editor in edit mode & running without AR connected, and running it with AR Remote / on device ?
     
  2. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    793
    How about making the editor window the same resolution as your device screen?
     
  3. Jon-at-Kaio

    Jon-at-Kaio

    Joined:
    Oct 17, 2007
    Posts:
    185
    Hey there @jimmya I messaged you about this particular problem earlier this week, and yes we have done the basic trouble shooting. thus why we've narrowed it down to that update method, we comment that line out and the cube stays the same size it is in the editor only version, remove the comment and it pops to being bigger.

    I suspect its slightly trickier than a basic beginner problem.
     
  4. Jon-at-Kaio

    Jon-at-Kaio

    Joined:
    Oct 17, 2007
    Posts:
    185
  5. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    793
    The problem is that your in editor camera does not have the same properties as the camera on your device. That is where the camera projection matrix comes from (the FOV of the device camera, intrinsics and the resolution).

    We get the camera projection matrix from ARKit https://developer.apple.com/documentation/arkit/arcamera/2923539-projectionmatrix

    Also, you should be careful about trying to make your UI so dependent on the camera FOV since that will change per device, as well as may not be future-proof.
     
  6. Jon-at-Kaio

    Jon-at-Kaio

    Joined:
    Oct 17, 2007
    Posts:
    185
    "Also, you should be careful about trying to make your UI so dependent on the camera FOV since that will change per device, as well as may not be future-proof."

    Which was why I wanted to make sure we had the right approach, Our UI works fine around the edge of the screen the problem we're seeing is primarily with a 3d model we use as a Raycast target and acting as a 'canvas/grid overlay' for our current approach to 'drawing' our objects on screen/inspace.