[Bug] ALINE + URP draws gizmos for inactive GameObjects

I’m using ALINE 1.6.1, Unity 2021.3 LTS, and URP.

ALINE is rendering gizmos for inactive objects - and even for objects whose scenes are not loaded (this happens when a prefab changes, triggering a re-import of scenes that contain that prefab; it looks like Unity is instantiating objects inside that scene during an import, which means they get registered with the DrawingManager and… never unregistered, which may be a Unity bug?)

The “rendering inactive gizmos” behavior seems to be caused by a small oversight in DrawingManager.DrawGizmos on line 536, in the if (usingRenderPipeline) gizmo drawing loop:

#if UNITY_2022_1_OR_NEWER
    var gizmosEnabled = mono.isActiveAndEnabled && typeToGizmosEnabled[gizmoDrawers[i].GetType()];
    var gizmosEnabled = true;  // <--- the issue?
    if (gizmosEnabled && (mono.hideFlags & HideFlags.HideInHierarchy) == 0 && !disabledDueToIsolationMode) {
        try {
        } catch (System.Exception e) {
            Debug.LogException(e, mono);

In Unity versions < 2022.1, gizmosEnabled is unconditionally set to true. If I change this line to gizmosEnabled = mono.isActiveAndEnabled, things work as expected.

Thanks for reporting this and finding the issue! I’ll release an update soon with the fix.

1 Like

Version 2021.3.5f - Same problem (URP). 5000 disabled GameObject (enemy with script (AIPATH)) - give 1ms To renderer (Profiler Unnamed_ScriptableRenderPass - ALINE - Filter destroyed object)

@Darkcrash Is it possible for you to upgrade to a newer version of Unity? From my tests, Unity seems to have significantly improved the performance of checking for destroyed objects in later versions.
Let me know how it goes.

Few minute. Create Backup, and update to latest 2021 version.

Same problem. After Update Unity to 2022 latest version! 5000 Disabled GameObject (Slow down game - Aline - Filter destroyed object ~ 1ms). Problem in script Seeker (On disabled object give 0.2ms - 0.3ms) and AIPATH (On samedisabled gameObject give 0.5 - 0,7 ms).
Disabled gameObject with script Seeker and AIPATH (draw in Render).
How fix this?


I have done some optimizations in my dev version (will be included in the next update). On my machine, having 5000 disabled objects takes about 0.8ms per frame. Improving it further requires some work, though.

The whole code that takes up time essentially looks like

for (...) {
    if (items[i].isActiveAndEnabled) {

So almost all the overhead is just calling isActiveAndEnabled on all your 5000 objects.

There is a more advanced approach I can use, but it requires some work (I’m working on it). But also, why do you need 5000 disabled objects?

In my case need only 1000 GameObject (5000 - i just testing for future). In my game on global map must be ~ 1000 Enemy (All enemy random choosing position at start, but as the game progresses, they must remember their place). All Enemies disabled (For optimization), but if hero close, than enemy activated (gameObject enable, enemy use random movement and if hero very close, than enemy attack him). Enemies have different material, mesh, characteristic.
2) Second solution - instantiate and destroy enemy in range, but I think that it will be worse in terms of performance. (More GC Alloc) and spikes. But I will need to test!

By the way, I bought this asset, because navmesh sytem (Unity) has a similar problem with objects that are turned off! 1-2 ms (even navMesh or gameObject with Navmesh disabled).


Note that this overhead is only present in the editor, not in a standalone game.