Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by NZRoadKill · Jun 11, 2010 at 06:11 PM · editormatrixgizmohandlesonscenegui

Handles.matrix seems strange?

Can anyone shed some light on how to use the Handles.matrix to draw gizmos properly? I was trying to draw a rotation handle that is 0.5 times the size of the normal rotation handle in the SceneView. In OnSceneGUI I tried the following:

Handles.matrix = Handle.matrix * Matrix4x4.Scale(Vector3(0.5,0.5,0.5));
Handles.RotationHandle(.....

But this seems to make the rotation gizmo larger in my view, rather than 0.5 times the size of the normal gizmo?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image yoyo · Jan 05, 2011 at 12:01 AM 0
Share

On a related note, is it possible to use Handles.matrix to resize text, like you can with GUI.matrix?

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Bunny83 · Jun 14, 2011 at 12:37 PM

The matrix only affects the position and rotation of the handle, not the size. Normally you can specify the size that you calculated with HandleUtility.GetHandleSize but the PositionHandle does that internally.

Here's the (internal) implementation of PositionHandle ( thanks ILSpy ;) )

 public static Vector3 PositionHandle(Vector3 position, Quaternion rotation)
 {
     float handleSize = HandleUtility.GetHandleSize(position);
     Color color = Handles.color;
     Handles.color = Handles.xAxisColor;
     position = Handles.Slider(position, rotation * Vector3.right, handleSize, new Handles.DrawCapFunction(Handles.ArrowCap), SnapSettings.move.x);
     Handles.color = Handles.yAxisColor;
     position = Handles.Slider(position, rotation * Vector3.up, handleSize, new Handles.DrawCapFunction(Handles.ArrowCap), SnapSettings.move.y);
     Handles.color = Handles.zAxisColor;
     position = Handles.Slider(position, rotation * Vector3.forward, handleSize, new Handles.DrawCapFunction(Handles.ArrowCap), SnapSettings.move.z);
     Handles.color = Handles.centerColor;
     position = Handles.FreeMoveHandle(position, rotation, handleSize * 0.15f, SnapSettings.move, new Handles.DrawCapFunction(Handles.RectangleCap));
     Handles.color = color;
     return position;
 }
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hardwire · Jun 14, 2011 at 12:43 PM 0
Share

Have you got the RotationHandle as well?

avatar image Bunny83 · Jun 30, 2011 at 11:51 AM 0
Share

Sorry, i just went through some of my emails (350+ only from UnityAnswers).

     public static Quaternion RotationHandle(Quaternion rotation, Vector3 position)
     {
         float handleSize = HandleUtility.GetHandleSize(position);
         Color color = Handles.color;
         Handles.color = Handles.xAxisColor;
         rotation = Handles.Disc(rotation, position, rotation * Vector3.right, handleSize, true, SnapSettings.rotation);
         Handles.color = Handles.yAxisColor;
         rotation = Handles.Disc(rotation, position, rotation * Vector3.up, handleSize, true, SnapSettings.rotation);
         Handles.color = Handles.zAxisColor;
         rotation = Handles.Disc(rotation, position, rotation * Vector3.forward, handleSize, true, SnapSettings.rotation);
         Handles.color = Handles.centerColor;
         rotation = Handles.Disc(rotation, position, Camera.current.transform.forward, handleSize * 1.1f, false, 0f);
         rotation = Handles.FreeRotateHandle(rotation, position, handleSize);
         Handles.color = color;
         return rotation;
     }
avatar image
0

Answer by hardwire · Jun 14, 2011 at 12:13 PM

In my experience changing the matrix doesn't have any effect for many functions (inluding RotationHandle()) and it also bugged some other functions for me, so I stopped using it. Now I draw my own handles and transform everything manually before passing it into Handles' functions.

But it might be quite difficult to do the full rotation handle. In my case I was happy with a simple one using Handles.Disc() together with Handles.DrawLine(), so it might work for you as well.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

How to disable the default transform gizmo in editor? 1 Answer

Editor: calling event.use() prevents gizmos from being drawn 1 Answer

Keep multiple custom handles visible in the Scene view 0 Answers

How to read the current PivotRotation or PivotMode ? 1 Answer

Permanent handles (when object is not selected) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges