Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Noob question about Handles! i mean, Many questions!

Discussion in 'Editor & General Support' started by resetme, Jun 7, 2015.

  1. resetme

    resetme

    Joined:
    Jun 27, 2012
    Posts:
    197
    Hi again! im advancing with my project really fast thanks to this forum!

    so.. my question now is about Handles.

    I want to create multiple handles, and move it with the mouse in the editor window. also, all handles should have some properties (number, type, etc.)

    My first question is how to create those handles. (Way point style project)
    -I need a script that extend Editor, that script should be linked to a GameObject in the hierarchy view, right? Is there a way to have only the script and nothing in my hierarchy?

    -For every handle i make, do i need to create a game object to assign the handles to that object? as i said before i would like to have a clean hierarchy. And as it is a way point project, i may have 20 way point.

    -Can i create some kind of number or textfield in the bottom of the handles to show in the scene editor?


    I have created some gizmos before, but for every gizmo i need to create an empty game object and i didn't like it. ...

    this is my idea!

    As always, Appreciate any help!


    edited my awful english...
     
    Last edited: Jun 7, 2015
  2. Myhijim

    Myhijim

    Joined:
    Jun 15, 2012
    Posts:
    1,148
    If you decide to go with the gameobject creation way, after creating a waypoint it is possible to hide the object in the hierarchy with :

    Code (CSharp):
    1. gameObject.hideFlags = HideFlags.HideInHeirarchy
    For every gameObject/Waypoint you make.

    As for the label, you can always use the
    Code (CSharp):
    1. Handles.Label(position, text/image);
    You will also want to do the updating in the OnDrawGizmos() method.

    As for deciding which handle is currently being used, I found that a little more tricky, and drew from this example :
    http://answers.unity3d.com/questions/463207/how-do-you-make-a-custom-handle-respond-to-the-mou.html

    Hope this helps
    - Myhi
     
  3. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,228
    You can have multiple handles and type on one game object. But I do believe that you are going to have at least one gameobject on screen as the handles are part of onscenegui. Unlike gizmos, handles are typically drawn when the object is active, where gizmos are drawn all the time. And unlike gizmos, handles can be manipulated individually where gizmos are just a visual. For example, I have path (waypoint) editor using handles where are all the points are simply stored in a Vector3[], so there is just the main gameobject with the script, but not several empty gameobjects for reference, just the the array in the script.

    So you could do something like that, have you "Path" gameobject that has your script and it will handle all the nodes and handles and text. Text/labels are drawn with handles as well, Lable() for simple text, or Begin/EndGUI for more complex ones.
     
    Myhijim likes this.
  4. resetme

    resetme

    Joined:
    Jun 27, 2012
    Posts:
    197
    thank you guys so much, and i'm truly sorry for my awful english.

    now that i have seen the light, i will start to coding it!
     
  5. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    828
unityunity