Is it possible to access entity from main scene?

Hello, I am pretty new to ECS, so I hope my question is not too stupid :smile:.

I have a game that I want to switch partially over to ECS. But most probably not the whole game.
So for example I want to make the positions of some objects be calculated by ECS but there are other Gameobjects that need these positions.

Lets say I have a star system with planets. Therse planets now use the ECS system within their own subscene.
I also have some buildings on these planets that have old monobehaviour objects that are hardly connected to other Gameobjects that I dont want/cant move to the subscene.

So is it possible to somehow connect the buildings to the planets so that they still move with them?

You can access entities anywhere in the project.
Scripts and DOTS systems are not bound to the Sub-Subscenes.
Entities don’t work like GameObjects.

That sounds great! Is there some example how I can do that?
I mean I tried to do that with the foreach loop but it says it must be in a ISystem.

So far most if not all examples on yt or so are very isolated and only teach how things inside the subscene are handled. I havent seen one where the connection between the main scene and subscene are shown.

@Pascal81 try:

var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity e = entityManager.CreateEntity();

Thank you! But can you maybe give me a little more hint? I tested it and in β€œe”-> World β†’ AllSystems now I have some entities. But each type is only one time in the array while in my test I have 3 times the object in game. I would need to get all 3 individual entities with their properties.

Edit: I guess entityManager.GetAllEntities() does the trick.

I suggest you look into Unity DOTS samples. Learn basics from them.
There is plenty examples, to get what you may need.