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
0
Question by PlutDem · Nov 10, 2014 at 06:41 PM · c#editoreditor-scriptinghandles

Is it possible to determine wich Handles.PositionHandle is currently focused?

Hello, is it possible to determine which Handles.PositionHandle is currently focused?

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 SaraCecilia · Nov 10, 2014 at 04:24 PM 0
Share

Is this thread helpful? http://forum.unity3d.com/threads/currently-selected-handle-in-editor-script.87634/

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by codebeans · Mar 09, 2015 at 09:08 PM

If you mean by axis. Try Making each of them an individual Handle Slider.

If you mean by overall Positionhandle do this:

  • Add GUI.SetNextControlName("your_unique_Identifer_for_this_handle"); before calling Handle.PostionHandle(..)

Now in the function where you evaluate those Handles and try to find the right one. check for GUI.GetNameOfFocusedControl() and do a simple switch-case

Comment
Add comment · Show 4 · 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 canis · Jun 02, 2016 at 10:51 AM 0
Share

Hi, I have same problems, however the following code not fully functional

 // Point
 GUI.SetNextControlName("Point_" + point.GetInstanceID() + "Handle1");
 Vector3 newGlobal1 =
     !free$$anonymous$$ode ?
     Handles.PositionHandle(point.globalHandle1, Quaternion.identity) :
     Handles.Free$$anonymous$$oveHandle(point.globalHandle1, point.transform.rotation, HandleUtility.GetHandleSize(point.globalHandle1) * HANDLE_SUB_SIZE, Vector3.zero, Handles.CircleCap);
 

you can visualize it only work on Free$$anonymous$$oveHandle by following checking.

 // Another editor script to script which one is selected
 void OnSceneGUI()
 {
     string hotControl = GUI.GetNameOfFocusedControl();
     if (!hotControl.StartsWith("Point_" + selectedPoint.GetInstanceID()))
     {
         for (int i = 0; i < curve.pointCount; i++) // curve contain all points.
         {
             if (hotControl.StartsWith("Point_" + curve[i].GetInstanceID()))
             {
                 selectedPoint = curve[i];
                 break;
             }
         }
     }
     
     GUILayout.Label(selectedPoint ? selectedPoint.name : "none");
 }

thru result, I also notice when user click on PositionHandle : GUI.GetNameOfFocusedControl(); // return "" GUIUtility.hotControl // return non-zero value

but click on the Free$$anonymous$$oveHandle : GUI.GetNameOfFocusedControl(); // return "Point_#1234", correct result. GUIUtility.hotControl // return non-zero value

my purpose is create a editor panel to selected GameObject during scene update. any suggestion to make it functional on PositionHandle ?

avatar image Bunny83 canis · Jun 02, 2016 at 11:30 AM 0
Share

Have you actually read the answer carefully? He suggested to not use a PositionHandle but to use 3 individual Sliders which you can give a name individually.

The PositionHandle code internally named each axis seperately:

  • "xAxis"

  • "yAxis"

  • "zAxis"

  • "Free$$anonymous$$oveAxis"

So it's not possible to give each axis for each of your points a unique name if you use a PositionHandle.

Each slider inside a PositionHandle has it's own controlID. However they are creating their IDs automatically with GUIUtility.GetControlID(Handles.s_SliderHash, FocusType.$$anonymous$$eyboard);. The static field s_SliderHash is literally just "SliderHash".GetHashCode();.

IDs are usually handed out in sequence, so by manually generating a control ID with the same hash before the actual PositionHandle, you should be able to predict the ID for the next control. You then just have to check GUIUtility.keyboardControl to deter$$anonymous$$e which control is focused.

avatar image canis Bunny83 · Jun 04, 2016 at 04:22 PM 0
Share

thanks, and sorry, I haven't describe my problem correctly, I dont mean to find which axis. I only need to identify the positionHandle's gameObject. but your answer make me think some more about the controlID.

how to identify the controlID's owner? I mean if I use it to move another gameObject.

currenty my project is writing an bezier curve, each Curve have unlimited point. in scene view the developer able to move all the point within that curve. thats why I need to know which point are focus.

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

6 People are following this question.

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

Related Questions

Bind to OnWillSaveAssets and force to save my scene 0 Answers

Change the color/size of a position handle 0 Answers

object field decides when it wants to work,Why does my list clear itself 0 Answers

How to create persistent handles in Editor Scene View? 1 Answer

Using Handles.DrawAAPolyLine 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