Skip to content

Commit

Permalink
Disabled DrawGizmosEditor when objects are hidden in het SceneVisibil…
Browse files Browse the repository at this point in the history
…ityManager
  • Loading branch information
jeffreylanters committed May 9, 2023
1 parent 7d1690e commit 6aff5f4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Runtime/Controller.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif

namespace ElRaccoone.EntityComponentSystem {
/// <summary>
Expand Down Expand Up @@ -134,7 +137,13 @@ void OnDrawGizmos () {
// interface.
var monoBehaviours = FindObjectsOfType<MonoBehaviour> ();
var entities = monoBehaviours.OfType<IEntityComponent> ();
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.
Expand Down

0 comments on commit 6aff5f4

Please sign in to comment.