Skip to content

Commit 079c282

Browse files
Added editor time gizmos for controllers
1 parent 17feaa0 commit 079c282

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Runtime/Controller.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.Linq;
23
using UnityEngine;
34

45
namespace ElRaccoone.EntityComponentSystem {
@@ -126,8 +127,14 @@ void OnDestroy () {
126127
/// </summary>
127128
void OnDrawGizmos () {
128129
if (!Application.isPlaying) {
129-
// When the application is not playing, the GUI will not be drawn since
130-
// the controller is not initialized at this stage.
130+
// When the application is not playing, the Gizmos will not be drawn
131+
// since the controller is not initialized at this stage, so no systems
132+
// or services are available. Instead, the Gizmos will be drawn on all
133+
// MonoBehaviour components that implement the IEntityComponent
134+
// interface.
135+
var monoBehaviours = FindObjectsOfType<MonoBehaviour> ();
136+
var entities = monoBehaviours.OfType<IEntityComponent> ();
137+
OnDrawEditorGizmos (entities.ToArray ());
131138
return;
132139
}
133140
// Invoking draw gizmos method on each system and service.
@@ -178,6 +185,11 @@ public virtual void OnUpdate () { }
178185
/// </summary>
179186
public virtual void OnWillDestroy () { }
180187

188+
/// <summary>
189+
/// Method invoked during editor time when the controller is drawing gizmos.
190+
/// </summary>
191+
public virtual void OnDrawEditorGizmos (IEntityComponent[] entities) { }
192+
181193
/// <summary>
182194
/// Register your systems and services to the controller. This can only be
183195
/// done during 'OnInitialize' cycle.

0 commit comments

Comments
 (0)