Search Unity

Issue adding entities package to 2019.3.0a10

Discussion in 'Data Oriented Technology Stack' started by manarito, Jul 24, 2019.

  1. manarito

    manarito

    Joined:
    Nov 17, 2016
    Posts:
    5
    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:


    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)
     
  2. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    364
    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.
     
    Timboc likes this.
  3. rizu

    rizu

    Joined:
    Oct 8, 2013
    Posts:
    1,228
    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.
     
  4. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    364
    Any changes I make get overwritten when I restart unity. Have you copied the packages to your project folder or something?
     
  5. rizu

    rizu

    Joined:
    Oct 8, 2013
    Posts:
    1,228
    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.
     
  6. Akhilya

    Akhilya

    Joined:
    Sep 4, 2017
    Posts:
    3
    To fix these 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


    Just replace default SubSceneLiveLinkSystem.cs code by this :

    Code (CSharp):
    1.  using System;
    2. using System.Collections.Generic;
    3. using System.Reflection;
    4. using Unity.Entities;
    5. using UnityEngine;
    6. using UnityEngine.SceneManagement;
    7. using UnityEngine.Rendering;
    8. using UnityEditor;
    9. using UnityEditor.SceneManagement;
    10. using UnityEngine.Experimental.Rendering;
    11. using Object = UnityEngine.Object;
    12.  
    13. namespace Unity.Scenes.Editor
    14. {
    15.     [ExecuteAlways, UpdateInGroup(typeof(InitializationSystemGroup)), UpdateBefore(typeof(SubSceneStreamingSystem))]
    16.     class SubSceneLiveLinkSystem : ComponentSystem
    17.     {
    18.         class GameObjectPrefabLiveLinkSceneTracker : AssetPostprocessor
    19.         {
    20.             static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    21.             {
    22.                 foreach (var asset in importedAssets)
    23.                 {
    24.                     if (asset.EndsWith(".prefab", true, System.Globalization.CultureInfo.InvariantCulture))
    25.                         GlobalDirtyLiveLink();
    26.                 }
    27.             }
    28.         }
    29.  
    30.         static int GlobalDirtyID = 0;
    31.         static int PreviousGlobalDirtyID = 0;
    32.         MethodInfo m_GetDirtyIDMethod = typeof(Scene).GetProperty("dirtyID", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).GetMethod;
    33.  
    34.         UInt64 m_LiveLinkEditSceneViewMask = 1UL << 60;
    35.         UInt64 m_LiveLinkEditGameViewMask = 1UL << 58;
    36.         HashSet<SceneAsset> m_EditingSceneAssets = new HashSet<SceneAsset>();
    37.  
    38.         static void AddUnique(ref List<SubScene> list, SubScene scene)
    39.         {
    40.             if (list == null)
    41.                 list = new List<SubScene>(10);
    42.             if (!list.Contains(scene))
    43.                 list.Add(scene);
    44.         }
    45.  
    46.         protected override void OnUpdate()
    47.         {
    48.             List<SubScene> needLiveLinkSync = null;
    49.             List<SubScene> cleanupScene = null;
    50.             List<SubScene> markSceneLoadedFromLiveLink = null;
    51.             List<SubScene> removeSceneLoadedFromLiveLink = null;
    52.             m_EditingSceneAssets.Clear();
    53.  
    54.             var liveLinkEnabled = SubSceneInspectorUtility.LiveLinkEnabled;
    55.  
    56.             for (int i = 0; i != EditorSceneManager.sceneCount; i++)
    57.             {
    58.                 var scene = EditorSceneManager.GetSceneAt(i);
    59.                 if (scene.isSubScene)
    60.                 {
    61.                     if (liveLinkEnabled)
    62.                         EditorSceneManager.SetSceneCullingMask(scene, m_LiveLinkEditSceneViewMask);
    63.                     else
    64.                         EditorSceneManager.SetSceneCullingMask(scene, EditorSceneManager.DefaultSceneCullingMask | m_LiveLinkEditGameViewMask);
    65.  
    66.                     var sceneAsset = AssetDatabase.LoadAssetAtPath<SceneAsset>(scene.path);
    67.                     if (scene.isLoaded && sceneAsset != null)
    68.                         m_EditingSceneAssets.Add(sceneAsset);
    69.                 }
    70.             }
    71.  
    72.             if (PreviousGlobalDirtyID != GlobalDirtyID)
    73.             {
    74.                 Entities.ForEach((SubScene subScene) =>
    75.                 {
    76.                     subScene.LiveLinkDirtyID = -1;
    77.                 });
    78.                 PreviousGlobalDirtyID = GlobalDirtyID;
    79.             }
    80.  
    81.             Entities.ForEach((SubScene subScene) =>
    82.             {
    83.                 var isLoaded = m_EditingSceneAssets.Contains(subScene.SceneAsset);
    84.                 if (isLoaded && liveLinkEnabled)
    85.                 {
    86.                     if (subScene.LiveLinkDirtyID != GetSceneDirtyID(subScene.LoadedScene) || subScene.LiveLinkShadowWorld == null)
    87.                         AddUnique(ref needLiveLinkSync, subScene);
    88.                 }
    89.                 else if (isLoaded && !liveLinkEnabled)
    90.                 {
    91.                     var hasAnythingLoaded = false;
    92.                     foreach (var s in subScene._SceneEntities)
    93.                         hasAnythingLoaded |= EntityManager.HasComponent<SubSceneStreamingSystem.StreamingState>(s) || !EntityManager.HasComponent<SubSceneStreamingSystem.IgnoreTag>(s);
    94.  
    95.                     if (hasAnythingLoaded)
    96.                     {
    97.                         AddUnique(ref cleanupScene, subScene);
    98.                         AddUnique(ref markSceneLoadedFromLiveLink, subScene);
    99.                     }
    100.                 }
    101.                 else
    102.                 {
    103.                     var isDrivenByLiveLink = false;
    104.                     foreach (var s in subScene._SceneEntities)
    105.                         isDrivenByLiveLink |= EntityManager.HasComponent<SubSceneStreamingSystem.IgnoreTag>(s);
    106.  
    107.                     if (isDrivenByLiveLink || subScene.LiveLinkShadowWorld != null)
    108.                     {
    109.                         AddUnique(ref cleanupScene, subScene);
    110.                         AddUnique(ref removeSceneLoadedFromLiveLink, subScene);
    111.                     }
    112.                 }
    113.             });
    114.  
    115.             if (needLiveLinkSync != null)
    116.             {
    117.                 foreach (var scene in needLiveLinkSync)
    118.                 {
    119.                     if (!IsHotControlActive())
    120.                         ApplyLiveLink(scene);
    121.                     else
    122.                         EditorUpdateUtility.EditModeQueuePlayerLoopUpdate();
    123.                 }
    124.             }
    125.  
    126.  
    127.             if (cleanupScene != null)
    128.             {
    129.                 foreach (var scene in cleanupScene)
    130.                 {
    131.                     CleanupScene(scene);
    132.                 }
    133.             }
    134.  
    135.             if (markSceneLoadedFromLiveLink != null)
    136.             {
    137.                 foreach (var scene in markSceneLoadedFromLiveLink)
    138.                 {
    139.                     foreach (var sceneEntity in scene._SceneEntities)
    140.                     {
    141.                         if (!EntityManager.HasComponent<SubSceneStreamingSystem.IgnoreTag>(sceneEntity))
    142.                             EntityManager.AddComponentData(sceneEntity, new SubSceneStreamingSystem.IgnoreTag());
    143.                     }
    144.                 }
    145.             }
    146.  
    147.             if (removeSceneLoadedFromLiveLink != null)
    148.             {
    149.                 foreach (var scene in removeSceneLoadedFromLiveLink)
    150.                 {
    151.                     foreach (var sceneEntity in scene._SceneEntities)
    152.                     {
    153.                         EntityManager.RemoveComponent<SubSceneStreamingSystem.IgnoreTag>(sceneEntity);
    154.                     }
    155.                 }
    156.             }
    157.  
    158.         }
    159.  
    160.         void CleanupScene(SubScene scene)
    161.         {
    162.             scene.CleanupLiveLink();
    163.  
    164.             var streamingSystem = World.GetExistingSystem<SubSceneStreamingSystem>();
    165.  
    166.             foreach (var sceneEntity in scene._SceneEntities)
    167.             {
    168.                 streamingSystem.UnloadSceneImmediate(sceneEntity);
    169.                 EntityManager.DestroyEntity(sceneEntity);
    170.             }
    171.             scene._SceneEntities = new List<Entity>();
    172.  
    173.             scene.UpdateSceneEntities();
    174.         }
    175.  
    176.         void ApplyLiveLink(SubScene scene)
    177.         {
    178.             var streamingSystem = World.GetExistingSystem<SubSceneStreamingSystem>();
    179.  
    180.             var isFirstTime = scene.LiveLinkShadowWorld == null;
    181.             if (scene.LiveLinkShadowWorld == null)
    182.                 scene.LiveLinkShadowWorld = new World("LiveLink");
    183.  
    184.  
    185.             using (var cleanConvertedEntityWorld = new World("Clean Entity Conversion World"))
    186.             {
    187.                 if (isFirstTime)
    188.                 {
    189.                     foreach (var s in scene._SceneEntities)
    190.                     {
    191.                         streamingSystem.UnloadSceneImmediate(s);
    192.                         EntityManager.DestroyEntity(s);
    193.                     }
    194.  
    195.                     var sceneEntity = EntityManager.CreateEntity();
    196.                     EntityManager.SetName(sceneEntity, "Scene (LiveLink): " + scene.SceneName);
    197.                     EntityManager.AddComponentObject(sceneEntity, scene);
    198.                     EntityManager.AddComponentData(sceneEntity, new SubSceneStreamingSystem.StreamingState { Status = SubSceneStreamingSystem.StreamingStatus.Loaded});
    199.                     EntityManager.AddComponentData(sceneEntity, new SubSceneStreamingSystem.IgnoreTag( ));
    200.  
    201.                     scene._SceneEntities = new List<Entity>();
    202.                     scene._SceneEntities.Add(sceneEntity);
    203.                 }
    204.  
    205.                 GameObjectConversionUtility.ConvertScene(scene.LoadedScene, scene.SceneGUID, cleanConvertedEntityWorld, GameObjectConversionUtility.ConversionFlags.AddEntityGUID | GameObjectConversionUtility.ConversionFlags.AssignName);
    206.  
    207.                 var convertedEntityManager = cleanConvertedEntityWorld.EntityManager;
    208.  
    209.                 var liveLinkSceneEntity = scene._SceneEntities[0];
    210.  
    211.                 convertedEntityManager.AddSharedComponentData(convertedEntityManager.UniversalQuery, new SceneTag { SceneEntity = liveLinkSceneEntity });
    212.  
    213.                 WorldDiffer.DiffAndApply(cleanConvertedEntityWorld, scene.LiveLinkShadowWorld, World);
    214.  
    215.                 convertedEntityManager.Debug.CheckInternalConsistency();
    216.                 scene.LiveLinkShadowWorld.EntityManager.Debug.CheckInternalConsistency();
    217.  
    218.                 var group = EntityManager.CreateEntityQuery(typeof(SceneTag), ComponentType.Exclude<EditorRenderData>());
    219.                 group.SetFilter(new SceneTag {SceneEntity = liveLinkSceneEntity});
    220.  
    221.                 EntityManager.AddSharedComponentData(group, new EditorRenderData() { SceneCullingMask = m_LiveLinkEditGameViewMask, PickableObject = scene.gameObject });
    222.  
    223.                 group.Dispose();
    224.  
    225.                 scene.LiveLinkDirtyID = GetSceneDirtyID(scene.LoadedScene);
    226.                 EditorUpdateUtility.EditModeQueuePlayerLoopUpdate();
    227.             }
    228.         }
    229.  
    230.  
    231.         static GameObject GetGameObjectFromAny(Object target)
    232.         {
    233.             Component component = target as Component;
    234.             if (component != null)
    235.                 return component.gameObject;
    236.             return target as GameObject;
    237.         }
    238.  
    239.         internal static bool IsHotControlActive()
    240.         {
    241.             return GUIUtility.hotControl != 0;
    242.         }
    243.  
    244.  
    245.         UndoPropertyModification[] PostprocessModifications(UndoPropertyModification[] modifications)
    246.         {
    247.             foreach (var mod in modifications)
    248.             {
    249.                 var target = GetGameObjectFromAny(mod.currentValue.target);
    250.                 if (target)
    251.                 {
    252.                     var targetScene = target.scene;
    253.                     Entities.ForEach((SubScene scene) =>
    254.                     {
    255.                         if (scene.IsLoaded && scene.LoadedScene == targetScene)
    256.                         {
    257.                             scene.LiveLinkDirtyID = -1;
    258.                         }
    259.                     });
    260.                 }
    261.             }
    262.  
    263.             return modifications;
    264.         }
    265.  
    266.         int GetSceneDirtyID(Scene scene)
    267.         {
    268.             if (scene.IsValid())
    269.             {
    270.                 return (int)m_GetDirtyIDMethod.Invoke(scene, null);
    271.             }
    272.             else
    273.                 return -1;
    274.         }
    275.  
    276.         static void GlobalDirtyLiveLink()
    277.         {
    278.             GlobalDirtyID++;
    279.         }
    280.  
    281.         protected override void OnCreate()
    282.         {
    283.             Undo.postprocessModifications += PostprocessModifications;
    284.             Undo.undoRedoPerformed += GlobalDirtyLiveLink;
    285.  
    286.             Camera.onPreCull += OnPreCull;
    287.             RenderPipelineManager.beginCameraRendering += OnPreCull;
    288.         }
    289.  
    290.         void OnPreCull(ScriptableRenderContext context, Camera camera) => OnPreCull(camera);
    291.         void OnPreCull(Camera camera)
    292.         {
    293.             if (camera.cameraType == CameraType.Game)
    294.             {
    295.                 camera.overrideSceneCullingMask = EditorSceneManager.DefaultSceneCullingMask | m_LiveLinkEditGameViewMask;
    296.             }
    297.             else if (camera.cameraType == CameraType.SceneView)
    298.             {
    299.                 if (camera.scene.IsValid())
    300.                 {
    301.                     camera.overrideSceneCullingMask = 0;
    302.                 }
    303.                 else
    304.                 {
    305.                     camera.overrideSceneCullingMask = EditorSceneManager.DefaultSceneCullingMask | m_LiveLinkEditSceneViewMask;
    306.                 }
    307.             }
    308.  
    309.         }
    310.  
    311.         protected override void OnDestroy()
    312.         {
    313.             Undo.postprocessModifications -= PostprocessModifications;
    314.             Undo.undoRedoPerformed -= GlobalDirtyLiveLink;
    315.  
    316.             Camera.onPreCull -= OnPreCull;
    317.             RenderPipelineManager.beginCameraRendering -= OnPreCull;
    318.         }
    319.     }
    320. }
     
    Last edited: Jul 30, 2019