void ApplyChangeSet(EntityChangeSetSerialization.ResourcePacket resourcePacket) { var changeSet = LiveLinkChangeSet.Deserialize(resourcePacket, LiveLinkPlayerAssetRefreshSystem.GlobalAssetObjectResolver); m_Patcher.ApplyPatch(changeSet); changeSet.Dispose(); }
public void ApplyPatch(LiveLinkChangeSet changeSet) { var dstEntities = _DstWorld.EntityManager; var sceneSystem = _DstWorld.GetExistingSystem<SceneSystem>(); Entity sectionEntity; var sceneEntity = sceneSystem.GetSceneEntity(changeSet.SceneGUID); //@TODO: Check if the scene or section is requested to be loaded if (sceneEntity == Entity.Null) { Debug.LogWarning($"'{changeSet.SceneName}' ({{changeSet.sceneGUID}}) was ignored in live link since it is not loaded."); return; } // Unload scene if (changeSet.UnloadAllPreviousEntities) { //@Todo: Can we try to keep scene & section entities alive? (In case user put custom data on it) sceneSystem.UnloadScene(sceneEntity, SceneSystem.UnloadParameters.DestroySectionProxyEntities | SceneSystem.UnloadParameters.DontRemoveRequestSceneLoaded); // Create section sectionEntity = dstEntities.CreateEntity(); dstEntities.AddComponentData(sectionEntity, new SceneSectionStreamingSystem.StreamingState { Status = SceneSectionStreamingSystem.StreamingStatus.Loaded}); dstEntities.AddComponentData(sectionEntity, new DisableSceneResolveAndLoad( )); // Configure scene dstEntities.AddComponentData(sceneEntity, new DisableSceneResolveAndLoad( )); dstEntities.AddComponentData(sceneEntity, new LiveLinkedSceneState { Scene = changeSet.SceneGUID }); dstEntities.AddBuffer<ResolvedSectionEntity>(sceneEntity).Add(new ResolvedSectionEntity { SectionEntity = sectionEntity} ); #if UNITY_EDITOR dstEntities.SetName(sectionEntity, "SceneSection (LiveLink): " + changeSet.SceneName); dstEntities.SetName(sceneEntity, "Scene (LiveLink): " + changeSet.SceneName); #endif } else { sectionEntity = dstEntities.GetBuffer<ResolvedSectionEntity>(sceneEntity)[0].SectionEntity; } // SceneTag.SceneEntity == Entity.Null is reserved for new entities added via live link. if (_AddedScenesQuery.CalculateChunkCount() != 0) { Debug.LogWarning("SceneTag.SceneEntity must not reference Entity.Null. Destroying Entities."); dstEntities.DestroyEntity(_AddedScenesQuery); } EntityPatcher.ApplyChangeSet(_DstWorld.EntityManager, changeSet.Changes); //liveLink.ConvertedShadowWorld.EntityManager.Debug.CheckInternalConsistency(); dstEntities.SetSharedComponentData(_AddedScenesQuery, new SceneTag { SceneEntity = sectionEntity }); EditorUpdateUtility.EditModeQueuePlayerLoopUpdate(); }