Entity CreateDstEntity(UnityObject uobject, int serial) { #if DETAIL_MARKERS using (m_CreateEntity.Auto()) #endif { int flags = 0; if (AddEntityGUID) { flags |= k_EntityGUIDMask; } var go = uobject as GameObject; if (go != null) { if (ForceStaticOptimization || go.GetComponentInParent <StaticOptimizeEntity>() != null) { flags |= k_StaticMask; } if (!go.IsActiveIgnorePrefab()) { flags |= k_DisabledMask; } } else if (uobject is Component) { throw new ArgumentException("Object must be a GameObject, Prefab, or Asset", nameof(uobject)); } var entity = m_DstManager.CreateEntity(m_Archetypes[flags]); if ((flags & k_EntityGUIDMask) != 0) { m_DstManager.SetComponentData(entity, uobject.ComputeEntityGuid(m_Settings.NamespaceID, serial)); } if (m_Settings.SceneGUID != default) { int sectionIndex = 0; if (go != null) { var section = go.GetComponentInParent <SceneSectionComponent>(); if (section != null) { sectionIndex = section.SectionIndex; } } //@TODO: add an `else` that figures out what referenced this thing, because this is a dependency. // probably easiest to determine after everything has been converted by simply analyzing entity references. -joe m_DstManager.AddSharedComponentData(entity, new SceneSection { SceneGUID = m_Settings.SceneGUID, Section = sectionIndex }); } #if UNITY_EDITOR if (AssignName) { m_DstManager.SetName(entity, uobject.name); } #endif return(entity); } }