uimgui icon indicating copy to clipboard operation
uimgui copied to clipboard

[QUESTION] I figured out how to draw Gizmo from ImGuizmo, but they distorted.

Open RidgyTheFox opened this issue 3 years ago • 1 comments

Well, as the title says, I figured out how to draw it all, but for some reason it doesn't display correctly. I'm not very good at matrices and I have no idea how to fix it at all.

I`m using Unity 2021.1.17f1 with Built-in render pipeline. Package version 4.1.1 (Last at the moment.)

https://youtu.be/yEWYUFGb97w

private void OnLayout(UImGui.UImGui obj) { ImGuizmo.BeginFrame(); ImGuizmo.SetRect(0, 0, Screen.height, Screen.width);

Matrix4x4 matrix = _objectInScene.transform.localToWorldMatrix;
Matrix4x4 view = _currentCamera.worldToCameraMatrix;
Matrix4x4 projection = _currentCamera.projectionMatrix;

ImGuizmo.Manipulate(ref view.m00, ref projection.m00, OPERATION.TRANSLATE, MODE.WORLD, ref matrix.m00);
ImGuizmo.DrawGrid(ref view.m00, ref projection.m00, ref matrix.m00, 50f);

}

RidgyTheFox avatar Aug 23 '22 09:08 RidgyTheFox

Seems like Screen.height and Screen.width should switch places in your SetRect call. You may also want to add a SetOrthographic call depending on your camera settings.

Also, I don't think you need to call BeginFrame yourself, UImGui should be doing that for you.

Zguy avatar Sep 20 '22 21:09 Zguy

There's a new version that look fix it using the comment above. I'm closing this issue. Re-open if you need

psydack avatar Mar 20 '24 18:03 psydack