From 6aff5f444e3cd3776f23bcab8aad3822e82faa40 Mon Sep 17 00:00:00 2001 From: Jeffrey Lanters Date: Tue, 9 May 2023 13:02:15 +0200 Subject: [PATCH] Disabled DrawGizmosEditor when objects are hidden in het SceneVisibilityManager --- Runtime/Controller.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Runtime/Controller.cs b/Runtime/Controller.cs index 957b594..a97d749 100644 --- a/Runtime/Controller.cs +++ b/Runtime/Controller.cs @@ -1,6 +1,9 @@ using System.Collections.Generic; using System.Linq; using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif namespace ElRaccoone.EntityComponentSystem { /// @@ -134,7 +137,13 @@ void OnDrawGizmos () { // interface. var monoBehaviours = FindObjectsOfType (); var entities = monoBehaviours.OfType (); - OnDrawEditorGizmos (entities.ToArray ()); + var visibleEntities = entities.Where (entity => { + var monoBehaviour = entity as MonoBehaviour; + return monoBehaviour.enabled + && monoBehaviour.gameObject.activeInHierarchy + && !SceneVisibilityManager.instance.IsHidden (monoBehaviour.gameObject); + }); + OnDrawEditorGizmos (visibleEntities.ToArray ()); return; } // Invoking draw gizmos method on each system and service.