Search Unity

Gizmos and Handles

Discussion in 'Scripting' started by MaT227, Oct 7, 2016.

  1. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
  2. RChrispy

    RChrispy

    Joined:
    Dec 18, 2013
    Posts:
    71
    Could you post your OnDrawGizmos code, and the collider settings? This might help to find a solution.
     
  3. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    @Dev6_RC Thanks for the answer.
    Concerning the sphere collider, it's just the basic Unity sphere primitive with the renderer deactivated and a radius of 1.0.
    Nothing special concerning the Gizmos or Handles code but here they are.
    Code (CSharp):
    1. // Monobehaviour script
    2. void OnDrawGizmos()
    3. {
    4.     Gizmos.DrawWireSphere(transform.position, 1.0f);
    5. }
    6.  
    7. // Editor script
    8. private void OnSceneGUI()
    9. {
    10.     Handles.RadiusHandle(Quaternion.identity, myobject.transform.position, 1.0f, false);
    11. }
     
  4. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    Anybody ?
    Maybe someone from Unity can tell me how they are doing this.
    Seems that they only use the Handles for the control point but not for the sphere shape, but how do they get the circle always facing the camera and being affected by occluders.
     
  5. RChrispy

    RChrispy

    Joined:
    Dec 18, 2013
    Posts:
    71
    Hey @MaT227 ,
    sorry for my late reply but I tested your problem in an empty scene. Seems like the gizmo is exactly as the collider but the collider has a Circle around the edges of the gizmo. This circle billboards forwards the camera.

    You could look into this code and write your own Gizmo Logic (With billboard circle) example here:
    https://www.assetstore.unity3d.com/en/#!/content/11396

    This should be exactly what you are looking for. :)
     
  6. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    Thanks for the answer @Dev6_RC !
    I thought about creating that billboard circle by hand and it's seems that's the best solution for the moment.
    Thanks for the link ! :)
     
  7. RChrispy

    RChrispy

    Joined:
    Dec 18, 2013
    Posts:
    71
    If you have your own gizmo code. I would like to see, I am kind of interested. :)
     
  8. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628