Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 MasterLetch · Feb 17, 2013 at 07:54 PM · cameraeditorscenehandles

Drawing Handles

I have been trying to draw handles for the past 2 days with very little success, not sure which portion of what I am doing is wrong.

I don't want to use gizmos (as they require a monobehaviour that doesn't really fit what I'm doing)

here is a snippet of code

 public class AdaptivePathEditor : EditorWindow {
 
 public void Update () {
         Handles.DrawCamera(new Rect(0,0,500,500),Camera.current);
         Handles.PositionHandle(Vector3.zero,Quaternion.identity);
     }
 }

I would also like a object that can be created and dragged into a an editor window but that probably requires inheriting from scriptable object which is another thing entirely.

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
6
Best Answer

Answer by numberkruncher · Feb 17, 2013 at 08:02 PM

Use OnSceneGUI of custom editor for handles

I believe that you need to use the OnSceneGUI message handler of a custom Editor for this:

 [CustomEditor(typeof(YourMonoBehaviour))]
 public class AdaptivePathEditor : Editor {
     void OnSceneGUI() {
         Handles.DrawCamera(new Rect(0,0,500,500), Camera.current);
         Handles.PositionHandle(Vector3.zero, Quaternion.identity);
     }
 }

For more information please see: http://docs.unity3d.com/Documentation/ScriptReference/Editor.html

Otherwise you may need to consider using the Graphics and/or GL class instead. Though I am not sure how you would "inject" that into a scene view without a custom editor or gizmos.

Define a static gizmo function

Another alternative would be to draw gizmos from your editor window:

 public class YourEditorWindow : EditorWindow {

     static YourEditorWindow window;

     [DrawGizmo(GizmoType.NotSelected)]
     static void RenderCustomGizmo(Transform objectTransform, GizmoType gizmoType) {
         if (window == null)
             return;

         // Draw gizmos...
     }

     // Maintain static reference to window
     void OnEnable() {
         window = this;
     }
     void OnDisable() {
         window = null;
     }

     void OnGUI() {
     }

 }

For further information please see:

  • http://docs.unity3d.com/Documentation/ScriptReference/DrawGizmo.html

  • http://docs.unity3d.com/Documentation/ScriptReference/DrawGizmo.DrawGizmo.html

Comment
Add comment · Show 9 · 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 MasterLetch · Feb 17, 2013 at 08:34 PM 0
Share

not sure that would work, its funny i just need a "ball" or "node" to pop up without a zsort so i can see it through things aswell as line drawer.

Update(); happens 100 times a second from everywindow, so enless editor.handles refuses to run there. then i think it should work

avatar image numberkruncher · Feb 17, 2013 at 08:41 PM 0
Share

I believe that handles need to be presented using OnSceneGUI because they respond to GUI events which do not occur when processing Update messages. It is normal to associate custom control IDs to handles which can then be used to handle things like mouse interaction (drag & drop for example). Handles are generally interactive GUI elements.

avatar image numberkruncher · Feb 17, 2013 at 08:42 PM 0
Share

There is an undocumented OnPreSceneGUI message handler, so perhaps there is an undocumented OnPostSceneGUI message handler. I am not saying that there is, but might be worth experimenting to find out. This would presumably draw your handles on top of everything else.

avatar image MasterLetch · Feb 17, 2013 at 08:59 PM 0
Share

that would work wonders, only if i could get handles actually drawing from EditorWindow, which i don't fully understand why its so difficult

avatar image numberkruncher · Feb 17, 2013 at 09:19 PM 0
Share

EditorWindow's are not designed to present things within other scene view windows. They are independent viewports, however they can actually draw gizmos.

Show more comments

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

10 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

Related Questions

On can I have OnBecameVisible/Invisible ignore the scene/editor camera and only work for the game camera ? 6 Answers

Unity Scene View's right-click + WASD doesn't look 3D anymore? 2 Answers

Changing master view move speed. 3 Answers

Drawing handles in multiple camera's 0 Answers

How can I make a custom 3d editor within the Unity editor? 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