Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by jpthek9 · Oct 22, 2015 at 09:46 PM · editor3ddepthgizmoshandles

Editor 3D tools with depth

Currently, something like Handles.PositionHandle has no visual indicator of depth except when the camera moves. This makes visually designing very difficult. Is it possible to make the handle interact with meshes to be semi-transparent when covered by a mesh (like collider gizmos) or change in size based on the distance from the scene camera?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Eno-Khaon · Oct 22, 2015 at 11:46 PM

After a bit of repair work done based on an ancient post by @Bunny83, I've put together a simple fixer-upper script which removes the scaling applied to the translation tool in a very basic manner.

Many further adjustments would be necessary to make it reasonably viable for use, but this is more for the proof of concept that it's not impossible to create:

 using UnityEngine;
 using System.Collections;
 using UnityEditor;
 
 [CustomEditor(typeof(GameObject))]
 public class HandleScale : Editor
 {
     void OnSceneGUI()
     {
         if(Selection.activeGameObject != null)
         {
             if(Tools.current == Tool.Move)
             {
                 Tools.hidden = true;
                 Selection.activeGameObject.transform.position = ScaledPositionHandle(Selection.activeGameObject.transform.position, Quaternion.identity, 3.0f);
             }
             else
             {
                 Tools.hidden = false;
             }
 
             if(GUI.changed)
                 EditorUtility.SetDirty(target);
         }
         else
         {
             Tools.hidden = false;
         }
     }
 
     Vector3 ScaledPositionHandle(Vector3 position, Quaternion rotation, float scale)
     {
         float handleSize = 1.0f;
         Color color = Handles.color;
         Handles.color = Handles.xAxisColor;
         position = Handles.Slider(position, rotation * Vector3.right, handleSize * scale, new Handles.DrawCapFunction(Handles.ArrowCap), Handles.SnapValue(position.x, 1f));
         position = Handles.Slider(position, rotation * Vector3.up, handleSize * scale, new Handles.DrawCapFunction(Handles.ArrowCap), Handles.SnapValue(position.y, 1f));
         Handles.color = Handles.zAxisColor;
         position = Handles.Slider(position, rotation * Vector3.forward, handleSize * scale, new Handles.DrawCapFunction(Handles.ArrowCap), Handles.SnapValue(position.z, 1f));
         Handles.color = Handles.centerColor;
         position = Handles.FreeMoveHandle(position, rotation, handleSize * scale * 0.15f, Vector3.zero, new Handles.DrawCapFunction(Handles.RectangleCap));
         Handles.color = color;
         return position;
     }
 }
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

32 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What is the best way to use the Handles class to create custom gizmos. 1 Answer

3d Line Drawing in editor with z-sorting 2 Answers

Editor Windows : Help required 1 Answer

Showing Handles in the Game View 1 Answer

Select object by selecting gizmo or handle? 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