Skip to content

Commit

Permalink
* EcsWorldUnityEditorSystem: Optional "bakeComponentsInName" ctor par…
Browse files Browse the repository at this point in the history
…ameter added.
  • Loading branch information
Leopotam committed Jun 20, 2021
1 parent 4017fb3 commit 7d71c4c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Runtime/EcsWorldUnityEditorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ public sealed class EcsWorldUnityEditorSystem : IEcsPreInitSystem, IEcsRunSystem
readonly string _worldName;
readonly GameObject _rootGO;
readonly Transform _entitiesRoot;
readonly bool _bakeComponentsInName;
EcsWorld _world;
EcsEntityObserver[] _entities;
Dictionary<int, byte> _dirtyEntities;
Type[] _typesCache;

public EcsWorldUnityEditorSystem (string worldName = null) {
public EcsWorldUnityEditorSystem (string worldName = null, bool bakeComponentsInName = true) {
_bakeComponentsInName = bakeComponentsInName;
_worldName = worldName;
_rootGO = new GameObject (_worldName != null ? $"[ECS-WORLD {_worldName}]" : "[ECS-WORLD]");
Object.DontDestroyOnLoad (_rootGO);
Expand Down Expand Up @@ -61,17 +63,25 @@ public void OnEntityCreated (int entity) {
entityObserver.Entity = entity;
entityObserver.World = _world;
_entities[entity] = entityObserver;
_dirtyEntities[entity] = 1;
if (_bakeComponentsInName) {
_dirtyEntities[entity] = 1;
} else {
go.name = entity.ToString ("X8");
}
}
_entities[entity].gameObject.SetActive (true);
}

public void OnEntityDestroyed (int entity) {
_entities[entity].gameObject.SetActive (false);
if (_entities[entity]) {
_entities[entity].gameObject.SetActive (false);
}
}

public void OnEntityChanged (int entity) {
_dirtyEntities[entity] = 1;
if (_bakeComponentsInName) {
_dirtyEntities[entity] = 1;
}
}

public void OnFilterCreated (EcsFilter filter) { }
Expand Down

0 comments on commit 7d71c4c

Please sign in to comment.