private static Entity CreateEntity(EntityArchetype archetype, string name, Guid parentGuid = default)
        {
            var session       = Application.AuthoringProject.Session;
            var worldManager  = session.GetManager <IWorldManager>();
            var entityManager = worldManager.EntityManager;
            var sceneManager  = session.GetManager <IEditorSceneManagerInternal>();

            var parent       = worldManager.GetEntityFromGuid(parentGuid);
            var parentExists = parent != Entity.Null && entityManager.Exists(parent);
            var scene        = !parentExists?sceneManager.GetActiveScene() : sceneManager.GetScene(parent);

            Assert.AreNotEqual(scene, Scene.Null);

            var graph      = sceneManager.GetGraphForScene(scene);
            var uniqueName = EntityNameHelper.GetUniqueEntityName(name, worldManager, parentExists ? graph.FindNode(parent)?.Children : graph.Roots);

            var entity = worldManager.CreateEntity(uniqueName, archetype);

            scene.AddEntityReference(entityManager, entity);

            if (parentExists)
            {
                if (entityManager.HasComponent <Parent>(entity))
                {
                    entityManager.SetComponentData(entity, new Parent {
                        Value = parent
                    });
                }
                else
                {
                    entityManager.AddComponentData(entity, new Parent {
                        Value = parent
                    });
                }
            }

            SetComponentDefaultValue <NonUniformScale>(entity);
            SetComponentDefaultValue <SiblingIndex>(entity);

            EntityHierarchyWindow.SelectOnNextPaint(worldManager.GetEntityGuid(entity).AsEnumerable().ToList());
            return(entity);
        }