Search Unity

Feature Request Culling distance for gizmos in editor

Discussion in 'Editor & General Support' started by Hellwaiker, Aug 3, 2021.

  1. Hellwaiker

    Hellwaiker

    Joined:
    Jan 8, 2016
    Posts:
    118
    I want to be able to set a radius distance from the camera, and every gizmo and editor helper beyond that radius to stop rendering.
     
  2. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    I don't think a radius settings is feasible, but just general purpose frustum culling would do wonders for performance if Unity would find a solution to implement it.

    We had a couple of projects where Gizmos are important level design tools because they can be clicked for fast selection, so we wanted them to always render, but at any given time hundreds or thousands of these calls would make the editor very slow. We manually implemented frustum culling so it would only render the two or three Gizmos on screen and it fixed our issues, but of course it would be much better if this was built in, especially since I can't think of any reason why Gizmos should be rendered if not visible.

    However, with Gizmos it might be difficult to implement culling that's not itself a performance bottleneck. Sometimes drawing is quite fast, so culling might be slower in 80% of the use cases where there are not that many Gizmos.

    One of the main issues will be to define when a Gizmos is visible. If it's a sphere, you can define a Bounding Sphere, if it's a mesh, you can calculate the Bounding Box, but if it's a series of lines, the bounding volume calculation might be as slow as simply drawing the thing. Our custom code chose to just make some assumptions, e.g. we only used a single point of origin for each Gizmos, so it could happen that the Gizmos didn't draw because they were partially off screen, etc.
     
  3. hotCODEhot

    hotCODEhot

    Joined:
    Sep 14, 2017
    Posts:
    2
    I second this feature request!

    I've got a scene which has tons of gizmos going off into the distance and I want to be able to see the one's which I'm close to but turn off the ones in the distance.

    Sure you can turn on 3D icons so that the ones in the distance get drawn smaller but I'd rather be able to set the size to be independent of my distance from it and just have gizmos outside of a desired range not draw.
     
    JLifeDev likes this.
  4. Kathlar

    Kathlar

    Joined:
    Nov 7, 2017
    Posts:
    6
    We need this!
     
  5. JLifeDev

    JLifeDev

    Joined:
    Feb 8, 2016
    Posts:
    12
    @Xarbrough
    Yeah, Implementing Gizmos culling is difficult some by some case.
    I love too Visualize-Debuggig & Making Scene Tool. So use lot of Gizmos in my game Too.

    so recommand solve tools for you. it's just my experience.

    - [a line] [shapes] solve a lot immediate gui drawing performance.
    * A line support burst compile

    - If you have A* Pathfinding Project Pro, [a line] already included below AstarPathfindingProject/Drawing)

    - If you are univer version 2023 higher You can try Gizmos.DrawLines Api.
    - (Article) Unity new gizmos drwaing api

    Sad : These assets are very expensive.

    But also think unity require improving gizmos performance at the same level as [a line] / [shapes] and support matrix/color scope assignable api like Shapes/ALine
     
    Last edited: Apr 24, 2023
  6. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,433
    There's options to disable gizmos for each behaviour class. You can also have it auto-hide gizmos for any component you "fold up" in the Inspector.

    And if you're implementing OnDrawGizmos in your own scripts, consider changing them to OnDrawGizmosSelected once you're basically happy with the functionality. That will cut down the clutter a lot.
     
    JLifeDev likes this.