You've successfully subscribed to Nicholas Workshop
Great! Next, complete checkout for full access to Nicholas Workshop
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.

Rotate Gizmos To Fit A Game Object In Unity

Nicholas Wong
Nicholas Wong

While you are making a cube in unity which is transparent in gameplay, you would probably want to make it visible only in editor mode with gizmos. However, gizmos doesn’t rotate with the object transform. So you can use the following tricks to rotate the gizmos to fit your object. The code shown is to draw a cube which is totally the same as your object. By setting up the matrix of gizmos, we can transform gizmos to the local position, scale and rotation.

Gizmos.color = Color.green;  
Gizmos.matrix = transform.localToWorldMatrix;  
Gizmos.DrawWireCube(Vector3.zero,Vector3.one);  
Unsorted

Nicholas Wong

Fullstack software engineer with strong background in computer science and extensive experience in software engineering and architecture. Studied in NYU, worked in Yahoo, Rakuten and Manulife.