As we all know that the standard cube in unity is 1m * 1m * 1m and it is also the same size in XR. But it is too big .I want to set the unit of measurement for example the 1m1m1m cube in unity shows like 1dm * 1dm *1dm.You may saiy that use the scale, but many of my scripts define some data like speed, attack range will mass.So it there any way to set such unit?
Set the inverted scale for the whole AR Game (this will not affect the physics and transforms of gameplay objects — only AR scale):
public void SetARScaleInverted(float scale = 2f)
{
xrOrigin.transform.localScale = Vector3.one * scale;
}
I tryied but didn’t work.The objects are at the same world scale, only the AR Planes scaled and can’t match the real plane.
Before settings the scale, you can position your game in AR using this script and MakeContentAppearAt()
method that is added to xrOrigin
method list.
So I position GameWorldParent
object in my AR templates and then scale xrOrigin
as mentioned above:
Many systems in Unity, most notably Physics, assume that Unity’s unit of measurement is in meters. I would recommend that you measure your project in meters and use scripts to convert to decimeters for your code if you want?
This is excatly what I am doing, I wrote a piece of code to scale all the relevant parameters.But if we can define the unit of measurement in AR mode, we can easily use some AI assets on Lego-sized characters.