Hi,
On a new project, when I try to import the entities package in 2019.0.3a10 in a minimal configuration I get the following errors:
Library\PackageCache\com.unity.entities@0.0.12-preview.33\Unity.Scenes.Editor\SubSceneLiveLinkSystem.cs(306,13): error CS0103: The name ‘RenderPipeline’ does not exist in the current context
Library\PackageCache\com.unity.entities@0.0.12-preview.33\Unity.Scenes.Editor\SubSceneLiveLinkSystem.cs(338,13): error CS0103: The name ‘RenderPipeline’ does not exist in the current context
I tried to add the Core RP package even though it isn’t listed as a dependency but it didn’t help. (Also Collections is installed although it doesn’t seem to display in the package manager)
In 2019.2.0b10 the same packages on a new project do not give me an error:
Did anyone encounter this? Is there anything I’m missing here?
The reason I had to use the alpha is because I wanted to test the visual scripting component, which needs 2019.3 (Note that I’m aware the drop shouldn’t work as-is for versions over alpha 5)
Yes, I did too, and one other I spoke to on the discord server. I have a feeling we just need to wait for a new entities/hybrid release to be able to use alpha 10, but if I’m wrong and someone gets packages to play nice, I’m interested also.
1 Like
I had to edit entities and hybrid packages a bit to get them running on 2019.3.0a10, Unity will probably add ifdefs for these eventually.
Any changes I make get overwritten when I restart unity. Have you copied the packages to your project folder or something?
You need to have the modified packages somewhere outside of the default packagecache for modifications to stick, common place is to have the package on your projects Packages folder as things placed there will be automatically picked up by Unity. There used to be a “Develop” button on older 2019.3 alphas package managers that moved the package to Packages for you but it appears to be gone in a10 now.
system
July 29, 2019, 9:42am
6
To fix these errors :
Library\PackageCache\com.unity.entities@0.0.12-preview.33\Unity.Scenes.Editor\SubSceneLiveLinkSystem.cs(338,13): error CS0103: The name 'RenderPipeline' does not exist in the current context```
Just replace default SubSceneLiveLinkSystem.cs code by this :
```csharp
using System;
using System.Collections.Generic;
using System.Reflection;
using Unity.Entities;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Rendering;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine.Experimental.Rendering;
using Object = UnityEngine.Object;
namespace Unity.Scenes.Editor
{
[ExecuteAlways, UpdateInGroup(typeof(InitializationSystemGroup)), UpdateBefore(typeof(SubSceneStreamingSystem))]
class SubSceneLiveLinkSystem : ComponentSystem
{
class GameObjectPrefabLiveLinkSceneTracker : AssetPostprocessor
{
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
foreach (var asset in importedAssets)
{
if (asset.EndsWith(".prefab", true, System.Globalization.CultureInfo.InvariantCulture))
GlobalDirtyLiveLink();
}
}
}
static int GlobalDirtyID = 0;
static int PreviousGlobalDirtyID = 0;
MethodInfo m_GetDirtyIDMethod = typeof(Scene).GetProperty("dirtyID", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).GetMethod;
UInt64 m_LiveLinkEditSceneViewMask = 1UL << 60;
UInt64 m_LiveLinkEditGameViewMask = 1UL << 58;
HashSet<SceneAsset> m_EditingSceneAssets = new HashSet<SceneAsset>();
static void AddUnique(ref List<SubScene> list, SubScene scene)
{
if (list == null)
list = new List<SubScene>(10);
if (!list.Contains(scene))
list.Add(scene);
}
protected override void OnUpdate()
{
List<SubScene> needLiveLinkSync = null;
List<SubScene> cleanupScene = null;
List<SubScene> markSceneLoadedFromLiveLink = null;
List<SubScene> removeSceneLoadedFromLiveLink = null;
m_EditingSceneAssets.Clear();
var liveLinkEnabled = SubSceneInspectorUtility.LiveLinkEnabled;
for (int i = 0; i != EditorSceneManager.sceneCount; i++)
{
var scene = EditorSceneManager.GetSceneAt(i);
if (scene.isSubScene)
{
if (liveLinkEnabled)
EditorSceneManager.SetSceneCullingMask(scene, m_LiveLinkEditSceneViewMask);
else
EditorSceneManager.SetSceneCullingMask(scene, EditorSceneManager.DefaultSceneCullingMask | m_LiveLinkEditGameViewMask);
var sceneAsset = AssetDatabase.LoadAssetAtPath<SceneAsset>(scene.path);
if (scene.isLoaded && sceneAsset != null)
m_EditingSceneAssets.Add(sceneAsset);
}
}
if (PreviousGlobalDirtyID != GlobalDirtyID)
{
Entities.ForEach((SubScene subScene) =>
{
subScene.LiveLinkDirtyID = -1;
});
PreviousGlobalDirtyID = GlobalDirtyID;
}
Entities.ForEach((SubScene subScene) =>
{
var isLoaded = m_EditingSceneAssets.Contains(subScene.SceneAsset);
if (isLoaded && liveLinkEnabled)
{
if (subScene.LiveLinkDirtyID != GetSceneDirtyID(subScene.LoadedScene) || subScene.LiveLinkShadowWorld == null)
AddUnique(ref needLiveLinkSync, subScene);
}
else if (isLoaded && !liveLinkEnabled)
{
var hasAnythingLoaded = false;
foreach (var s in subScene._SceneEntities)
hasAnythingLoaded |= EntityManager.HasComponent<SubSceneStreamingSystem.StreamingState>(s) || !EntityManager.HasComponent<SubSceneStreamingSystem.IgnoreTag>(s);
if (hasAnythingLoaded)
{
AddUnique(ref cleanupScene, subScene);
AddUnique(ref markSceneLoadedFromLiveLink, subScene);
}
}
else
{
var isDrivenByLiveLink = false;
foreach (var s in subScene._SceneEntities)
isDrivenByLiveLink |= EntityManager.HasComponent<SubSceneStreamingSystem.IgnoreTag>(s);
if (isDrivenByLiveLink || subScene.LiveLinkShadowWorld != null)
{
AddUnique(ref cleanupScene, subScene);
AddUnique(ref removeSceneLoadedFromLiveLink, subScene);
}
}
});
if (needLiveLinkSync != null)
{
foreach (var scene in needLiveLinkSync)
{
if (!IsHotControlActive())
ApplyLiveLink(scene);
else
EditorUpdateUtility.EditModeQueuePlayerLoopUpdate();
}
}
if (cleanupScene != null)
{
foreach (var scene in cleanupScene)
{
CleanupScene(scene);
}
}
if (markSceneLoadedFromLiveLink != null)
{
foreach (var scene in markSceneLoadedFromLiveLink)
{
foreach (var sceneEntity in scene._SceneEntities)
{
if (!EntityManager.HasComponent<SubSceneStreamingSystem.IgnoreTag>(sceneEntity))
EntityManager.AddComponentData(sceneEntity, new SubSceneStreamingSystem.IgnoreTag());
}
}
}
if (removeSceneLoadedFromLiveLink != null)
{
foreach (var scene in removeSceneLoadedFromLiveLink)
{
foreach (var sceneEntity in scene._SceneEntities)
{
EntityManager.RemoveComponent<SubSceneStreamingSystem.IgnoreTag>(sceneEntity);
}
}
}
}
void CleanupScene(SubScene scene)
{
scene.CleanupLiveLink();
var streamingSystem = World.GetExistingSystem<SubSceneStreamingSystem>();
foreach (var sceneEntity in scene._SceneEntities)
{
streamingSystem.UnloadSceneImmediate(sceneEntity);
EntityManager.DestroyEntity(sceneEntity);
}
scene._SceneEntities = new List<Entity>();
scene.UpdateSceneEntities();
}
void ApplyLiveLink(SubScene scene)
{
var streamingSystem = World.GetExistingSystem<SubSceneStreamingSystem>();
var isFirstTime = scene.LiveLinkShadowWorld == null;
if (scene.LiveLinkShadowWorld == null)
scene.LiveLinkShadowWorld = new World("LiveLink");
using (var cleanConvertedEntityWorld = new World("Clean Entity Conversion World"))
{
if (isFirstTime)
{
foreach (var s in scene._SceneEntities)
{
streamingSystem.UnloadSceneImmediate(s);
EntityManager.DestroyEntity(s);
}
var sceneEntity = EntityManager.CreateEntity();
EntityManager.SetName(sceneEntity, "Scene (LiveLink): " + scene.SceneName);
EntityManager.AddComponentObject(sceneEntity, scene);
EntityManager.AddComponentData(sceneEntity, new SubSceneStreamingSystem.StreamingState { Status = SubSceneStreamingSystem.StreamingStatus.Loaded});
EntityManager.AddComponentData(sceneEntity, new SubSceneStreamingSystem.IgnoreTag( ));
scene._SceneEntities = new List<Entity>();
scene._SceneEntities.Add(sceneEntity);
}
GameObjectConversionUtility.ConvertScene(scene.LoadedScene, scene.SceneGUID, cleanConvertedEntityWorld, GameObjectConversionUtility.ConversionFlags.AddEntityGUID | GameObjectConversionUtility.ConversionFlags.AssignName);
var convertedEntityManager = cleanConvertedEntityWorld.EntityManager;
var liveLinkSceneEntity = scene._SceneEntities[0];
convertedEntityManager.AddSharedComponentData(convertedEntityManager.UniversalQuery, new SceneTag { SceneEntity = liveLinkSceneEntity });
WorldDiffer.DiffAndApply(cleanConvertedEntityWorld, scene.LiveLinkShadowWorld, World);
convertedEntityManager.Debug.CheckInternalConsistency();
scene.LiveLinkShadowWorld.EntityManager.Debug.CheckInternalConsistency();
var group = EntityManager.CreateEntityQuery(typeof(SceneTag), ComponentType.Exclude<EditorRenderData>());
group.SetFilter(new SceneTag {SceneEntity = liveLinkSceneEntity});
EntityManager.AddSharedComponentData(group, new EditorRenderData() { SceneCullingMask = m_LiveLinkEditGameViewMask, PickableObject = scene.gameObject });
group.Dispose();
scene.LiveLinkDirtyID = GetSceneDirtyID(scene.LoadedScene);
EditorUpdateUtility.EditModeQueuePlayerLoopUpdate();
}
}
static GameObject GetGameObjectFromAny(Object target)
{
Component component = target as Component;
if (component != null)
return component.gameObject;
return target as GameObject;
}
internal static bool IsHotControlActive()
{
return GUIUtility.hotControl != 0;
}
UndoPropertyModification[] PostprocessModifications(UndoPropertyModification[] modifications)
{
foreach (var mod in modifications)
{
var target = GetGameObjectFromAny(mod.currentValue.target);
if (target)
{
var targetScene = target.scene;
Entities.ForEach((SubScene scene) =>
{
if (scene.IsLoaded && scene.LoadedScene == targetScene)
{
scene.LiveLinkDirtyID = -1;
}
});
}
}
return modifications;
}
int GetSceneDirtyID(Scene scene)
{
if (scene.IsValid())
{
return (int)m_GetDirtyIDMethod.Invoke(scene, null);
}
else
return -1;
}
static void GlobalDirtyLiveLink()
{
GlobalDirtyID++;
}
protected override void OnCreate()
{
Undo.postprocessModifications += PostprocessModifications;
Undo.undoRedoPerformed += GlobalDirtyLiveLink;
Camera.onPreCull += OnPreCull;
RenderPipelineManager.beginCameraRendering += OnPreCull;
}
void OnPreCull(ScriptableRenderContext context, Camera camera) => OnPreCull(camera);
void OnPreCull(Camera camera)
{
if (camera.cameraType == CameraType.Game)
{
camera.overrideSceneCullingMask = EditorSceneManager.DefaultSceneCullingMask | m_LiveLinkEditGameViewMask;
}
else if (camera.cameraType == CameraType.SceneView)
{
if (camera.scene.IsValid())
{
camera.overrideSceneCullingMask = 0;
}
else
{
camera.overrideSceneCullingMask = EditorSceneManager.DefaultSceneCullingMask | m_LiveLinkEditSceneViewMask;
}
}
}
protected override void OnDestroy()
{
Undo.postprocessModifications -= PostprocessModifications;
Undo.undoRedoPerformed -= GlobalDirtyLiveLink;
Camera.onPreCull -= OnPreCull;
RenderPipelineManager.beginCameraRendering -= OnPreCull;
}
}
}
1 Like
To fix these errors :
Library\PackageCache\com.unity.entities@0.0.12-preview.33\Unity.Scenes.Editor\SubSceneLiveLinkSystem.cs(338,13): error CS0103: The name 'RenderPipeline' does not exist in the current context```
Just replace default SubSceneLiveLinkSystem.cs code by this :
```csharp
using System;
using System.Collections.Generic;
using System.Reflection;
using Unity.Entities;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Rendering;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine.Experimental.Rendering;
using Object = UnityEngine.Object;
namespace Unity.Scenes.Editor
{
[ExecuteAlways, UpdateInGroup(typeof(InitializationSystemGroup)), UpdateBefore(typeof(SubSceneStreamingSystem))]
class SubSceneLiveLinkSystem : ComponentSystem
{
class GameObjectPrefabLiveLinkSceneTracker : AssetPostprocessor
{
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
foreach (var asset in importedAssets)
{
if (asset.EndsWith(".prefab", true, System.Globalization.CultureInfo.InvariantCulture))
GlobalDirtyLiveLink();
}
}
}
static int GlobalDirtyID = 0;
static int PreviousGlobalDirtyID = 0;
MethodInfo m_GetDirtyIDMethod = typeof(Scene).GetProperty("dirtyID", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).GetMethod;
UInt64 m_LiveLinkEditSceneViewMask = 1UL << 60;
UInt64 m_LiveLinkEditGameViewMask = 1UL << 58;
HashSet<SceneAsset> m_EditingSceneAssets = new HashSet<SceneAsset>();
static void AddUnique(ref List<SubScene> list, SubScene scene)
{
if (list == null)
list = new List<SubScene>(10);
if (!list.Contains(scene))
list.Add(scene);
}
protected override void OnUpdate()
{
List<SubScene> needLiveLinkSync = null;
List<SubScene> cleanupScene = null;
List<SubScene> markSceneLoadedFromLiveLink = null;
List<SubScene> removeSceneLoadedFromLiveLink = null;
m_EditingSceneAssets.Clear();
var liveLinkEnabled = SubSceneInspectorUtility.LiveLinkEnabled;
for (int i = 0; i != EditorSceneManager.sceneCount; i++)
{
var scene = EditorSceneManager.GetSceneAt(i);
if (scene.isSubScene)
{
if (liveLinkEnabled)
EditorSceneManager.SetSceneCullingMask(scene, m_LiveLinkEditSceneViewMask);
else
EditorSceneManager.SetSceneCullingMask(scene, EditorSceneManager.DefaultSceneCullingMask | m_LiveLinkEditGameViewMask);
var sceneAsset = AssetDatabase.LoadAssetAtPath<SceneAsset>(scene.path);
if (scene.isLoaded && sceneAsset != null)
m_EditingSceneAssets.Add(sceneAsset);
}
}
if (PreviousGlobalDirtyID != GlobalDirtyID)
{
Entities.ForEach((SubScene subScene) =>
{
subScene.LiveLinkDirtyID = -1;
});
PreviousGlobalDirtyID = GlobalDirtyID;
}
Entities.ForEach((SubScene subScene) =>
{
var isLoaded = m_EditingSceneAssets.Contains(subScene.SceneAsset);
if (isLoaded && liveLinkEnabled)
{
if (subScene.LiveLinkDirtyID != GetSceneDirtyID(subScene.LoadedScene) || subScene.LiveLinkShadowWorld == null)
AddUnique(ref needLiveLinkSync, subScene);
}
else if (isLoaded && !liveLinkEnabled)
{
var hasAnythingLoaded = false;
foreach (var s in subScene._SceneEntities)
hasAnythingLoaded |= EntityManager.HasComponent<SubSceneStreamingSystem.StreamingState>(s) || !EntityManager.HasComponent<SubSceneStreamingSystem.IgnoreTag>(s);
if (hasAnythingLoaded)
{
AddUnique(ref cleanupScene, subScene);
AddUnique(ref markSceneLoadedFromLiveLink, subScene);
}
}
else
{
var isDrivenByLiveLink = false;
foreach (var s in subScene._SceneEntities)
isDrivenByLiveLink |= EntityManager.HasComponent<SubSceneStreamingSystem.IgnoreTag>(s);
if (isDrivenByLiveLink || subScene.LiveLinkShadowWorld != null)
{
AddUnique(ref cleanupScene, subScene);
AddUnique(ref removeSceneLoadedFromLiveLink, subScene);
}
}
});
if (needLiveLinkSync != null)
{
foreach (var scene in needLiveLinkSync)
{
if (!IsHotControlActive())
ApplyLiveLink(scene);
else
EditorUpdateUtility.EditModeQueuePlayerLoopUpdate();
}
}
if (cleanupScene != null)
{
foreach (var scene in cleanupScene)
{
CleanupScene(scene);
}
}
if (markSceneLoadedFromLiveLink != null)
{
foreach (var scene in markSceneLoadedFromLiveLink)
{
foreach (var sceneEntity in scene._SceneEntities)
{
if (!EntityManager.HasComponent<SubSceneStreamingSystem.IgnoreTag>(sceneEntity))
EntityManager.AddComponentData(sceneEntity, new SubSceneStreamingSystem.IgnoreTag());
}
}
}
if (removeSceneLoadedFromLiveLink != null)
{
foreach (var scene in removeSceneLoadedFromLiveLink)
{
foreach (var sceneEntity in scene._SceneEntities)
{
EntityManager.RemoveComponent<SubSceneStreamingSystem.IgnoreTag>(sceneEntity);
}
}
}
}
void CleanupScene(SubScene scene)
{
scene.CleanupLiveLink();
var streamingSystem = World.GetExistingSystem<SubSceneStreamingSystem>();
foreach (var sceneEntity in scene._SceneEntities)
{
streamingSystem.UnloadSceneImmediate(sceneEntity);
EntityManager.DestroyEntity(sceneEntity);
}
scene._SceneEntities = new List<Entity>();
scene.UpdateSceneEntities();
}
void ApplyLiveLink(SubScene scene)
{
var streamingSystem = World.GetExistingSystem<SubSceneStreamingSystem>();
var isFirstTime = scene.LiveLinkShadowWorld == null;
if (scene.LiveLinkShadowWorld == null)
scene.LiveLinkShadowWorld = new World("LiveLink");
using (var cleanConvertedEntityWorld = new World("Clean Entity Conversion World"))
{
if (isFirstTime)
{
foreach (var s in scene._SceneEntities)
{
streamingSystem.UnloadSceneImmediate(s);
EntityManager.DestroyEntity(s);
}
var sceneEntity = EntityManager.CreateEntity();
EntityManager.SetName(sceneEntity, "Scene (LiveLink): " + scene.SceneName);
EntityManager.AddComponentObject(sceneEntity, scene);
EntityManager.AddComponentData(sceneEntity, new SubSceneStreamingSystem.StreamingState { Status = SubSceneStreamingSystem.StreamingStatus.Loaded});
EntityManager.AddComponentData(sceneEntity, new SubSceneStreamingSystem.IgnoreTag( ));
scene._SceneEntities = new List<Entity>();
scene._SceneEntities.Add(sceneEntity);
}
GameObjectConversionUtility.ConvertScene(scene.LoadedScene, scene.SceneGUID, cleanConvertedEntityWorld, GameObjectConversionUtility.ConversionFlags.AddEntityGUID | GameObjectConversionUtility.ConversionFlags.AssignName);
var convertedEntityManager = cleanConvertedEntityWorld.EntityManager;
var liveLinkSceneEntity = scene._SceneEntities[0];
convertedEntityManager.AddSharedComponentData(convertedEntityManager.UniversalQuery, new SceneTag { SceneEntity = liveLinkSceneEntity });
WorldDiffer.DiffAndApply(cleanConvertedEntityWorld, scene.LiveLinkShadowWorld, World);
convertedEntityManager.Debug.CheckInternalConsistency();
scene.LiveLinkShadowWorld.EntityManager.Debug.CheckInternalConsistency();
var group = EntityManager.CreateEntityQuery(typeof(SceneTag), ComponentType.Exclude<EditorRenderData>());
group.SetFilter(new SceneTag {SceneEntity = liveLinkSceneEntity});
EntityManager.AddSharedComponentData(group, new EditorRenderData() { SceneCullingMask = m_LiveLinkEditGameViewMask, PickableObject = scene.gameObject });
group.Dispose();
scene.LiveLinkDirtyID = GetSceneDirtyID(scene.LoadedScene);
EditorUpdateUtility.EditModeQueuePlayerLoopUpdate();
}
}
static GameObject GetGameObjectFromAny(Object target)
{
Component component = target as Component;
if (component != null)
return component.gameObject;
return target as GameObject;
}
internal static bool IsHotControlActive()
{
return GUIUtility.hotControl != 0;
}
UndoPropertyModification[] PostprocessModifications(UndoPropertyModification[] modifications)
{
foreach (var mod in modifications)
{
var target = GetGameObjectFromAny(mod.currentValue.target);
if (target)
{
var targetScene = target.scene;
Entities.ForEach((SubScene scene) =>
{
if (scene.IsLoaded && scene.LoadedScene == targetScene)
{
scene.LiveLinkDirtyID = -1;
}
});
}
}
return modifications;
}
int GetSceneDirtyID(Scene scene)
{
if (scene.IsValid())
{
return (int)m_GetDirtyIDMethod.Invoke(scene, null);
}
else
return -1;
}
static void GlobalDirtyLiveLink()
{
GlobalDirtyID++;
}
protected override void OnCreate()
{
Undo.postprocessModifications += PostprocessModifications;
Undo.undoRedoPerformed += GlobalDirtyLiveLink;
Camera.onPreCull += OnPreCull;
RenderPipelineManager.beginCameraRendering += OnPreCull;
}
void OnPreCull(ScriptableRenderContext context, Camera camera) => OnPreCull(camera);
void OnPreCull(Camera camera)
{
if (camera.cameraType == CameraType.Game)
{
camera.overrideSceneCullingMask = EditorSceneManager.DefaultSceneCullingMask | m_LiveLinkEditGameViewMask;
}
else if (camera.cameraType == CameraType.SceneView)
{
if (camera.scene.IsValid())
{
camera.overrideSceneCullingMask = 0;
}
else
{
camera.overrideSceneCullingMask = EditorSceneManager.DefaultSceneCullingMask | m_LiveLinkEditSceneViewMask;
}
}
}
protected override void OnDestroy()
{
Undo.postprocessModifications -= PostprocessModifications;
Undo.undoRedoPerformed -= GlobalDirtyLiveLink;
Camera.onPreCull -= OnPreCull;
RenderPipelineManager.beginCameraRendering -= OnPreCull;
}
}
}
Can you tell me where I do that editing? I’m pouring over the folders of Unity and my package, and I can’t for the life of me figure out where I can find and edit SubSceneLiveLinkSystem.cs