Search Unity

Using Gizmo Class

Discussion in 'Scripting' started by Jonathan Czeck, Jul 11, 2005.

  1. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    I'm trying to draw gizmos for my pathfinding nodes. I made an icon and stuck it in the Resources folder of the Unity app bundle. It seems like I'm not supposed to draw gizmos from regular objects, only Camera objects.

    Gizmos.DrawIcon(transform.position, "Node Gizmo.tiff");

    This generate exceptions that m_CurrentCamera or something isn't assigned when this is stuck in my Node game objects. I've only gotten it to work in a script attached to my main camera calling it from OnPostRender(). Which doesn't seem like the thing to do, either, as it just draws a nasty white square.

    "Node Gizmo.tiff" or "Node Gizmo" don't seem to make a difference. Which one should I be using?

    Help is very appreciated.

    Cheers,
    -Jon
     

    Attached Files:

  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    You are only supposed to call the gizmo functions when inside the DrawGizmos:
    function DrawGizmos ()
    {
    Gizmos.DrawIcon(transform.position, "Node Gizmo.tiff");
    }

    Sorry. This should be much clearer in the documentation and should give you saner errors when you call them from somewhere else.

    You have to give the complete name of the image: Node Gizmo.tiff
     
  3. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    Ah, jeez. That's easy. Just a little note in the Gizmos class pointing to the place in MonoBehavior or something would be enough of a hint for me.

    They only seem to get drawn if the object is selected. Is that expected behavior?

    Cheers,
    -Jon
     
  4. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Oh yeah. Doh. Never looked into Gizmos drawing much after Gooball.

    There should really be a function to let users display them in both cases.

    Please file a bug on the documentation and the not always displaying.