Hi again
For the tutorial references, Wayn games has just released a video about animation in hybrid workflow : Mastering Entity Animation in Unity ECS : Hybrid Workflow Explained (youtube.com). I have not watched it, but his videos are good tutorials for ecs (The forum post you made had his old video)
Your question got my interest, particularly the idea of editor companion (seems a bit risky but I like that), so yesterday I have tried to see if making a companion gameobject in editor is feasible. I have tried to use the fact you can make a baker that targets monobehaviour colliders, to add custom component to all colliders in subscenes.
Also here is how to strip every physics components with a baking system :
[WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)]
[UpdateAfter(typeof(RigidbodyBakingSystem))]
partial struct RemovePhysicsSystem : ISystem
{
public void OnUpdate(ref SystemState state)
{
var queryCollider = SystemAPI.QueryBuilder()
.WithAll<PhysicsCollider>()
.Build();
state.EntityManager.RemoveComponent<PhysicsCollider>(queryCollider);
var queryIndex = SystemAPI.QueryBuilder()
.WithAll<PhysicsWorldIndex>()
.Build();
state.EntityManager.RemoveComponent<PhysicsWorldIndex>(queryIndex);
var queryPhysicsVelocity = SystemAPI.QueryBuilder()
.WithAll<PhysicsVelocity>()
.Build();
state.EntityManager.RemoveComponent<PhysicsVelocity>(queryPhysicsVelocity);
var queryPhysicsMass = SystemAPI.QueryBuilder()
.WithAll<PhysicsMass>()
.Build();
state.EntityManager.RemoveComponent<PhysicsMass>(queryPhysicsMass);
var queryPhysicsDamping = SystemAPI.QueryBuilder()
.WithAll<PhysicsDamping>()
.Build();
state.EntityManager.RemoveComponent<PhysicsDamping>(queryPhysicsDamping);
}
}
I then made a system to manage a companion gameobject during editor time. It mostly works, but there is one issue that I think is hard to fix :
When you close and open subscenes, the whole subscen is rebaked, and all the old data is scraped (including the sacrilegeous baking cleanupcomponent). The Instantiation system is triggered again, and the companions are spawned again, making duplicates. Because the cleanup component seems to be manually removed at scene opening, the destruction system does not trigger, and you don’t get the behavior wanted (deletion of old gameobject and instantiation of new one)
But otherwise, everything else works : When you remove the collider from a gameobject in a subscene the companion is destroyed, and when you destroy the gameobject in a subscene, the companion is also destroyed.
(There are also a few details to add, like primitives baking and movement of the companion when you move your authoring gameobjects)
I will try a few things to see if we can not get rid of the duplicate.
9749020–1395115–Systems.cs (5.44 KB)
9749020–1395118–TestBaker.cs (1.25 KB)