Search Unity

Question Scaling a .glb model loaded at runtime to a specific size

Discussion in 'Scripting' started by marzdh, May 29, 2023.

  1. marzdh

    marzdh

    Joined:
    Jun 3, 2013
    Posts:
    35
    Hi,

    I'm loading .glb models at runtime. The models being loaded are of different sizes. But I want them scaled to one specific size. Can someone help with this?

    The glb model when loaded has no components attached to it, however it has children with the components Mesh and Mesh Renderer.

    Regards,
    Mariam
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,742
    Steps to success will be:

    - identify a way to judge "size" of model:
    ---> difference between top-most and bottom-most vertices?
    ---> encode size information into the model itself?
    ---> something else?

    - identify how big you want it to be

    - drive the transform.localScale to an appropriate value to satisfy your needs.