Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Compilation of Issues with 0.50

Discussion in 'Entity Component System' started by tertle, Mar 17, 2022.

  1. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    -edit- 2022-04-29 a bunch of these have been fixed in 0.50.1
    https://forum.unity.com/threads/compilation-of-issues-with-0-50.1253973/#post-8088752

    Just spent 8 hours upgrading personal libraries and work project (still in progress) and going to publicly document issues here to save you all the effort

    1. EntityQuery.GetSingleton<T> is busted

    -edit- i was informed by unity the issue is on multi component singletons only

    Sometimes returns wrong value (not always not sure what repo is.)

    Code (CSharp):
    1. _query = GetEntityQuery(ComponentType.ReadOnly<LocalPlayer>(), ComponentType.ReadOnly<Translation>());
    2. var translation = _query.GetSingleton<Translation>();
    To
    Code (CSharp):
    1. var translation = _query.ToComponentDataArray<Translation>(Allocator.Temp)[0];
    * Though this isn't safe, you might need a Complete()

    Looking at entities source might be related to this TODO? That said I've come across on things that are definitely don't have disabled entities with matching archetype.

    Code (CSharp):
    1. // TODO(https://unity3d.atlassian.net/browse/DOTS-4625): Can't just grab the first entity here, it may be disabled
    2. return UnsafeUtility.AsRef<T>(ChunkIterationUtility.GetChunkComponentDataROPtr(chunk, match->IndexInArchetype[1]))
    2. Your own partial systems break code gen
    For example

    Code (CSharp):
    1. public partial class TestClass : SystemBase
    2. {
    3.     protected overide void OnUpdate()
    4.     {
    5.         Job1();
    6.         Job2();
    7.     }
    8. }
    9.  
    10. public partial class TestClass
    11. {
    12.     private void Job1()
    13.     {
    14.         Entities.Foreach(..).Schedule();
    15.     }
    16. }
    17.  
    18. public partial class TestClass
    19. {
    20.     private void Job2()
    21.     {
    22.         Entities.Foreach(..).Schedule();
    23.     }
    24. }
    Will cause duplicate generations with the exact same name - uses the class name not the method name.

    3. Unity hates 'this'
    Code (CSharp):
    1. .WithStoreEntityQueryInField(ref this._query)
    Breaks code gen and you must remove the 'this'. even though it's exactly the same. I feel like it's just some static rule that's being applied without thought.

    Replace with
    Code (CSharp):
    1. .WithStoreEntityQueryInField(ref _query)
    4. FIXED Nested [Set|Get]Components are broken in codegen
    For example -
    Code (CSharp):
    1. SetComponent(entity, GetComponent<Translation>(sourceEntity));
    Code (CSharp):
    1. SetComponent(GetComponent<Target>(entity).Value, new Translation());
    Code (CSharp):
    1. GetComponent<CollectableComponent>(GetComponent<AbilityEquipmentLink>(entity).EquipmentEntity)
    Fix - split them onto multiple lines
    Code (CSharp):
    1.  
    2. var newEntity = GetComponent<Target>(entity).Value;
    3. SetComponent(newEntity, new Translation());

    5. FIXED Systems inside systems don't work with code gen
    Code (CSharp):
    1. public partial class System1 : SystemBase
    2. {
    3.     public partial class System2 : SystemBase
    4.     {
    5.  
    6.     }
    7. }
    Code (CSharp):
    1. public partial class JoinedClass
    2. {
    3.     public partial class System1 : SystemBase
    4.     {
    5.  
    6.     }
    7.  
    8.     public partial class System2 : SystemBase
    9.     {
    10.  
    11.     }
    12. }
    Fix : really nothing except don't nest them.


    6. Callbacks don't work in codegen

    Code (CSharp):
    1.  
    2. Entities.ForEach((Entity entity, in GameKeyData gameKeyData) => {
    3.     var operation = EffectsManager.Inst.BorrowEffectAsync<EffectObject>(
    4.         assetRequest, effect => {
    5.             var speaker = (ISpeaker)behaviour;
    6.             effect.transform.SetParent(speaker.GetSpeaker().IconOffset, false);
    7.             effect.transform.localPosition = _effectOffset;
    8.         });
    9.     }).WithStructuralChanges().Run();
    10.  
    Fix - Haven't found anything better than manual iteration.

    7. Can't capture variables from ForEach into LocalFuntions

    Code (CSharp):
    1.  
    2.     Entities.ForEach((Entity entity, int entityInQueryIndex, in Translation translation) => {
    3.  
    4.         float3 position = default;
    5.  
    6.         Create1();
    7.         Create2(entityInQueryIndex);
    8.  
    9.         void Create1() {
    10.             var e = ecb.CreateEntity(entityInQueryIndex); // NotAllowed
    11.             var e = ecb.AddComponentData(entityInQueryIndex, e, new Translation {Value = position});
    12.         }
    13.  
    14.         void Create2(int index) {
    15.             ecb.CreateEntity(inde
    16.             // This is also fine because position is captured but not part of ForEach
    17.             var e = ecb.AddComponentData(index, e, new Translation {Value = position});
    18.         }
    19.        
    Note above example, it's fine to capture local values though.

    8. FIXED GetSingleton fails code gen for some reason in a property

    Code (CSharp):
    1.             protected bool GridInDatabaseMatchesActual {
    2.                 get {
    3.                     if (!HasSingleton<StreamedWorldGridComponent>()) return false;
    4.                     if (_grid == null) return false;
    5.                     var gridSingleton = GetSingleton<StreamedWorldGridComponent>(); // This fails here
    6.                     return gridSingleton.IsEqual(_grid);
    7.                 }
    8.             }
    not sure what is up with this, i don't think it should even be code genning but it caused an internal error.
    Fix - just create a query and get the component yourself.

    Code (CSharp):
    1. protected bool GridInDatabaseMatchesActual {
    2.     get {
    3.         if (_grid == null) return false;
    4.  
    5.         using var query = EntityManager.CreateEntityQuery(ComponentType.ReadOnly<StreamedWorldGridComponent>());
    6.         if (query.IsEmptyIgnoreFilter) {
    7.             return false;
    8.         }
    9.  
    10.         var gridSingleton = query.GetSingleton<StreamedWorldGridComponent>();
    11.         return gridSingleton.IsEqual(_grid);
    12.     }
    13. }


    9. FIXED query.ToComponentDataArray need to call query.CompleteDependency() to be safe

    I'd recommend you use query.ToComponentDataArrayAsync instead
     
    Last edited: Apr 29, 2022
  2. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    502
    Thank you sir. A real time saver. I will definitely have singleton and partial bugs in my projects.
     
    eitaronishijima likes this.
  3. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    I've significantly updated the original post for anyone who viewed it originally.
     
    BelkinAlex, Krajca and JesOb like this.
  4. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    880
    Thanks, my project is completely broken with the latest entities right now.
     
    mikaelK likes this.
  5. Zec_

    Zec_

    Joined:
    Feb 9, 2017
    Posts:
    148
    Regarding this final suggested fix, doesn't it potentially clash with your top-most issue about query.GetSingleton<> being broken?

    Edit: Seeing Joachim_Antes response below, your suggested fix should work with no issues. Nevermind!
     
    Last edited: Mar 17, 2022
  6. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    If someone happens to get something along the lines of:

    Code (CSharp):
    1. Cannot implicitly convert type Unity.Entities.BufferTypeHandle<Whatever> to BufferTypeHandle<Whatever>
    check if you have ForwardCompatibilityExtensions.cs. That was causing me issues with standard DynamicBuffer usage. I am not even sure where it came from. I commented it out and then everything worked just fine. ¯\_(ツ)_/¯
     
  7. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    It appears that in 0.50 GetSingleton fails if you provide more than one IComponentData to the query, depending on which of the query elements you fetch. We'll fix it in 0.51. (All internal usage of GetSingleton is through queries with exactly one required component data on the query)
     
    iamarugin, WAYNGames, Occuros and 3 others like this.
  8. bb8_1

    bb8_1

    Joined:
    Jan 20, 2019
    Posts:
    100
    in DOTS>DOTS compiler there is option : add missing partial keyword to systems (learned this too late lol)
     
    lclemens likes this.
  9. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
    MostHated and bb8_1 like this.
  10. CookieStealer2

    CookieStealer2

    Joined:
    Jun 25, 2018
    Posts:
    119
    Edit: This bug is already in tertle's list

    Found another bug related to singletons. When you use GetSingleton<T>() from a property in systembase...
    Code (CSharp):
    1.     public struct TestComponent : IComponentData {}
    2.  
    3.     public partial class TestSystem : SystemBase
    4.     {
    5.         TestComponent SingletonData => GetSingleton<TestComponent>();
    6.  
    7.         protected override void OnUpdate()
    8.         {
    9.             var singletonData = SingletonData;
    10.         }
    11.     }
    ...you get the following error on compile:
    Workaround is to not use a property:
    Code (CSharp):
    1.     public struct TestComponent : IComponentData {}
    2.  
    3.     public partial class TestSystem : SystemBase
    4.     {
    5.         protected override void OnUpdate()
    6.         {
    7.             var singletonData = GetSingleton<TestComponent>();
    8.         }
    9.     }
    Bug is reported also.
     
    Last edited: Mar 17, 2022
    peaj_metric likes this.
  11. Zec_

    Zec_

    Joined:
    Feb 9, 2017
    Posts:
    148
    Tertle brought up this issue in section 8 of the top post, and you can see a temporary solution there as well if you still want to use a property.
     
    CookieStealer2 likes this.
  12. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,753
    @tertle out of curiosity, which Unity version are you running?
     
  13. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    2020.3.30f1
     
    Antypodish likes this.
  14. mk1987

    mk1987

    Joined:
    Mar 18, 2019
    Posts:
    53
    Think this thread seems appropriate. Im getting a few dependency errors during runtime which i've never encountered before in 0.17 where it was working perfectly fine. Could be me being against practice but if thats the case I suspect i wont be alone and would be good to know what im doing wrong or whether its a actual bug that i should revert back to 0.17 whilst it gets fixed.

    The first is using the TriggerEvents system, as i needed the Trigger hit point i use raycasts within the job so im parsing in a readonly copy of Physics world (Not using Collision Event since i dont want it to do any actual collision physics). If i remove raycasts and physicsworld ref I get the same error but on LaserDat instead. This system is either not working or my colliders are a mess in this update which i'll be checking now.

    Code (CSharp):
    1. InvalidOperationException: The previously scheduled job Integrator:ParallelIntegrateMotionsJob writes to the Unity.Collections.NativeArray`1[Unity.Physics.MotionData] ParallelIntegrateMotionsJob.MotionDatas. You are trying to schedule a new job CollisionJob, which reads from the same Unity.Collections.NativeArray`1[Unity.Physics.MotionData] (via CollisionJob.UserJobData.world.DynamicsWorld.m_MotionDatas). To guarantee safety, you must include Integrator:ParallelIntegrateMotionsJob as a dependency of the newly scheduled job.
    Code:
    Code (CSharp):
    1.     protected override void OnUpdate()
    2.     {
    3.        
    4.         NativeList<LogJam> Filter = new NativeList<LogJam>(Allocator.TempJob);          //used to ensure duplicate impacts are not accounted for in the same frame
    5.         var CollisionJob = new CollisionJob
    6.         {
    7.             L2W = GetComponentDataFromEntity<LocalToWorld>(),
    8.             ColliderEnt = GetComponentDataFromEntity<ColliderEnabled>(),
    9.             world = _buildPhysicsWorldSystem.PhysicsWorld,
    10.             LaserDat = GetComponentDataFromEntity<LaserHit>(true),
    11.             LaserFixed = GetComponentDataFromEntity<LaserData>(true),
    12.             MissileData = GetComponentDataFromEntity<MissileData>(true),
    13.             LaserMissileAlive = GetComponentDataFromEntity<IsAlive>(),
    14.             HitTargetBuffer = GetBufferFromEntity<HitTargetBuffer>(),
    15.             Par = GetComponentDataFromEntity<Parent>(true),
    16.             CF = CF,
    17.             LJ= Filter,
    18.         };
    19.      
    20.         Dependency = CollisionJob.Schedule(stepPhysicsWorld.Simulation, Dependency);
    21.         Dependency.Complete();
    22.         //var Co = new CO
    23.         //{
    24.         //
    25.         //};
    26.         //Dependency = Co.Schedule(stepPhysicsWorld.Simulation, Dependency);
    27.         //commandBufferSystem.AddJobHandleForProducer(Dependency);
    28.    
    29.         Filter.Dispose();
    30.             //return Dependency;
    31.  
    32.  
    33.     }

    The second is on LocalToWorld which im collecting as read only.. Note following it states lambda job 3 but the line it suggests ReloadmeB which should be 4 or 5 but certainly not 3. Im also confused why it isnt an issue for for the 2 or 3 lambdas beforehand. The system was a bit complex with multiple lambdas but works pretty fast for what i need and still seems to be working from what i can see.

    Error:
    The system LinearWeapons reads Unity.Transforms.LocalToWorld via LinearWeapons:LinearWeapons_LambdaJob_3_Job but that type was not assigned to the Dependency property. To ensure correct behavior of other systems, the job or a dependency must be assigned to the Dependency property before returning from the OnUpdate method.


    Code (CSharp):
    1.     protected override void OnUpdate()
    2.     {
    3.  
    4.             var ecb = m_EndSimulationEcbSystem.CreateCommandBuffer().AsParallelWriter();
    5.             deltatim = World.GetOrCreateSystem<FixedStepSimulationSystemGroup>().Timestep;
    6.             //float dt = UnityEngine.Time.deltaTime;
    7.             ComponentDataFromEntity<LocalToWorld> trans = GetComponentDataFromEntity<LocalToWorld>(true);
    8.             UpdateTarget UpdateT = new UpdateTarget()
    9.             {
    10.                 trans = trans,
    11.                 TargetList = GetBufferFromEntity<TargetList>(true),
    12.                 PTA = GetBufferFromEntity<PrimaryTargetArray>(true),
    13.                 STA = GetBufferFromEntity<SecondaryTargetArray>(true),
    14.                 WTA = GetBufferFromEntity<WeaponTargetArray>(true),
    15.                 CM = GetComponentDataFromEntity<CommandMaster>(true)
    16.             };
    17.             //0- The below deals with assigning targets to the weapon
    18.             Entities.WithBurst().ForEach((Entity Ent, ref TargetSelector TS, in WeaponAttributes WA, in Parent Par, in LocalToWorld L2W) => UpdateT.Execute(Ent, ref TS, in WA, in Par, in L2W)).ScheduleParallel();
    19.             //
    20.             TargetJob targ = new TargetJob()
    21.             {
    22.                 deltaTime = deltatim,
    23.             };
    24.             //1-This one tracks the primary target and updates where to aim (This is suitable for turret or projectile launched weapons
    25.             Entities.WithBurst().ForEach((ref targetop Var, in LocalToWorld TR, in TargetSelector TS) => targ.Execute(ref Var, in TR, in TS)).ScheduleParallel();
    26.             //m_EndSimulationEcbSystem.AddJobHandleForProducer(this.Dependency);
    27.             //
    28.             TurretCode turd = new TurretCode()
    29.             {
    30.                 deltaTime = deltatim,
    31.                 trans = trans,
    32.                 commandBuffer = ecb,
    33.                 at = GetComponentDataFromEntity<Aimedtag>(true)
    34.             };
    35.             //2 - this one controls the turret aim
    36.             Entities.WithBurst().ForEach((Entity entity, int entityInQueryIndex, in TurretConstants Con, in targetop TTr, in PowerDrawComp PDC, in CompHealthState CHS) => turd.Execute(entity, entityInQueryIndex, in Con, in TTr, in PDC, in CHS)).ScheduleParallel();
    37.             Entities.WithBurst().ForEach((Entity entity, int entityInQueryIndex, in targetop Var, in MissileOperator MO) => turd.MissileLauncher(entity, entityInQueryIndex, in Var, in MO)).ScheduleParallel();
    38.             m_EndSimulationEcbSystem.AddJobHandleForProducer(this.Dependency);
    39.             //
    40.             WeaponCharge WC = new WeaponCharge()
    41.             {
    42.                 dt = deltatim,
    43.                 PowerDraw = GetComponentDataFromEntity<PowerDrawComp>(true),
    44.                 commandBuffer = ecb
    45.             };
    46.             //3- this one controls the charge of weapon (reload as to be done elsewhere);
    47.             Entities.WithBurst().ForEach((Entity entity, int entityInQueryIndex, ref ChargeComp PD, in Parent Par) => WC.Execute(entity, entityInQueryIndex, ref PD, in Par)).ScheduleParallel();
    48.             //
    49.             //the below do reloads where applicable
    50.             EntityQueryDesc ReloadAllocation = new EntityQueryDesc
    51.             {
    52.                 //None = new ComponentType[] { typeof(PlayerTag), typeof(AllyTag) },
    53.                 All = new ComponentType[] { typeof(ComponentAllocations), typeof(SendAmmo), typeof(Parent) }
    54.             };
    55.             ReloadMeA RMA = new ReloadMeA()
    56.             {
    57.                 deltatime = deltatim,
    58.                 commandBuffer = ecb,
    59.                 Trans = trans,
    60.                 ChargeCo = GetComponentDataFromEntity<ChargeComp>()
    61.             };
    62.             Entities.WithBurst().ForEach((Entity entity, int entityInQueryIndex, ref DynamicBuffer<SendAmmo> SA, ref ComponentAllocations CA) => RMA.Execute(entity, entityInQueryIndex, ref SA, ref CA)).Schedule();
    63.            
    64.             ReloadmeB RMB = new ReloadmeB()
    65.             {
    66.                 commandBuffer = ecb,
    67.                 Trans = trans,
    68.                 RA1 = GetComponentDataFromEntity<ReallocateAmmo>(),
    69.                 ComponentAllocations = GetEntityQuery(ReloadAllocation).ToComponentDataArray<ComponentAllocations>(Allocator.TempJob),
    70.                 ComponentAllocationsEnt = GetEntityQuery(ReloadAllocation).ToEntityArray(Allocator.TempJob),
    71.                 ComponentAllocationsPar = GetEntityQuery(ReloadAllocation).ToComponentDataArray<Parent>(Allocator.TempJob),
    72.             };
    73.             Entities.WithBurst().ForEach((Entity entity, int entityInQueryIndex, ref ChargeComp pD, ref Reloadme RM, ref PowerDrawComp PDC, in Parent Par) => RMB.Execute(entity, entityInQueryIndex, ref pD, ref RM, ref PDC, in Par)).Schedule();
    74.            
    75.             OpenDoors OD = new OpenDoors()
    76.             {
    77.                 commandBuffer = ecb,
    78.                 at = GetComponentDataFromEntity<Aimedtag>(),
    79.                 deltatime = deltatim,
    80.                 L2P = GetComponentDataFromEntity<Translation>()
    81.             };
    82.             Entities.WithBurst().ForEach((Entity ent, int entityInQueryIndex, ref ChargeComp CC, in MissileOperator MO, in CompHealthState CHS) => OD.Execute(ent, entityInQueryIndex, ref CC, in MO, in CHS)).ScheduleParallel();
    83.             firecode fire = new firecode()
    84.             {
    85.                 dt = deltatim,
    86.                 ecb = ecb
    87.             };
    88.             //this one fires the weapon if various conditions met (specifically turret or energy based weapons
    89.             Entities.WithBurst().ForEach((Entity entity, int entityInQueryIndex, ref ChargeComp PD, ref DynamicBuffer<SpawnCooldown> SC, in DynamicBuffer<ElementSpawnPosition> SP, in Aimedtag at, in AmunitionContainer AC, in LocalToWorld pos) => fire.Execute(entity, entityInQueryIndex, ref PD, ref SC, in SP, in at, in AC, in pos)).ScheduleParallel();
    90.             m_EndSimulationEcbSystem.AddJobHandleForProducer(this.Dependency);
    91.             //(Entity entity, int entityInQueryIndex, in Aimedtag at, in AmunitionContainer AC, in LocalToWorld pos, in DynamicBuffer<ElementSpawnPosition> SP, ref PowerDraw PD, ref DynamicBuffer<SpawnCooldown> SC)
    92.  
    93.         }
     
  15. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    It was unfortunately left out of the 0.17 upgrade guide but there's a new way to handle dependencies in physics that's hidden in the physics changelog upgrade guide.

    You need to use the new register dependency methods

     
    lclemens, Harry-Wells and yinyinh like this.
  16. mk1987

    mk1987

    Joined:
    Mar 18, 2019
    Posts:
    53
    @tertle Thanks for that, i looked at change notes at 0.50 but didnt think to look at the unissued change notes below. I'll update my post if/when i update the code.

    Edit: Just needed to add this.RegisterPhysicsRuntimeSystemReadOnly(); into my Onstartrunning() and it works perfectly now with my collision handling system working as before! Thanks Again!

    Another issue ive come accross, one of my damage modules outside of entities.foreach using Hybrid Renderer V2 and entities goes into the RenderMesh collects the mesh, updates Vertex Colour information representing damage, creates a new mesh (since i dont want damage to occur to all the ships, just the ship thats damaged) and then spits it back into the component as a new RenderMesh, this worked seemingly instantaneously before with only minor render issues (a single frame might go invisible but at 60fps ive never seen it).

    That code seems to be working as it was before with the mesh correctly generated but reissuing the RenderMesh results in that Entity not rendering anymore despite all the components being identical bar the change in mesh. I did change the code to use RenderMeshUtility.AddComponent but the results the same, i used default Shader as a test and the results the same in case it was a shader issue.

    Im not sure in this instance if i need to tell the Hybrid Renderer to do something such as a revalidation or if theres a function that deals with mesh changes. If anyone knows what to do that be great, else i'll update this post if/when i find a work around. My only thought is it could be due to the change in the unissued 0.12.0 " Do not perform structural changes in the HybridRendererSystem anymore" but could be something else.

    EDIT: Turned out reason it wasnt rendering was due to the layermask value in Rendermesh, im not sure if thats a new thing or not or whether HybridRenderer 0.50 interprets it differently but setting the layermask to 1 from zero seemed to fix the problem and it now renders.
     
    Last edited: Mar 20, 2022
  17. DreamersINC

    DreamersINC

    Joined:
    Mar 4, 2015
    Posts:
    131
    So far I have run into code generation broken for [GenerateAuthoringComponent] if the component has private variables and generic system reflection throw error callback but the system still works
     
  18. JohnnyTurbo

    JohnnyTurbo

    Joined:
    May 17, 2017
    Posts:
    42
    Got the same error as @CookieStealer2 when using SetSingleton()
    Code (CSharp):
    1. public struct SomeComponent : IComponentData
    2. {
    3.    public float Value;
    4. }
    5.  
    6. public partial class TestSystem : SystemBase
    7. {
    8.    private SomeComponent a;
    9.  
    10.    protected override void OnUpdate()
    11.    {
    12.       a = new SomeComponent{ Value = 123 };
    13.  
    14.       // Below does not compile on 0.50
    15.       SetSingleton(a);
    16.  
    17.       // This will still work
    18.       var b = a;
    19.       SetSingleton(b);
    20.    }
    21. }
    Bug reported through editor.

    UPDATE: Just discovered this issue only occurs when passing in a class scoped variable to the SetSingleton() method. Updated the code to better reflect the issue and workaround.
     
    Last edited: Mar 23, 2022
    lclemens and bb8_1 like this.
  19. JohnnyTurbo

    JohnnyTurbo

    Joined:
    May 17, 2017
    Posts:
    42
    Also came across a few quirks with the new physics packages - not necessarily bugs but did have me scratching my head for a bit.

    I made a sample project for a tutorial video on creating a multi-unit area selection system with DOTS physics, where I create a selection mesh through code, then any entities inside that selection volume get selected [Link to Tuorial Video]. I upgraded the project to 0.50 to see what broke - the single unit selection (using raycasts) worked fine, however the area unit selection did not.

    First I came across an upgrade tool to upgrade the physics authoring components to be compatible with physics 0.50.

    Go to Window > DOTS > Physics > Upgrade Data to open the tool. I ran the tool with the Upgrade Materials box checked and everything worked fine. Tool then lists all the assets it finds that were upgraded. A .json report also gets dropped into your Assets folder.

    The above didn't completely fix the issues I was having and in my brief searches, I didn't come across any docs on this tool yet, so unsure exactly what it does, but I'm sure it's there for a reason :)

    I narrowed the issue down to the creation of my selection entity (volume). I found out that the selection entity's collider wasn't properly being instantiated in the world.

    I was able to confirm that the entity was still being created with expected data, however with the physics debug visualizations enabled, I didn't actually see the collider in the editor and no trigger events were firing.

    The fix was simply to add a PhysicsWorldIndex component to the selection entity I was spawning. After that I could see the collider in the editor and trigger events were firing as expected.

    Hope that helps someone!
     
    PhilSA, lclemens and bb8_1 like this.
  20. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    I'm getting a bunch of profiler-related errors.
    dots_errors.png

    Any clue how to resolve these?
     
  21. Zec_

    Zec_

    Joined:
    Feb 9, 2017
    Posts:
    148
    EternalAmbiguity likes this.
  22. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    All my IJobEntity have the following warnings

    Code (CSharp):
    1. There is no defined ordering between fields in multiple declarations of partial struct 'DecisionMakerSystem.DecisionMakerJob'. To specify an ordering, all instance fields must be in the same declaration. [Collapse]csharp(CS0282)
    2.  
     
    lclemens and Gekigengar like this.
  23. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
  24. AlexHolderDev

    AlexHolderDev

    Joined:
    Jul 2, 2014
    Posts:
    35
    Here's a fun one: the Assets>Create>ECS>System action creates a file that does not obey the new System syntax rules.

    I get this error when creating a system from that menu item:

    Assets\Scripts\ExampleSystem.cs(8,1): error DC0058: All SystemBase-derived classes must be defined with the `partial` keyword, so that source generators can emit additional code into these classes. Please add the `partial` keyword to ExampleSystem, as well as all the classes it is nested within.​

    The code created by that menu item is this:

    Code (CSharp):
    1. using Unity.Burst;
    2. using Unity.Collections;
    3. using Unity.Entities;
    4. using Unity.Jobs;
    5. using Unity.Mathematics;
    6. using Unity.Transforms;
    7.  
    8. public class ExampleSystem : SystemBase
    9. {
    10.     protected override void OnUpdate()
    11.     {
    12.         // Assign values to local variables captured in your job here, so that it has
    13.         // everything it needs to do its work when it runs later.
    14.         // For example,
    15.         //     float deltaTime = Time.DeltaTime;
    16.  
    17.         // This declares a new kind of job, which is a unit of work to do.
    18.         // The job is declared as an Entities.ForEach with the target components as parameters,
    19.         // meaning it will process all entities in the world that have both
    20.         // Translation and Rotation components. Change it to process the component
    21.         // types you want.
    22.      
    23.      
    24.      
    25.         Entities.ForEach((ref Translation translation, in Rotation rotation) => {
    26.             // Implement the work to perform for each entity here.
    27.             // You should only access data that is local or that is a
    28.             // field on this job. Note that the 'rotation' parameter is
    29.             // marked as 'in', which means it cannot be modified,
    30.             // but allows this job to run in parallel with other jobs
    31.             // that want to read Rotation component data.
    32.             // For example,
    33.             //     translation.Value += math.mul(rotation.Value, new float3(0, 0, 1)) * deltaTime;
    34.         }).Schedule();
    35.     }
    36. }
    37.  
    Doing as the error suggests and adding the "partial" word after "public" in the system declaration does fix this issue. It's that simple - why doesn't the menu item do this?
     
    bb8_1 likes this.
  25. Fabrice_Lete

    Fabrice_Lete

    Unity Technologies

    Joined:
    May 5, 2018
    Posts:
    55
    Are your IJobEntity split over multiple partial structs? If different parts of the same struct define fields, that warning is expected: https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs0282
     
  26. Fabrice_Lete

    Fabrice_Lete

    Unity Technologies

    Joined:
    May 5, 2018
    Posts:
    55
    Can you please clarify what you mean by "to be safe"? Do you mean that those functions are throwing an exception if there is a running job accessing the same components, or that calling those functions causes undefined behavior (crash, corrupted data, etc.)
     
  27. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    Safety warnings are thrown on existing jobs using these components because the dependency hasn't been completed. Not sure if behaviour has changed or safety system has been improved compared to 0.17

    We had this issue in half a dozen places and this same issue has been mentioned by a few other users on the forums, for example this thread: https://forum.unity.com/threads/fee...ncy-getoutputdependency.1254111/#post-7985031

    I fixed our project by just switching to the Async version
     
    Last edited: Mar 22, 2022
  28. Abbrew

    Abbrew

    Joined:
    Jan 1, 2018
    Posts:
    417
    Making the IJobEntity partial is required - I get a compilation error otherwise. Here's the IJobEntity

    Code (CSharp):
    1. [BurstCompile]
    2.         private partial struct DecisionMakerJob : IJobEntity
    3.         {
    4.             public EntityCommandBuffer.ParallelWriter ecbParallel;
    5.             public BehaviorWriters behaviorWriters;
    6.  
    7.             [ReadOnly]
    8.             public ComponentDataFromEntity<BehaviorProgressComponent> behaviorProgressFromEntity;
    9.             [ReadOnly]
    10.             public ComponentDataFromEntity<BehaviorResultComponent> behaviorResultFromEntity;
    11.  
    12.             public void Execute(
    13.                 Entity decisionMakerEntity,
    14.                 [EntityInQueryIndex] int entityInQueryIndex,
    15.                 in BehaviorProgressComponent progress,
    16.                 in DynamicBuffer<DecisionMakerConditionElement> conditions,
    17.                 ref DynamicBuffer<DecisionMakerConditionAllRemainingElement> conditionsRemaining,
    18.                 in DynamicBuffer<DecisionMakerConditionAllElement> conditionsUnique,
    19.                 in DynamicBuffer<DecisionMakerTaskElement> tasks,
    20.                 in DynamicBuffer<DecisionMakerKickoffTaskElement> kickoffTasks,
    21.                 in DynamicBuffer<DecisionMakerDurationTaskElement> durationTasks,
    22.                 ref DynamicBuffer<DecisionMakerDurationTaskCurrentElement> currentDurationTasks,
    23.                 in DynamicBuffer<DecisionMakerPlanElement> plans,
    24.                 ref DynamicBuffer<DecisionMakerCurrentPlanElement> currentTasks,
    25.                 in DynamicBuffer<DecisionMakerFallbackTaskElement> fallbackTasks,
    26.                 in DynamicBuffer<DecisionMakerFallbackKickoffTaskElement> fallBackKickoffTasks,
    27.                 in DynamicBuffer<DecisionMakerFallbackDurationTaskElement> fallbackDurationTasks,
    28.                 in DecisionMakerFallbackAnimationComponent fallbackAnimation,
    29.                 in DynamicBuffer<DecisionMakerAnimationElement> animations,
    30.                 ref DecisionMakerAnimationCurrentComponent currentAnimation
    31.             )
    32.             {
    33.                 var conditionAllsFast = conditionsUnique.AsNativeArray();
    34.                 var conditionsFast = conditions.AsNativeArray();
    35.                 var tasksFast = tasks.AsNativeArray();
    36.  
    37.                 var behaviorProgressChange = false;
    38.                 var newState = INVALID_STATE;
    39.  
    40.                 switch (progress.state)
    41.                 {
    42.                     case (int)State.START_PLANNING:
    43.  
    44.                         conditionsRemaining.Clear();
    45.  
    46.                         foreach (var conditionAll in conditionAllsFast)
    47.                         {
    48.                             var conditionAllEntity = conditionAll.entity;
    49.  
    50.                             BehaviorSystemActions.Start(ecbParallel, entityInQueryIndex, conditionAllEntity);
    51.  
    52.                             conditionsRemaining.Add(new DecisionMakerConditionAllRemainingElement
    53.                             {
    54.                                 entity = conditionAllEntity
    55.                             });
    56.                         }
    57.  
    58.                         behaviorProgressChange = true;
    59.                         newState = (int)State.WAIT_FOR_PLANNING;
    60.  
    61.                         break;
    62.  
    63.                     case (int)State.WAIT_FOR_PLANNING:
    64.  
    65.                         var numConditionAllRemainings = conditionsRemaining.Length;
    66.                         for (var j = numConditionAllRemainings - 1; j >= 0; j--)
    67.                         {
    68.                             var numConditionAllRemainingEntity = conditionsRemaining[j].entity;
    69.                             if (Hint.Likely(BehaviorSystemActions.IsComplete(behaviorProgressFromEntity, numConditionAllRemainingEntity)))
    70.                             {
    71.                                 conditionsRemaining.RemoveAtSwapBack(j);
    72.                             }
    73.                         }
    74.  
    75.                         // All conditions have completed
    76.                         if (Hint.Unlikely(conditionsRemaining.IsEmpty))
    77.                         {
    78.                             var numPlansAmount = plans.Length;
    79.  
    80.                             // Create a lookup of conditions to their plans
    81.                             var numConditions = conditionsFast.Length;
    82.                             var conditionsToPlans = new NativeMultiHashMap<Entity, int>(numConditions, Allocator.Temp);
    83.                             foreach (var condition in conditionsFast)
    84.                             {
    85.                                 conditionsToPlans.Add(condition.entity, condition.planIndex);
    86.                             }
    87.  
    88.                             // Count how many conditions each plan has completed
    89.                             var plansToNumConditionsCompleted = new NativeArray<int>(numPlansAmount, Allocator.Temp);
    90.                             foreach (var conditionAll in conditionAllsFast)
    91.                             {
    92.                                 var conditionAllEntity = conditionAll.entity;
    93.                                 if (Hint.Unlikely(behaviorResultFromEntity[conditionAllEntity].success))
    94.                                 {
    95.                                     if (Hint.Likely(conditionsToPlans.TryGetFirstValue(conditionAllEntity, out var planIndex, out var it)))
    96.                                     {
    97.                                         plansToNumConditionsCompleted[planIndex] = plansToNumConditionsCompleted[planIndex] + 1;
    98.  
    99.                                         while (Hint.Unlikely(conditionsToPlans.TryGetNextValue(out planIndex, ref it)))
    100.                                         {
    101.                                             plansToNumConditionsCompleted[planIndex] = plansToNumConditionsCompleted[planIndex] + 1;
    102.                                         }
    103.                                     }
    104.                                 }
    105.                             }
    106.  
    107.                             // Iterate through all plans
    108.                             var plansFast = plans.AsNativeArray();
    109.                             var planTasks = new NativeList<Entity>(Allocator.Temp);
    110.                             var planDurationTasks = new NativeList<Entity>(Allocator.Temp);
    111.                             var planSucceeded = false;
    112.                             for (var planIndex = 0; planIndex < numPlansAmount; planIndex++)
    113.                             {
    114.                                 if (Hint.Unlikely(plansToNumConditionsCompleted[planIndex] == plansFast[planIndex].numConditionsRequired))
    115.                                 {
    116.                                     planSucceeded = true;
    117.  
    118.                                     // Choose only the tasks with all conditions completed
    119.                                     foreach (var task in tasksFast)
    120.                                     {
    121.                                         if (Hint.Unlikely(task.planIndex == planIndex))
    122.                                         {
    123.                                             planTasks.Add(task.entity);
    124.                                         }
    125.                                     }
    126.  
    127.                                     // Kickoff the kickoff tasks
    128.                                     foreach(var kickoffTask in kickoffTasks.AsNativeArray())
    129.                                     {
    130.                                         if (Hint.Unlikely(kickoffTask.planIndex == planIndex))
    131.                                         {
    132.                                             BehaviorSystemActions.Start(ecbParallel, entityInQueryIndex, kickoffTask.entity);
    133.                                         }
    134.                                     }
    135.  
    136.                                     // Choose the duration tasks
    137.                                     foreach(var durationTask in durationTasks.AsNativeArray())
    138.                                     {
    139.                                         if(Hint.Unlikely(durationTask.planIndex == planIndex))
    140.                                         {
    141.                                             planDurationTasks.Add(durationTask.entity);
    142.                                         }
    143.                                     }
    144.  
    145.                                     // Choose only the animation with all conditions completed
    146.                                     var chosenAnimation = animations[planIndex];
    147.                                     currentAnimation.entity = chosenAnimation.entity;
    148.                                     currentAnimation.loop = chosenAnimation.loop;
    149.  
    150.                                     break;
    151.                                 }
    152.                             }
    153.  
    154.                             // Empty means no plan succeeded
    155.                             if (!planSucceeded)
    156.                             {
    157.                                 // Fallback tasks
    158.                                 foreach (var fallbackTask in fallbackTasks.AsNativeArray())
    159.                                 {
    160.                                     planTasks.Add(fallbackTask.entity);
    161.                                 }
    162.  
    163.                                 // Fallback duration tasks
    164.                                 foreach(var durationTask in fallbackDurationTasks.AsNativeArray())
    165.                                 {
    166.                                     planDurationTasks.Add(durationTask.entity);
    167.                                 }
    168.  
    169.                                 // Kickoff the kickoff tasks
    170.                                 foreach (var kickoffTask in fallBackKickoffTasks.AsNativeArray())
    171.                                 {
    172.                                     BehaviorSystemActions.Start(ecbParallel, entityInQueryIndex, kickoffTask.entity);
    173.                                 }
    174.  
    175.                                 currentAnimation.entity = fallbackAnimation.entity;
    176.                                 currentAnimation.loop = fallbackAnimation.loop;
    177.                             }
    178.  
    179.                             // Start the chosen tasks
    180.                             currentTasks.Clear();
    181.                             foreach (var planTask in planTasks.AsArray())
    182.                             {
    183.                                 currentTasks.Add(new DecisionMakerCurrentPlanElement
    184.                                 {
    185.                                     entity = planTask
    186.                                 });
    187.  
    188.                                 BehaviorSystemActions.Start(ecbParallel, entityInQueryIndex, planTask);
    189.                             }
    190.  
    191.                             // Start the chosen duration tasks
    192.                             currentDurationTasks.Clear();
    193.                             foreach (var currentDurationTask in planDurationTasks.AsArray())
    194.                             {
    195.                                 currentDurationTasks.Add(new DecisionMakerDurationTaskCurrentElement
    196.                                 {
    197.                                     entity = currentDurationTask
    198.                                 });
    199.  
    200.                                 BehaviorSystemActions.Start(ecbParallel, entityInQueryIndex, currentDurationTask);
    201.                             }
    202.  
    203.                             // Start the chosen animation
    204.                             BehaviorSystemActions.Start(ecbParallel, entityInQueryIndex, currentAnimation.entity);
    205.  
    206.                             behaviorProgressChange = true;
    207.                             newState = (int)State.WAIT_FOR_DECISION;
    208.                         }
    209.  
    210.                         break;
    211.  
    212.                     case (int)State.WAIT_FOR_DECISION:
    213.  
    214.                         // Count the number of tasks still running
    215.                         var numTasksRemaining = currentTasks.Length;
    216.                         for (var j = numTasksRemaining - 1; j >= 0; j--)
    217.                         {
    218.                             var taskRemainingEntity = currentTasks[j].entity;
    219.                             if (Hint.Unlikely(BehaviorSystemActions.IsComplete(behaviorProgressFromEntity, taskRemainingEntity)))
    220.                             {
    221.                                 currentTasks.RemoveAtSwapBack(j);
    222.                             }
    223.                         }
    224.  
    225.                         // Check if animation is completed only if it doesn't loop
    226.                         var animationCompleted = BehaviorSystemActions.IsComplete(behaviorProgressFromEntity, currentAnimation.entity);
    227.                         var animationLoops = currentAnimation.loop;
    228.                         var animationTaskCompleted = animationLoops | animationCompleted;
    229.                         // Loop the animation when appropriate
    230.                         if (Hint.Unlikely(animationLoops & animationCompleted))
    231.                         {
    232.                             BehaviorSystemActions.Start(ecbParallel, entityInQueryIndex, currentAnimation.entity);
    233.                         }
    234.  
    235.                         if (Hint.Unlikely(currentTasks.IsEmpty & animationTaskCompleted))
    236.                         {
    237.                             // Stop the duration tasks
    238.                             foreach (var durationTaskInProgress in currentDurationTasks.AsNativeArray())
    239.                             {
    240.                                 BehaviorSystemActions.Succeed(behaviorWriters, durationTaskInProgress.entity);
    241.                             }
    242.  
    243.                             goto case (int)State.START_PLANNING;
    244.                         }
    245.  
    246.                         break;
    247.  
    248.                     case (int)State.RESTART:
    249.  
    250.                         // Cancel all possibly running behaviors
    251.                         BehaviorSystemActions.Succeed(behaviorWriters, currentAnimation.entity);
    252.                         foreach (var conditionInProgress in conditionsRemaining.AsNativeArray())
    253.                         {
    254.                             BehaviorSystemActions.Succeed(behaviorWriters, conditionInProgress.entity);
    255.                         }
    256.                         foreach (var taskInProgress in currentTasks.AsNativeArray())
    257.                         {
    258.                             BehaviorSystemActions.Succeed(behaviorWriters, taskInProgress.entity);
    259.                         }
    260.                         foreach(var durationTaskInProgress in currentDurationTasks.AsNativeArray())
    261.                         {
    262.                             BehaviorSystemActions.Succeed(behaviorWriters, durationTaskInProgress.entity);
    263.                         }
    264.  
    265.                         behaviorProgressChange = true;
    266.                         newState = (int)State.START_PLANNING;
    267.  
    268.                         break;
    269.  
    270.                     default:
    271.                         break;
    272.                 }
    273.  
    274.                 if (Hint.Unlikely(behaviorProgressChange))
    275.                 {
    276.                     BehaviorSystemActions.Progress(behaviorWriters, decisionMakerEntity, newState);
    277.                 }
    278.             }
     
    Oneiros90 likes this.
  29. cort_of_unity

    cort_of_unity

    Unity Technologies

    Joined:
    Aug 15, 2018
    Posts:
    98
    I am aware of this regression in 0.17 and 0.50, and have a fix in progress for ToComponentDataArray() and CopyFromComponentDataArray(). I wasn't aware that ToEntityArray() was affected; can you elaborate on the safety error you're seeing with that call? Jobs shouldn't be able to write the Entity arrays that ToEntityArray() is reading; only main-thread structural changes can do that. So I'm not sure what extra safety/dependency checks this function needs beyond what are already in place. If you have a quick repro case for the ToEntityArray issue, that would be even better; thanks!
     
  30. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    I'm on day two of trying to upgrade.
    Hybrid Renderer 0.50 says that no types have been registered:
    2022-03-28_23-46-28@2x.png


    It would be very useful if DOTS team could include more details in error messages so we know why they happened / how to fix them.

    EDIT turns out ENABLE_HYBRID_RENDERER_V2 is not defined anymore.
    even though Hybrid Renderer V2 is enabled.
    2022-03-28_23-56-02@2x.png
     
    Last edited: Mar 28, 2022
  31. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Systems Window only seems to display systems for default world:
    2022-03-29_01-35-39@2x.png

    Selecting another world (ServerWorld) does not display any systems.
    The old Entity Debugger does display systems (ServerWorld):

    2022-03-29_01-38-24@2x.png
     
  32. Zec_

    Zec_

    Joined:
    Feb 9, 2017
    Posts:
    148
    If the fix for the ToComponentDataArray() and CopyFromComponentDataArray() regression is relatively simple, it would be greatly appreciated if you could share a diff of the changes in the entities package.

    Our project has a quite massive codebase and it would be great if we could avoid having to adjust a lot of code for this temporary regression. But yeah, if the diff is complex or the sharing of it too large an undertaking I understand it. We are always able to wait for the next patch, but we're simply quite excited to get everything running :)
     
    Last edited: Mar 28, 2022
  33. cort_of_unity

    cort_of_unity

    Unity Technologies

    Joined:
    Aug 15, 2018
    Posts:
    98
    For the issue I have in mind, the minimal diff would just be a call to CompleteDependency() added to the beginning of ToEntityArray(), ToComponentDataArray(), and CopyFromComponentDataArray(). The rest is mostly just unit test coverage and comments.

    This is probably a more aggressive sync than what's necessary for these operations, but it restores the original pre-0.17 behavior (and provides consistency with what the Async() variants are using).
     
    bb8_1 and Zec_ like this.
  34. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    Hey Cort. I went back and changed a few random ToEntityArrayAsync to ToEntityArray in the project that I thought had the issue but I wasn't able to repo it today. I would have sworn I saw a single case of this when upgrading our project but considering the number of issues I had to resolve there is a good chance I just mixed up line numbers on a ToComponentDataArray.
     
    cort_of_unity and bb8_1 like this.
  35. peaj_metric

    peaj_metric

    Joined:
    Sep 15, 2014
    Posts:
    146
    Just found another difference that is not mentioned in the upgrading docs:
    Entity command buffers methods dont accept queries anymore.
    They have to be replaced with their new ForEntityQuery equivalent:

    AddComponent => AddComponentForEntityQuery
    DestroyEntities => DestroyEntitiesForEntityQuery
    ...
     
    bb8_1 likes this.
  36. Mockarutan

    Mockarutan

    Joined:
    May 22, 2011
    Posts:
    158
    The fact that your own partial systems (with own code gen) break with this code gen is a big deal for me. I get the following types of errors:

    Code (CSharp):
    1. CommandSerializer.cs(51,33): error CS0111: Type 'CommandSerializer' already defines a member called 'OnCreateForCompiler' with the same parameter types
    (There is no OnCreateForCompiler in my code gen)

    Code (CSharp):
    1. CommandSerializer_Gen.cs(553,22): error CS0759: No defining declaration found for implementing declaration of partial method 'CommandSerializer.__DeserializeCommands_Gen_2035150B(ref NativeNetBuffer, ulong)'
    (A partial method that has nothing to do with my generated CommandSerializer_Gen.cs)

    I'm not sure exactly what happens, but it does not seem fixable without removing my or Unity's code gen.
    Is there a plan to make this work or should I re implement my code gen utilizing IJobEntityBatch instead?
     
  37. Zec_

    Zec_

    Joined:
    Feb 9, 2017
    Posts:
    148
    Noteworthy is that these work differently than the old ones. Here's the mention from the Added Section in the Change Log for Entities 0.18:
    EntityCommandBuffer methods for managed components that perform a query at record time (instead of at playback time): AddComponentObjectForEntityQuery and SetComponentObjectForEntityQuery.


    Edit: Here's a second mention of it under the "Deprecated Section":
    The EntityCommandBuffer methods which perform an EntityQuery at playback are now deprecated. Instead use the methods whose names end with "ForEntityQuery". These "ForEntityQuery" methods perform the query at 'record time' (when the method is called).
     
  38. peaj_metric

    peaj_metric

    Joined:
    Sep 15, 2014
    Posts:
    146
    Just hit that issue too. Funny thing is it works if you wrap the Set/GetSingleton call in another method called by the property:

    Code (CSharp):
    1. public CompType MySingleton => GetMySingleton();
    2.  
    3. private CompType GetMySingleton()
    4. {
    5.     return GetSingleton<CompType>();
    6. }
    In the case of GetSingleton it is also possible to use TryGetSingleton which does not cause the same issue
     
  39. DreamersINC

    DreamersINC

    Joined:
    Mar 4, 2015
    Posts:
    131
    I thought I was going crazy for a bit. Just figured how this bug.
    Instantiating a GO at runtime with convert and inject creates clones of all clone of gameobject that were converted injected at the start of play. Appears to be an editor only issue. Based on the lack of artifacts and visual glitching in my builds vs editor
     
  40. peaj_metric

    peaj_metric

    Joined:
    Sep 15, 2014
    Posts:
    146
    You mean it creates clones visible in the hierarchy? Because its supposed to clone all the companion objects if you instantiate the entity.
    But I figured there is a bug that the gameObjects dont get moved into the companion object scene and hidden in hierarchy like they are in all other conversion cases (which makes them visible and persistent in the current scene hierarchy)

    CompanionGameObjectUtility.MoveToCompanionScene is not called in this case.
    I currently use a workaround by calling it manually on runtime instantantiated entities which was tricky though as its internal.
     
  41. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    880
    Did you find a solution for this problem? I have it too.
     
  42. DreamersINC

    DreamersINC

    Joined:
    Mar 4, 2015
    Posts:
    131

    Correct clones are visible and selectable in the hierarchy. Drove me crazy for a couple of days cuz I thought the light mapping system was broken until I realized that all the game objects were clones. Then I thought I had a script running wild.
     
  43. peaj_metric

    peaj_metric

    Joined:
    Sep 15, 2014
    Posts:
    146
    Yeah from the code it looks like they just forgot to execute CompanionGameObjectUtility.MoveToCompanionScene when runtime instancing entities.
     
  44. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    880
    Also we could not use ecb.***ForEntityQuery in jobs? Or this is source generation problem?

    Code (CSharp):
    1. ...
    2. var ecb = beginSim.CreateCommandBuffer();
    3.  
    4. Job.WithCode(() => {
    5.     ecb.RemoveComponentForEntityQuery<DelayedDisableTag>(removeQuery);
    6. }).Schedule();
    7. ...
    8.  
    InvalidOperationException: DelayedDisableSystem_LambdaJob_1_Job.removeQuery.__impl uses unsafe Pointers which is not allowed. Unsafe Pointers can lead to crashes and no safety against race conditions can be provided.
     
  45. DreamersINC

    DreamersINC

    Joined:
    Mar 4, 2015
    Posts:
    131
    Fun part is that it compiles and run properly in build
     
  46. mk1987

    mk1987

    Joined:
    Mar 18, 2019
    Posts:
    53
    I did a few weeks ago yes, i think it was because i had Onstartrunning() and OnCreate() in system base. I reduced it to just on start running as it was contradicting itself (no idea why i had this in the first place!). I also added this.register[hysicsruntimesystemreadonly() as i was also using PhysicsVelocity i think.

    I also added each lambda function to the dependency and wrote this.completedependency() where it wasnt working but that was first thing i did and i dont think it did anything (just never bothered to undo it..). No errors anymore but pretty sure its just the the first or second thing i needed to do. The dependency stuff i think is not needed. When i optimise the code i'll work out which bits i actually need but its fast and working so not planning to mess around with it at moment. Let me know if any of that helps!
     
  47. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    880
    Thanks for advise! Turns out the problem in my case was in Ecb.*ForEntityQuery(eq). Here I am describing the issue and solution: https://forum.unity.com/threads/issues-after-update-to-0-50.1270577/#post-8069996
     
  48. joepl

    joepl

    Unity Technologies

    Joined:
    Jul 6, 2017
    Posts:
    87
    Hello there, a number of the above issues were fixed in the recent 0.50.1 release:

    4. Nested [Set|Get]Components are broken in codegen
    5. Systems inside systems don't work with code gen
    8. GetSingleton fails code gen for some reason in a property
    9. query.ToComponentDataArray need to call query.CompleteDependency() to be safe

    I'll make sure we have bugs filed for the other issues as well. Thanks!
     
  49. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    Thans i'll update the thread to avoid confusion for any future readers.
     
    bb8_1 likes this.
  50. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,113
    @joepl Just curious. Will 0.51 release have any more improvement or new feature?
     
    bb8_1 likes this.