RadiusHandle producing really weird results when setting matrix

Hey guys

I’m trying to use the RadiusHandle and scale it to match my transform:

     /// <summary>
     ///    Draws the sphere emission shape.
     /// </summary>
     /// <param name="shape">Shape.</param>
     private void DrawSphereEmissionShape(EmissionShape shape)
     {
       Handles.matrix = castTarget.transform.localToWorldMatrix;
       shape.radius = Handles.RadiusHandle(Quaternion.identity,
        Vector3.zero,
        shape.radius);
     }

At first the result looks correct, but as I start to pan around something very strange happens:

You can see that the “outline” loop is being drawn along entirely the wrong plane.

When I move, rotate and scale my object the handle transforms accordingly, but always I get this strange result with the outline.

Is this a bug with Unity or am I doing something wrong here?

Thanks,
Ves

First glance, it appears that it’s lining it up along the wrong axes. Is the object you’re using ( I suppose castTarget) rotated in the video you posted? And does setting castTarget’s world rotation to (0,0,0) make it behave correctly?

In that video the transforms are mostly in their default state

Position x y z
Rotation 0 0 0
Scale 1 1 1

I suppose I should clarify my original code snippet is from a custom inspector script, called during OnSceneGUI. “castTarget” is simply the inspector target, cast to my MonoBehaviour class.

This issue doesn’t happen unless I set the matrix.

Had the same issue. Seems to be a bug.
I submitted a bug report.

1 Like