#archived-dots

1 messages · Page 133 of 1

warped trail
#

or 1/4 of a Hz

mint iron
#

i don't know what you mean

warped trail
#

operation per clock🤔

#

just forget it😔

mint iron
gusty comet
#

Hola. Anyone here experienced that a subscene simply doesn't show up in an iOS build?

#

I have an extremely simple test scene with a bouncing sphere and a cube, which worked fine on iOS with dots physics when I just used convertToEntity, but when I converted to subscene and removed the convert stuff, it works in the editor but they don't show up in the iOS build anymore

gusty comet
#

There's a console error in XCode which indicates that it's a serialisation issue

#

Coming from Unity.Entities.Serialization.StreamBinaryReader.ReadBytes

warped trail
#

are you building with new build tools?🤔

gusty comet
#

hmm no, although I'm not quite sure what you mean

#

I'm using 2019.3.7f1, and all the packages are up to date

#

I'm using Xcode 11.3 beta, I don't know if that could be a problem?

#

I recall having this same problem a while back when I did another quick dots test for ios

#

where anything that was converted to a subscene would not show up in the build

gusty comet
#

Yeah, looking more at the xcode logs, it can't load the files

#

"Can't open file" for the subscene

cosmic sentinel
#

How can I debug this issue where 2 iterations of the job take a lot longer than the other iterations?

#

The others take ~0.5ms, and the worst takes 20ms

opaque ledge
#

@cosmic sentinel it might be waiting for some other job to finish perhaps ?

wide fiber
#

@gusty comet subscenes are broken in builds, they are bugged

warped trail
#

for subscene you have to use new build tools

hollow sorrel
#

isn't that the old new build tools

warped trail
#

new new build tools are code only?🤔

hollow sorrel
#

i think so yea

#
## Deprecated
- Class `BuildPipeline` is now obsolete. It has been replaced by `BuildPipelineBase` which is no longer asset based. All build pipeline assets must be converted into a corresponding build pipeline class that derives from `BuildPipelineBase`.
bright sentinel
#

Oh huh

gusty comet
#

@wide fiber ok, thanks!

#

@warped trail wow, I honestly didn't even know about this. Where can I get it? Is it a package?

warped trail
#

i just copied mine from ecs samples😅

gusty comet
#

Ah, I see. You just downloaded the build configuration files from the ecs samples?

#

or do you mean this "SubsceneWithBUildConfigurations" stuff?

gusty comet
#

Wow, changing to a custom build configuration with the OSX hybrid pipeline did the trick!

junior fjord
#

is anyone using the 2d entities package? I wanted to use it for ludum dare but now I saw it depends only on entities 0.5.1 which is pretty outdated?

#

so do I understand it right that 2d entities gives me 2d-dots rendering + 2d dots physics but outdated entities package?

wary anchor
#

I currently have a bunch of persistent NativeArrays and other collections which are used by various systems throughout my game. They are generated in a System and made publicly accessible from there, which feels icky.

What would be a more suitable data container for a bunch of Persistent NativeCollections (which need to be recalculated every cycle of game-end-load)?

opaque ledge
#

you could go for Shared Statics, they are basically 'Global' fields that can be accessed from both ECS and MB

#

but its important that you initialize those fields before accessing them for obvious reasons

#

also it only works for struct types, so no managed stuff

#

you can put your native collections in there

wary anchor
#

Not heard of shared statics, are they relatively new in ECS? I do try to avoid static in general, but would be good to read up more on this

opaque ledge
#

static is just name, you can manipulate it during runtime

#

and no, it was around for a while

#

it might be confusing at first but its easy, its just copy paste xD

warped trail
#

you are basically doing what physics doing😅

wary anchor
#

Are there any other ways that people are making this sort of data available within their project?
I'm not sure I understand what difference it would make eg storing the data on a system vs a sharedstatic from an organisational perspective

#

Let me rephrase, I definitely don't understand the differences between storing the reference to a NativeCollection within a system versus a SharedStatic (which is after all listed in the Advanced Usages - this can't be how Unity envisages this type of data being accessed surely?

opaque ledge
#

i mean.. if your data 'naturally' belongs to a system then go for your way, but if its global i rather use Shared Static

#

you said it feels icky so i simply suggested there is an another way of doing, your call if you want to do it or not

warped trail
#

@wary anchor follow examples of smart guys😅

#

wrap your native arrays in some struct and expose some job handles

#

like Unity physics

wary anchor
#

I appreciate the advice, sorry I didn't type my intentions clearly - I'm trying to learn not dig my heels in! :)

and the class that it's stored in, they have an abstract basic class in that example that kinda creates itself? I don't understand what it's doing

opaque ledge
#

well, i myself am not smart enough to know how things shared static works, i only know it works which is all i need 😄

#

This article is for explanition of shared statics, if you are interested

wary anchor
#

thanks again, you're right it does make sense to have those data off the system. I'll copy/paste and play a bit to try to wrap my head around it 😄

#

definitely interested, thank you, yes JDs articles are awesome, not seen this one yet

junior fjord
#

@wary anchor the sharedstatic stuff works by hashing the abstract class and the member field you pass. With that hash it requests some memory. Therefore you have the GetAndCreate method (you can get the same memory location again at a later point in case you don't store it)

#

I don't really understand the logic behind being able to have this Get method and get the same memory location again, since after you got it, you can just store it somewhere. But maybe it has something to do with unity having to be able to access this from managed and unmanaged (so they can get the same memory location twice)

cosmic sentinel
#

Can some things force a ScheduleParallel to be processed as a single job?

#

have a job that takes the same amount of time for 10 entities in parallel as it takes to run them all in a single job (~180ms). when I do ScheduleParallel it starts the 10 jobs but all but one complete in 0.5ms but one takes 180ms (same as single)

warped trail
#

Schedule()

cosmic sentinel
warped trail
#

what this special job is doing? 😅

cosmic sentinel
#

a fair bit

warped trail
#

oh, i misunderstood your question 😅

cosmic sentinel
#

sorry, probably didn't explain it very well

#

but I'm pretty sure something is causing the jobs to be stalled by one job (or all jobs to be processed as one after some point)

bright sentinel
#

Maybe you have some weird logic with your jobs all writing to the same nativearray, but they somehow depend on each other? 🤔

cosmic sentinel
#

yeah, used to work ok. I'll just have to start going back in history to track down what it is

#

git bisect time

#

alright. that's very confusing. turns out it's an EntityQuery in a different system that is causing it to stall

#
        {
            All = new ComponentType[] { ComponentType.ReadOnly<Tags.Building>(), ComponentType.ReadOnly<GridPosition>() },
            Any = new ComponentType[] { ComponentType.ReadOnly<Tags.Dead>(), ComponentType.ReadOnly<Tags.Created>() }
        });
        RequireForUpdate(buildingQuery);```
#

which is created in OnCreate in a different system

#

and they don't really have anything to do with each other

#

oh. I think it might be the JIT burst compiler that is confusing me

#

yeah, if I set it to synchronous it spends most of that time compiling

bright sentinel
#

Seriously sounds like a bug 🤔

dark mauve
#

Hi there.
I was wondering if anyone here could offer me some help.
I'm trying to create an inventory system using Entities and the Job system. The entity and job systems are quite new to me, but I understand the basics. It's just a bit difficult for me to understand how to properly handle making this all use the ECS, since I have to use blittable types everywhere and some things I need (such as Texture2D for inventory image, and a List to store the inventory slots) are unavailable.

#

I hope this is the right place to ask this by the way. If it isn't, feel free to point me elsewhere 🙂

opaque ledge
#

You can use Dynamic Buffer as your inventory slots, as for item images you can always make class IComponent data and put your Texture2D there, only thing you have to be aware of you simply need to run the system on main thread if you are dealing with class components.

dark mauve
#

I'll have a look at Dynamic Buffers. Thanks! For the other thing, the issue is that as soon as I added Texture2D to a class as variable, it told me I can't use the class, because it's not blittable anymore.

warped trail
#

use class IComponentData instead of struct 😅

opaque ledge
#

instead of "struct ComponentA : IComponentData" you do "class ComponentA : IComponentData"

dark mauve
#

Ah I see

#

I was using ScriptableObjects for the item types, but I imagine I can't use those anymore then

#

Using both ScriptableObject and IComponentData as parent classes didn't work

cerulean pumice
#

Is there a way to include burst compiled code with an assembly that is loaded at runtime?

stone osprey
#

Is a bufferelementdata allowed to store unity references like gameobjects ?

opaque ledge
#

no

#

@stone osprey

#

@cerulean pumice what do you mean by include ?

stone osprey
#

Damn... so theres no mix between sharedelement & bufferelement ?

opaque ledge
#

you can inspect the code burst generates

#

i mean if you make it class then you can store references 😄

#

but otherwise no

cerulean pumice
#

My understanding is that all burstcompiled code is stored in another assembly at build time.

opaque ledge
#

i never did anything with shared components so i cannot say

#

oh i dont know about that Rein, sorry, maybe someone with more experience can help

cerulean pumice
#

So say I had another assembly that I was loading as a dependency at runtime, could that assembly provide burst compiled code to use.

dark mauve
#

I'm gettingInvalidOperationException: InventoryData used in NativeArray<InventoryData> must be unmanaged (contain no managed types) and cannot itself be a native container type. Unity.Collections.NativeArray`1[T].IsUnmanagedAndThrow () (at <05f2ac9c8847426992765a22ef6d94ca>:0)when trying to use DynamicBuffer instead of a List for the inventory slots

mint iron
#

NativeArray and DynamicBuffer have a struct constraint

dark mauve
#

What constraint do you mean?

mint iron
#

on T

dark mauve
#

The struct I'm using is very simple

#

Only 2 int variables

mint iron
#

InventoryData is a struct ?

dark mauve
#

InventoryData is the object with the DynamicBuffer

#

The buffer is of type ItemObject (a struct with 2 int variables)

mint iron
#

can you post some code, something doesn't add up because its trying to put an object in a NativeArray which isnt going to work.

dark mauve
#
public struct InventoryData : IComponentData
{
    public DynamicBuffer<ItemObject> m_InventorySlots;

}```
#

This is the InventoryData struct

warped trail
#

you can't do this😅

dark mauve
#
{
    int m_Count;
    int m_MaxStack;
}```
#

This is the ItemObject struct

warped trail
#

i guess you have to read docs first 😅

mint iron
#

hes saying you cant put a DynamicBuffer in a component like that

dark mauve
#

I'm trying to figure it out, but even with the docs I'm having difficulty wrapping my head around it. I'm completely new to DOTS and I have an assigment I have to finish in way too little time. Would be easy getting this to work without DOTS but alas that's not what I have to do

mint iron
#

a DynamicBuffer is an alternative to a component, so you use EntityManager.AddBuffer() instead of EntityManager.AddComponent()

#

in general, you can't put a list of things inside a component.

dark mauve
#

Ehhh. I'm not even using AddComponent right now. I've just attached the InventoryDataAuthoring script to the object that needs the inventory and tried to get some basic code running using the job system

#

What would you suggest me to do for this? I need to somehow store a list/array of those the inventory slots.

#

Then all I'd need to do is read the items in that list/array and alter their values to change the proper items. It's just that I'm getting stuck at getting any kind of list in the ECS

mint iron
#

ItemObject is an inventory slot ?

dark mauve
#

Yeah

#

It's basically <amount> of <type> item

#

At first I used GeneratedObjects for the type, but that wasn't supported for this either so I decided to just copy the values in there and transfer them over manually each time the item type changes.

mint iron
#

you could create a system that makes an entity, and add to the entity a DynamicBuffer of Inventory slots

stone osprey
#

@dark mauve Probably the "Prototype"-Pattern could help you out... everytime you "clone" a item, you customize that item after on with the certain unity data and store the references in a sharedComponentData

#

This is my system

mint iron
#

another option is to have a seperate entity+component for each inventory slot

dark mauve
#

Yeah that's what I was kinda worried about at first, but then again I only need the player to start with an empty inventory and then I need to be able to add and remove items to this inventory.

#

That's also a good idea

#

I'm just not sure where to begin with this all. It's really overwhelming me and the tutorials I find are usually making me more confused than I already was. Also a lot of them are a bit old and so much has changed to Entities since then.

#

I'm not sure what that is genar. I'll have a look. Basically the only limitation I got was that I have to avoid MonoBehaviors wherever possible

#

Thank you both a lot for your help btw

stone osprey
#

@dark mauve Using this for my little mmorpg... its quite usefull 🙂

#

Otherwhise

#

what does this mean "InvalidProgramException: Invalid IL code in Script.Client.Environment.Entitys.Systems.AnimationSystem/Script.Client.Environment.Entitys.Systems.<>c__DisplayClass_OnUpdate_LambdaJob0:OriginalLambdaBody (Script.Client.Environment.Entitys.Components.AnimatorComponent&): IL_00ae: endfinally
"

#

?

mint iron
#

id suggest, just to see something working,

  • Create a SubScene and put a few GameObjects in it, each represents a different ItemObject
  • Create an authoring component to hold the max and count fields, add it to each GO.
  • Press play and view the entities in EntityDebugger.
dull copper
dark mauve
#

Thanks @mint iron , I think you've just given me an idea 🙂

dull copper
#

"Update to latest dots multiple-subscene-instances branch "

warped trail
#

@dull copper yeah, we will get some new subscene tools in next release😅

dull copper
#

I guess that's some internal dots dev thing

#

is it confirmed?

#

I mean they are cooking something obviously

warped trail
#
* We are adding the ability to load & offset entity scenes (By letting users modify the loading staging world, before it is moved to the simulation world)
* We are adding the ability to load the same entity scene multiple times (Each one offset differently)
* We are adding the ability to generate meta data from the scene that can be used during placement

I expect those will land in a release in a couple of weeks in dots.```
#

from Joachim_Ante

mint iron
#

interesting, what would the usecase be for loading the same subscene multiple times?

warped trail
#

subscene as a prefab😅

#

are we gonna get some subscene documentation or not? 😅

dull copper
#

@mint iron I could see that useful for populating procedural worlds

#

could reuse some subscenes here and there

zenith wyvern
#

Dang I'm working on my dumb minecraft clone right now, this sounds like it would be pretty useful

#

Having to manually set up generated chunks is really awkward and annoying

dull copper
#

I mean the subscene doen't have to be big even

#

I'm happy they are improving this but it'll not benefit me at all atm 😄

#

my two main annoyances on dots are a) tooling / conversion setup b) subscenes breaking everything for me

#

oh wait, that dungeon example does that specifically

#

I just now read the thread

#
We are working on a sample where we do procedural dungeon generation.

Our approach is:
* A dungeon tile is an entity scene
* A procedural generator high level streaming rig (User code) has a list of SceneAsset references that define the possible tiles stored in a scriptable object.

At load time the scriptable objects defines all possible scenes, we load the meta data of each scene. (Eg. what connectivity of tiles do we have) Based on that it determines the placement of every possible tile in the world. Each represented by an entity representing the scene.

Then it uses normal streaming functionality to load the data. Eg. some scene sections are always loaded, other scene sections are loaded on demand based on distance.```
warped trail
#

good that i know something about scene sections from Unite Japan 😅

mint iron
#

SceneAsset references that define the possible tiles stored in a scriptable object. thats interesting, so they'll leverage SOs for the scene configuration (and so it can be edited/loaded with normal Asset management/importing systems). Presumably they also need to seperately make sure the referenced SceneAssets are loaded.

#

the rest sounds like standard dungeon tile gen, in Diablo3 all the scene tiles have exit/connector count meta and can have holes in them, that can then be filled with sub-tiles, so you get the double dynamicness of different outer environments, with switchable features inside them. its pretty cool.

vagrant surge
#

thats pretty interesting

fallow mason
#

the procedural dungeon sample? or entity scenes in general?

opaque ledge
#

Topher is our god basically

fallow mason
#

cool, looks very interesting

warped trail
#

what about documentation? 😅

fallow mason
#

who needs documentation when we've got sample projects?

#

I am a little disappointed to see samples still using JobComponentSystem.

dull copper
#

feels like the sample repo prio has dropped dramatically now

#

in past there was update always after new entities package or physics package

#

I'm guessing the samples are getting redone again in the future(?)

#

oh, so it's just not pushed to us? :/

safe lintel
#

Can you pester whoever is in charge of the animation samples repo too?

#

I have no idea how it works internally 😀

dark mauve
#

Making some progress. My next challenge is something I can't find anywhere online about.
I need to have a reference to a GameObject in an entity, so the entity can say "gameobject->dothis". The reason I need this in a gameobject is that it's for UI and UI entities aren't really a thing.
I know how to reference to an entity from a gameobject, but I need it the other way around. Any tips?

vagrant surge
#

@dark mauve look up class IComponentData

#

those are a lot slower and more limited than normal components, but they are "normal" C# classes, and as such, can call normal C# stuff

dark mauve
#

@vagrant surge I was using them, but they can't have a GameObject reference, because that's not blittable. Or am I doing something else wrong?

frosty siren
#

have we today a way to have presets of IComponentData with values?

#

something like scriptableObject but in dots world

vagrant surge
#

@dark mauve normal icomponent data (struct) are the blittable ones

#

class icomponent data re normal C# classes

dark mauve
#

oooh same name but class instead of struct

#

I see

frosty siren
#

or a way to get all types from entity

dark mauve
#

Using the class gives me Entities.ForEach uses managed IComponentData ItemObject&. This is only supported when using .WithoutBurst() and .Run()

#

About this line

warped trail
#

use .WithoutBurst() and .Run()😅

dark mauve
#

That's what I tried, but it doesn't recognise Run() at all

#

and just WithoutBurst doesn't fix it

bright sentinel
#

You should use SystemBase instead of JobComponentBase

bold pebble
#

Hi. Is it somehow possible to reference a (fixed size) list/array of Entity inside a IComponentData struct?

dark mauve
#

@bright sentinel where? I'm not using JobComponentBase anywhere

#
{
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        float deltaTime = Time.DeltaTime;

        JobHandle jobHandle = Entities.ForEach((ref ItemObject item) =>
        {}).Schedule(inputDeps);

        return jobHandle;
    }
}```
#

This is the full class

bright sentinel
#

@bold pebble Yes, you can use a FixedList<T> or FixedArray<T>

#

@dark mauve Sorry, I meant JobComponentSystem

#

It was introduced in 0.8 I believe, and replaces ComponentSystem and JobComponentSystem

dark mauve
#

Will it still use the job system if I change that though? Part of the assignment is that it must use the job component system

warped trail
#

something like this i guess```cs
public class ItemSystem : SystemBase
{
protected override void OnUpdate()
{
float deltaTime = Time.DeltaTime;

    Entities
    .WithoutBurst()
    .ForEach((ref ItemObject item) =>
    {}).Run();
}

}```

bright sentinel
#

Well, it's pretty much the same functionality, just combines ComponentSystem and JobComponentSystem

bold pebble
#

@bright sentinel What package/version do I find those types in?

bright sentinel
#

Will def use the job system

warped trail
#

and i think without ref when working with classes🤔

bright sentinel
#

@bold pebble It's either in Collections or Entities, not sure which version though

#

Shouldn't be too new

dark mauve
#

Thanks a lot then 🙂

bright sentinel
#

@bold pebble It was introduced in Collections 0.4 I guess

gentle osprey
#

Somewhat related to sjoerdtim's question. What's the "replacement" in SystemBase for "returning" the job dependencies?

        var buffer = mCommandBufferSystem.CreateCommandBuffer().ToConcurrent();
        var randomizer = mRandomizer;
        Entities
            .WithNone<THidden>()
            .WithAll<SMeshID>()
            .ForEach((Entity e, int entityInQueryIndex) =>
            {
                if (randomizer.NextInt(0, 2) < 1)
                    buffer.AddComponent(entityInQueryIndex, e, new THidden { });
            })
            .WithName("HideObjects")
            .ScheduleParallel();

        var buffer2 = mCommandBufferSystem.CreateCommandBuffer().ToConcurrent();
        Entities
            .WithAll<THidden>()
            .ForEach((Entity e, int entityInQueryIndex) =>
            {
                if (randomizer.NextInt(0, 2) < 1)
                    buffer2.RemoveComponent<THidden>(entityInQueryIndex, e);
            })
            .WithName("ShowObjects")
            .ScheduleParallel();
#

That blows up in my face with: The previously scheduled job RandomHideAndShowSystem:<>c__DisplayClass_HideObjects writes to the UNKNOWN_OBJECT_TYPE <>c__DisplayClass_HideObjects.JobData.buffer. You must call JobHandle.Complete() on the job RandomHideAndShowSystem:<>c__DisplayClass_HideObjects, before you can write to the UNKNOWN_OBJECT_TYPE safely.

#

With JobComponentSystem I would have returned inputDeps combined with the jobhandle for the two for each'es.

opaque ledge
#

Dependency property

zenith wyvern
#

Make sure you call AddJobHandleForProducer from the barrier system you produce your command buffer from. I think that's what that error is from @gentle osprey

opaque ledge
#

ScheduleParallel or Schedule basically is this: Dependency = foreach.Schedule(Dependency)

#

pinging doesnt work if you add it when you are editing your post Sark 😄

gentle osprey
#

That might be it @zenith wyvern cause i've messed that up before.

opaque ledge
#

at least not when i did it last time

zenith wyvern
#

From the code you showed you shouldn't need to write back to the Dependency jobhandle

#

It does it automatically

gentle osprey
#

But should it hten just be mCommandBufferSystem.AddJobHandleForProducer(Dependency);?

bold pebble
#

@bright sentinel Got it. Thanks. Is it somehow possible to assign entities to a FixedList32<Entity> via the authoring component?

zenith wyvern
#

But should it hten just be mCommandBufferSystem.AddJobHandleForProducer(Dependency);?
@gentle osprey
Yup

gentle osprey
#

Now it works wonders. Thanks :)

opaque ledge
#

is interface blittable 🤔

bright sentinel
#

@bold pebble Probably, you'd have to do that during the conversion. I haven't done something similar, so I can't tell you a solution for it though.

zenith wyvern
#

If you're storing an interface as a variable it's a reference type. But in Burst you can still use an interface type as a generic type constraint to get some interface-like behaviour @opaque ledge

opaque ledge
#

@zenith wyvern Can you give an example 👀 like, instead of a component type we do interface in foreach query ?

warped trail
#

@bold pebble i tried and it didn't work😅

zenith wyvern
#

@opaque ledge I haven't tried it but I think I read on the forums that generics aren't supported in Unity's ForEach code gen right now, and I don't know if they ever will be. But outside the ForEach you can do:

public void SomeFunctionCalledInBurst<T>(T aStructImplementingMyInterface) where T : IMyInterfaceType
{
   aStructImplementingMyInterface.someFunc();
}
opaque ledge
#

👍

stone osprey
#

Can we use "Adressables" inside of unity job systems ?

#

Once i try to load a adressable inside a foreach query i get weird errors

#

Entities.ForEach(); / Adressables.LoadAssetAsync<>() | invalid il error

zenith wyvern
#

You can't use it inside jobs. You need to retrieve whatever you're retrieving on the main thread then pass it in.

stone osprey
#

@zenith wyvern So i also cant use it in a Entities.ForEach() lambda ?

#

Even when "WithoutBurst().Run()" selected ?

zenith wyvern
#

You can't use it in a job or with Burst. So yes you can use it if you run on the main thread and disable burst.

stone osprey
#

@zenith wyvern Hmm... Are you familiar with Adressables at all ? I did exactly what you meant, regarding the main thread... but i get a "IL Invalid Program Execution" every freaking time this system tries to run on the main thread

mint iron
stone osprey
#

InvalidProgramException: Invalid IL code

zenith wyvern
#

I'm not that familiar with addressables, I'm guessing Unity would qualify that as a bug though since that error message is entirely unhelpful. Maybe the code gen doesn't like trying to spawn threads inside a ForEach or something. Can you force the loading to happen on the main thread instead of trying to run it async inside the ForEach? @stone osprey

#

@stone osprey Does it not even compile, or does the error happen at runtime?

stone osprey
#

@zenith wyvern I had that "Adressables.LoadAssetAsync" in the main thread before... that worked... but due to the data oriented part i wanted to put it into a system... im gonna try if it works outside the ForEach loop in the OnUpdate method of the system 🙂 The error happens at runtime, i cant even debug that code... but without the Adressables.LoadAssetAsync it works fine

dark mauve
#

Another question from me 😅 is there a way to make sure some objects don’t get converted to entities? Once I run the game the camera, map, and UI become entities and are no longer to be seen anywhere.

formal scaffold
#

@stone osprey is more support for animation out or did you write your own? Are you following a tutorial? Sorry if I can't help you but in about 2-3 Weeks I want to start working on animations aswell.

Also, can an entity have multiple buffers?

dark mauve
#

I also thought that when you close a subscene you’d still be able to see the objects, but they go completely invisible for me

zenith wyvern
#

I would suggest you make a bug report or post the problem on the forums @stone osprey. I'm not familiar enough with addressables to know how it might interact with the code gen. You could also check the Burst inspector to see if the generated code gives you any hints:

opaque ledge
#

@dark mauve you have to do convert and inject for those since they have no representation of those in ECS

#

that or dont convert them at all and do interaction from MB

dark mauve
#

What if I don’t want some objects to convert?

#

Like the UI

#

I want them to stay as gameobjects

opaque ledge
#

then dont convert 😄

dark mauve
#

They seem to convert even if I don’t tell them to

#

That’s the issue

bright sentinel
#

Don't make the UI in a subscene

opaque ledge
#

remove the convert script

dark mauve
#

Don’t have a convert script for them, but the subscene is probs the issue then

opaque ledge
#

oooh, you are using subscene ? yeah you have to get them out of there

#

Subscenes are dangerous places 👀

bright sentinel
#

They're the future 😄

zenith wyvern
#

Wasn't there a way to see the regular C# code from the generated ForEach?

dark mauve
#

So subscene objects are always entities?

zenith wyvern
#

Instead of just assembly

bright sentinel
#

Yes

dark mauve
#

And outside of subscene they only become entities when I use the convert script?

bright sentinel
#

Yep

opaque ledge
#

yep basically, they are 'scenes' for pure ECS stuff

dark mauve
#

Ah great, thanks a lot

bright sentinel
#

@opaque ledge They literally are scenes though

#

Saved as a .unity file

dark mauve
#

I really hope you guys don’t mind me asking so many questions btw

#

I feel a bit uncomfortable about it as I don’t want to waste people’s time

bright sentinel
#

That's what the channel is here for

#

Don't worry 🙂

#

If we were annoyed, we could just get out of here

dark mauve
#

👍🏼🙂 thanks

opaque ledge
#

oh dw, i did lots of asking back in few months 😄

stone osprey
#

@zenith wyvern Thanks im gonna do that !

bright sentinel
#

Yep, when I started work I had 3 messages each day in our 'getting-started' slack channel, 3 of them would usually be consecutive messages in that channel

stone osprey
#

Oh... how do you use EntityQueries in Systems ? Its telling me that my entity query has already been disposed... I dispose it on the end of the OnUpdate method

bright sentinel
#

You shouldn't dispose it 🤔

#

Just create it in OnCreate

#

Unless you dispose of the whole system, then it might be good practice to dispose everything in the system as well

#

If you want the system to only run when that query is met, you can also use RequireForUpdate(EntityQuery) in the OnCreate function

dark mauve
#

Hm so how do I handle this with a camera on a player? Obviously I want the player to be an entity, but the camera as an entity doesn’t seem to work

coarse turtle
#

ConvertAndInject the camera as far as I know

dark mauve
#

Will give that a shot

#

Thanks

mint iron
#

does anyone happen to know if the presence of hybrid components on your entities impacts the performance when using just the other (blittable) components?

stone osprey
#

@bright sentinel Thanks ! So i created in OnCreate a query and for looping over it i convert it to a array... but once i run that system it tells me "A Native Collection has not been disposed"... any idea why ?

warped trail
#

why are you iterating manually? 🤔

opaque ledge
#

tbh it shouldnt, since referenced objects doesnt live on chunks

stone osprey
#

@warped trail How else should i iterate over a entity query ? I cant use Entities.ForEach for my current test... because Adressables causes crash... so i need another way to loop over a set of components

warped trail
#

oh😅

stone osprey
#

Tells me that it "should" get disposed on line one inside the pic

#

So the query should get disposed... but that does not make sense

#

A Native Collection has not been disposed, resulting in a memory leak. Allocated from:

opaque ledge
#

perhaps try async version of toEntityArray

#

then use the jobhandle for dispose

warped trail
#

he is not doing any multithreaded thing here 😅

opaque ledge
#

right 😄

stone osprey
#

The System derives from Systembase... but ^ are right, im not doing anything multithread related with that query

#

Damn that fucks me up... no one ever used such a query inside a system ? I cant be the only one with that dispose exception, right ? :/

warped trail
#

you are disposing of entitys, what Native stuff do you have there other than entitys? 🤔

stone osprey
#

@warped trail What exactly do you mean ? ^^ Thats the only native array in this system...

#

So tried out the job handle... nope, same exception

#

Still tells me that the "var entities = ...ToEntityArray" should get disposed

#

A Native Collection has not been disposed, resulting in a memory leak. Allocated from:
Unity.Collections.NativeArray`1:.ctor(Int32, Allocator, NativeArrayOptions)
Unity.Entities.ChunkIterationUtility:CreateEntityArray(UnsafeMatchingArchetypePtrList, Allocator, ArchetypeChunkEntityType, EntityQuery, EntityQueryFilter&, JobHandle&, JobHandle) (at Packages\com.unity.entities@0.8.0-preview.8\Unity.Entities\Iterators\ChunkIterationUtility.cs:152)
Unity.Entities.EntityQuery:ToEntityArrayAsync(Allocator, JobHandle&) (at Packages\com.unity.entities@0.8.0-preview.8\Unity.Entities\Iterators\EntityQuery.cs:623)
Script.Client.Environment.Entitys.Systems.AnimationSystem:OnUpdate() (at Assets\Script\Client\Environment\Entitys\Systems\AnimationSystem.cs:31)

mint iron
#

i've had that exception before, but i cant remember how i fixed it 😛 /helpful

safe lintel
#

maybe use Dependency as your jobhandle because that jobhandle doesnt refer to anything(if this is systembase)?

bold pebble
#

How can I add something to a FixedList32<Entity> which is part of an IComponentData from inside a (bursted) job?

stone osprey
#

@mint iron Please try to remember 😉 Where did you created that query ? Where did you converted it to an array ? xD

mint iron
#

@bold pebble use .Add() or the array indexer ref access (arr[i].prop = whatever)

warped trail
#

wait a minute, what about those returns? 😅

#

if you return form Update you are not disposing of array

bold pebble
#

@mint iron: I am trying to do that but somehow the list stays empty.

stone osprey
#

@warped trail Wait... you are probably a genius

warped trail
#

i guess you have to use continue there😅

bold pebble
#

break

warped trail
#

you got the idea 😋

mint iron
#

haha, yes, that jogs my memory

bold pebble
#

well probably still continue, but the current logic is equivalent to break

mint iron
#

@bold pebble the collection source looks fine, are you trying to add it to a copy of the struct rather than using the ref'd one directly

stone osprey
#

@warped trail You are the best, thanks ! That solved my issue ! I converted that from Entities.ForEach where i used the return because we cannot use continue or break in there... totally forget that 😄

mint iron
#

we should put a document together 'if the exception says this, this is probably what you're doing wrong'

stone osprey
#

Ok that works fine... so if someone should ever use "Adressables"... dont do that in Entities.ForEach loops... its not gonna work rn

bold pebble
#

(I added line 16 for testing but that didn't help)

warped trail
#

wait a minute, ship is just a copy😅

bold pebble
#

Ah I see. Beacause it's readOnly?

warped trail
#

you have to do something like thiscs shipGetter[registerAtParent.Target] = ship

#

you get a copy of component with thiscs var ship = shipGetter[registerAtParent.Target];

#

if you want to change it, you have to assign it back😅

bold pebble
#

Ah I see. But now I run into the readOnly problem

warped trail
#

you have command buffer there😅

stone osprey
#

Thats also interessting... i just replaced my entityquery with a "entityManager.GetAllSharedUnqiqueComponents" and its 10 times faster...

bold pebble
#

@warped trail So you mean I can somehow use the command buffer to update the ship component?

warped trail
#

something like thiscs commandBuffer.SetComponent(registerAtParent.Target, ship)

#

but this change won't be immediate

#

or if you know for sure that you safe, you can disable restrictions and set it through cdfe🤔

#

and btw you can use GetComponent<T>(entity) inside foreach😅

#

less code

bold pebble
#

So I just tried that via the command buffer. This will however overwrite the component with each command and the list will then only contain the last component

#

Hm, but GetComponent is not available on JobComponentSystem

warped trail
#

oh, you are using outdated stuff 😏

bold pebble
#

Hm, that seems to be a recurring theme for me with DOTS ^^

warped trail
#

so you have a lot of entities, which writes to same place?

bold pebble
#

I have a Ship with 8 Thrusters which should register at the Ship (FixedList32) at startup.

#

Alternatively the Thrusters could also be assigned via the Authoring component but that would prevent addition/removal of Thrusters at runtime

#

Btw. JobComponentSystem is outdated? what should I use instead?

warped trail
#

SystemBase

bold pebble
#

Thanks. I will try to migrate everything then.

warped trail
#

just run this loop on a single thread, then you could just assign everything via cdfe😅

#

my naïve advice 😉

#

or use dynamic buffer🤔

bold pebble
#

I had a dynamic buffer before but tried to migrate to a fixed list

bold pebble
#

@warped trail I now run the thing single threaded and migrated to SystemBase. Is there still some unneeded/legacy stuff left now? 😄 https://pastebin.com/XEuxFjmJ

warped trail
#

you can use Schedule() 😅

#

it will run on different thread

bold pebble
#

I see. thanks. Btw. what is the difference between Schedule and Run then? I See there is also ScheduleParallel

warped trail
#

run mainthread, Schedule singlethread on worker thread, ScheduleParallel() as parallel as it can get 😅

bold pebble
#

Got it. thanks

#

The whole World.GetOrCreateSystem<BeginInitializationEntityCommandBufferSystem>(); then var commandBuffer = _entityCommandBufferSystem.CreateCommandBuffer(); and commandBuffer.RemoveComponent<RegisterAt>(entity); still feels a little bit verbose. Is there some shortcut like "PostUpdateCommands.RemoveComponent" or so?

warped trail
#

no

bold pebble
#

I see. It just felt like there should be a shorter way of telling ECS to globally remove all components of a certain type

warped trail
#

and how it should decide at what point in frame it should do it? 😅

bold pebble
#

It would be after the last system ran which depends on this Component (which would be only 1 in my case). Or even at the end of the update.

#

I also wouldn't mind calling a method at the end of my OnUpdate

#

Maybe it would also be possible to have "RunOnce" component which is removed by a dedicated system at the end of the frame

warped trail
#

you can do this yourself😄

bold pebble
#

Yes, but I'm still pondering on how to handle multiple types of "RunOnce" components.

gusty comet
#

Position and rotation are correct too. I checked it against the manually constructed entity I can already get to render, and my positioning system put it in the right place.

#

Actually... FrameDebugger is showing 1 vertex on the draw call. Yet the mesh is generated exactly as it is if I manually build the entity.

#

I swear, no step of anything is easy in Unity.

zenith wyvern
#

That's a weird way to convert a prefab. What does your entity debugger say? Does it show an entity with all the right components?

#

Sorry I saw you said that, what I mean is have you verified it in the entity debugger instead of just assuming?

gusty comet
#

I just figured it out. Up all night, and wouldn't you know, as soon as I verbalize the problem to someone else, BAM! I got it.

#

This is wrong:

quadMesh.triangles = new int[6];
#

This is right:

int[] tris = new int[6];
// do stuff to tris
quadMesh.triangles = tris;
#

Coming from a C++ background, I don't see the difference.

#

Also, it's weird because it's purely procedural 😄

zenith wyvern
#

Oh right, the getters for mesh properties return copies instead of returning the actual underlying arrays

#

I'm not sure your original code would have even compiled if they returned the underlying arrays

#

I guess it would have. But yeah that's more a quirk of how Unity chose to design their mesh properties. For whatever reason they chose to make them return copies.

gusty comet
#

How does assigning tris to the copy end up putting it in the underlying array though?

#

I'd expect it to get assigned to the copy, and happily continue on out of local scope, blinking the tris out of existence.

bright sentinel
#

It's some burst stuff

#

I remember seeing this in other places

zenith wyvern
#

The getter returns a copy, the setter assigns to the actual underlying array

gusty comet
#

(facepalm) I keep forgetting about C# getters and setters.

zenith wyvern
#

Like I said I have no idea why they chose to make it return a copy. I'm sure they have some good reason

gusty comet
#

Probably for some kind of memory safety reason.

zenith wyvern
#

Yeah properties are a constant source of annoyance when you're getting used to C#

#

Lots of hidden rules

gusty comet
#

Worth it though. Having stuff like Linq and managed memory without having to take it down to C is awesome.

zenith wyvern
#

Definitely. In this case having the same property return a copy and assign to the underlying array is not great design, but maybe it's a typical thing in C#

warped trail
#

awesome until you want performance 😋

zenith wyvern
#

Better to have two separate functions with clear naming

gusty comet
#

First test up, I'm seeing worse stability having V2 build the entity off a prefab. I can get to 38k entities, 2000 instantiations at a time, and then get a swapchain crash. Building entities manually, I can go 2000 at a time until 788k, and still don't get a crash. My processor just gets too bogged down.

#

Going to try taking it down to smaller batches. Maybe all those extra HDRP components are leading to more data sent to GPU.

#

500 at a time, it crashes sooner (17k instances)

#

5k at a time, 65k entities. So, we should instantiate as many as possible in one pass doing it this way. Exactly the opposite of building entities manually.

warped trail
#

i just instantiated 250k at once, no problem 😅

#

and default culling system is pretty good, if not borderline awesome🤔

gusty comet
#

Are you instantiating entities directly in a buffer, or instantiating prefabs?

warped trail
#

i instantiate via ecb in a single loop

#

simple prefab

zenith wyvern
#

You could probably get it even faster using a NativeArray. But presumably you have some setup to do for each entity

gusty comet
#

Okay, I'm messing up by doing it in a ECB then.

#

Naively, I'd think skipping the converter step would be more performant and stable (asking for less work to be done)

warped trail
#

you are not paying for conversion🤔

zenith wyvern
#

Conversion should happen in the editor or once when you hit play

warped trail
#

with subscene at least

zenith wyvern
#

The only cost should be Instantiate

#

Which should be very fast since the conversion should be done already

gusty comet
#

Hmm I'll show my spawner. 1 sec. I'm not keeping a game object around, so that might be my mistake.

#

Not using subscenes either, since it's all procedural.

zenith wyvern
#

For now I think the best way is to set up your entity prefab as a gameobject prefab and use conversion system to create your canonical "Prefab Entity"

#

It sucks but that seems to be the way they want us to do it

gusty comet
#

That has a test set up for 500k entities at 7k a pass (crash at 98k on my system)

#

I can't imagine why, except to keep us chained to the editor. Which kinda sucks if you want to make something like a ECS UI where the developer to use it should only see the result of editor field entries.

zenith wyvern
#

Conversion workflow is here to stay. If you avoid it you're going to be fighting their intended way to do things the whole way

gusty comet
#

Roger that. So, I better get used to it. This has been a learning experience though, so I wouldn't call it a waste.

zenith wyvern
#

I don't see anything unusual about your instantiation, it looks like you're not doing anything fancy

#

So not sure why there would be performance issues

gusty comet
#

But I'm instantiating entities directly. So, this isn't the wrong way?

zenith wyvern
#

If you need to make unique changes to each entity you are instantiating then what you're doing is the right way as far as i know

#

From what i can see you might be able to get away with a batch operation though

gusty comet
#

In my use case, I will need an arbitrary number of UI forms at runtime. Ideally in the end, they'll be on world canvases. So, yeah, they'll need further changes after instantiation. For now, I'm just trying to achieve what I've seen others can do, because I know I'm doing it right then.

zenith wyvern
#

There's a version of EntityManager.Instantiate that takes a NativeArray. You give it a prefab and a NativeArray<Entity> set to whatever size you want and it will fill it VERY quickly with copies of your prefab

gusty comet
#

When you say "prefab" in this case, this needs to be a GameObject native array?

zenith wyvern
#

No, entity prefab

gusty comet
#

Okay, I'll give that a shot. Time for coffee first though.

warped trail
#

just some entity, which you wish to copy😅

zenith wyvern
#

According to the API there is an overload that takes a GameObject prefab as well

gusty comet
#

Feels like I've been grinding at this milestone forever. By now, I thought I'd have moved a camera to ECS to sync camera with quad movement (weird jitters if you don't), and replicated rect-based UI stuff.

#

People who can estimate development time are wizards. Or prophets.

zenith wyvern
#

Heretics

gusty comet
#

😄

mint iron
#

can you still add entities to locked chunks?

zenith wyvern
#

Nope. No structural changes as far as I know. You can only change component data

mint iron
#

mmm, i see, they remove it from chunk->Archetype->EmptySlotTrackingRemoveChunk(chunk); on lock so it wont be picked up as a candidate with empty slots when adding entities.

#

for some reason i thought adding entities would be fine since its just adding more data and the archetype of the chunk doesn't change.

zenith wyvern
#

If it's locked they promise the order of entities won't change either

dull rune
#

Hi. I have a subscene with "auto load scene" checked in my scene. When I play in the editor it loads fine, but when I build the sub scene is not loaded. Do I need to manually load subscenes in a build regardless of the auto load flag, or is there something else I am missing here?

warped trail
#

how you build your game? 😅

dull rune
#

just playing around to understand how to work with subscenes right now. I just have one scene that I build which has this subscene in it

warped trail
#

i mean which tools are you using to build🤔

#

with subscene you have to use new build tools

dull rune
#

ah, then that is probably what I am missing 😬 where do I find the new build tools? I am new to dots and struggling a bit with navigating the documentation

dull rune
#

ah, okay😅 thanks!!

loud matrix
#

I can't find this anywhere but it feels like it must exist and I've seen mention of people asking how it works with no replies before.
Can EntityArchetype extend or parent off other archetypes?

fallow mason
#

What do you mean? Like have a base archetype with "sub-archetypes" that have all of the base archetype components plus extra ones?

loud matrix
#

Yup, space game so everything requires physics, translations, rotations, rendering local to world etc, would be much cleaner to setup a couple parents and inherit from those with what's needed

fallow mason
#

I don't know if there's anything built in, but I know you can do EntityArchetype.GetComponentTypes() to get the an array of types in an archetype.

#

Then you could add new types to the array and create a new archetype from that.

#

EntityArchetype is a struct, so you cant inherit from it.

loud matrix
#

Yeah I was considering setting up a method for handling it manually, just wanted to make sure there wasn't a built in way. Wanting to do things right, but also because I'm a bit of a C# noob and array management is still so counter to every other language I use.

#

I currently have a static class for storing all the archetypes so not difficult to add to it.

fallow mason
#

You could probably write an extension method where you pass in new types to automatically create an archetype with the archetype's base types + new types

loud matrix
#

I just managed to crash Unity so I must be on the right track!

gusty comet
#

I switched to instantiating with EntityManager, into a NativeArray, and I still get a swapchain crash.

#

In fact, it's considerably slower and crashes more easily than instantiating in a command buffer.

#

It's getting hard to believe these people who claim to render hundreds of thousands of entities, instantiated all at once.

#

It's starting to become more believable that they're using compute shaders instead of batch processing.

zenith wyvern
#

Huh, I thought using EntityManager with NativeArray was supposed to be substantially faster, I guess not

gusty comet
#

Way slower.

#

Probably because it has to be done on the main thread.

mint iron
#

probably because they just made ECB playback bursted.

zenith wyvern
#

ECB is played back on the main thread too

#

Yeah that may be it

mint iron
#

or maybe counting the speed in the system rather than the CommandBufferSystem being used for playback 😄

gusty comet
#

Note, I can instantiate any number of entities if I add the DisableRendering tag component first.

zenith wyvern
gusty comet
#

But there are people claiming to render in the 100s of thousands

zenith wyvern
#

I've never used it before but it sounds like it's made exactly for your scenario

gusty comet
#

It does, but I got the impression from posts on the forum that world creation isn't supported yet. Still, haven't tried it, so it's worth a shot.

zenith wyvern
#

I just checked my stress test, I can render 250k static cubes with plenty fps to spare

#

In the editor no less

#

Using URP 9 with Hybrid v2

gusty comet
#

Maybe it's having them marked static that is making the difference?

zenith wyvern
#

They're not marked as static, I just mean I'm not moving them

#

Saves the work from the transform system and having to recalculate renderbounds

#

If I move them all it performs substantially worse

gusty comet
#

That may be it then. I'm rotating them behind the camera.

#

It's my way of getting around the problem of adding and removing tag components leading to lots of rebuilding chunks, since one-sided quads rotated behind the camera should be hidden from view in two ways.

#

Actually, I was wrong. I already stopped rotating them.

zenith wyvern
#

Well my profiling seems to show that the transform system and recalculating renderbounds is a massive performance hit for large amounts of objects. What does the timeline on your profiler show?

gusty comet
#

Gfx.WaitForPresentFromGraphicsThread

#

Waiting for a signal from the GPU. That's half a second for instantiation of 2000 quads, whether rotated or not.

#

Which is weird for two reasons. Without the rotation, computation should be cheaper (CPU side), but with the rotation, they should be culled (GPU side).

#

With 25k quad entities instantiated, the SRP Batcher has enough verts and indices for 29 quads. So, there's a limit to batch rendering from the same quad.

#

I'd suspect my hardware, but it runs Beat Saber at 4k resolution and 90fps just fine.

spice venture
#

Hello, I have a native job dependancy question. I have a large number of jobs (work jobs) each writing data to a different temporary NativeContainer, and I want to coalesce the previous results into a single final NativeContainer (merge jobs).

I can create a sync point between the work jobs and then schedule the merge jobs sequentially but that's not optimal.

Is there a way to run the merge job as soon as the corresponding work job is complete, while maintining sync? (In a producer/consummer kind of way?)

warped trail
#

180k quads, constant up/down and constantly facing camera, cpu 95%, gpu 60%, URP😅

gusty comet
#

I don't know what I'm doing wrong.

warped trail
#

just use recommended workflow😅

#

and i'm on laptop from 2012

zenith wyvern
#

Pretty consistent with mine. I have a pretty beefy PC so my limits higher but yeah

#

Are you sure you have burst enabled?

gusty comet
#

Yep.

warped trail
#

just copy SpawnFromEntity codefrom ecs samples for test🤔

gusty comet
#

Looks like I'm already doing something pretty close to that. So, shouldn't take long to convert. I could have sworn I read through that last night.

loud matrix
#

Oh this is maddening, If I try and use PhysicsVelocity in a pure ECS component it just decides to up and NaN all position, rotation and local to world variables. Can find a couple posts about it with 0 solutions and nothing else. But if I convert to entity physics works fine.

gusty comet
#

Yeah, as I'm discovering, they want a very specific workflow.

warped trail
#

@spice venture you can just schedule all your jobs and scheduler will run your jobs in right order🤔

#

like your last job won't run, until previous jobs which writes to native containers finished

spice venture
#

Is there automativ dependency management from NativeArray usage? I expect safety errors If I try to write to the same NativeArray from parralel jobs.

warped trail
#

if they are in same dependency chain

#

like JobB depends on JobA

#

you can combine dependency

#

like if JobB writes to nativeA and JobA writes to nativeA, JobB won't run until JobA finished

spice venture
#

Without having to use any JobHandle chaining when scheduling jobs? That's neat.

warped trail
#

you have to use JobHandle chaining😅

spice venture
#

I'll try to reframe my problem:
I have jobs A1, A2, A3 ... that can run in parallel
For each of this jobs, I have merge jobs M1, M2, M3, ... that write to the a common array. So M1 depends on A1, and so on.
The problem is that I don't know if which order the A jobs will finish, so scheduling M1, M2, ... in order isn't optimal.

#

(Unless I wait for all the A jobs to finish, but that's wasted time to)

warped trail
#

schedule A1, A2, A3, combine depenencies and schedule M1, M2, M3🤔

spice venture
#

Well that's a sync point, and that's I'm trying to avoid.

#

There could be one lone worker thread finishing its A job, while other threads are idle

warped trail
#

combining dependencies doesn't not mean you are waiting for A1, A2, A3 to complete🤔

spice venture
#

Well it does if M1, M2... depends on the combined handles of A1, A2, ...

#

Unless I didn't understand you?

#

Sorry if i'm not clear enough 😄

warped trail
#

it will look something like thiscs var jhA1 = JobA1.Schedule(); var jhA2 = JobA2.Schedule(); var jhA3 = JobA3.Schedule(); var jobHandleA = JobHandle.CombineDependencies(jhA1 ,jhA2 ,jhA1); var jhM1 = JobM1.Schedule(jobHandleA); var jhM2 = JobM2.Schedule(jobHandleA); var jhM3 = JobM3.Schedule(jobHandleA);

toxic mural
#

Doesn't that mean M1, M2, M3 will be waiting on ALL of A1, A2, A3 ?

warped trail
#

if nativeContainer is not blocked by any job it will run

toxic mural
#

I need to read up on jobhandles

vale stream
#

does anyone have a more in depth explanation on how ComponentDataFromEntity works? Why do I need do use GetComponentDataFromEntity from a job to make one? Is it because of thread safety?

toxic mural
#

although it is not really that in depth

vale stream
#

I was just kinda curious what's going on under the hood. What's the reason to not just make a whole bunch of ComponentDataFromEntity from the beginning instead of in each job?

#

ty, tho, I havent seen this video yet

toxic mural
#

"What's the reason to not just make a whole bunch " I think it makes job scheduling more xomplex, if each job has access to 20 different types of components, it makes it harder to know when its safe to let something read or write

vale stream
#

thanks, that's kind what I was suspecting

gusty comet
#

Okay, so in V2, SpawnFromEntity is broken. The converter never picks up registered prefabs, and it's impossible to get it assigned properly before the spawner job tries to run.

#

But at any rate, I really don't see how this is any different from spawning from an entity obtained through the ForEach query.

zenith wyvern
#

That's it. I put my authoring script on a unity cube and add a ConvertToEntity. From those two scripts I get 250k cubes rendering.

#

@gusty comet

#

This is with URP 9, Unity 2020.1b3.

gusty comet
#

Okay, so my real problem is the workflow. They're forcing us to spam the editor to the point that it'll end up useless.

zenith wyvern
#

I don't know what you mean by "spam the editor"

gusty comet
#

I'll need a primitive built-in prefab dragged into the scene hierarchy, which is going to mean every kind of quad and every unique piece of geometry will need one too.

zenith wyvern
#

No, you just need a renderable gameobject. Convert it then set the mesh at runtime

#

All your renderable entities can come from one single prefab, and you can just give it the appropriate mesh when you instantiate it

gusty comet
#

Same problem following your example. Convert() is never called.

zenith wyvern
#

You need to have a ConvertToEntity script or have your gameobject in a subscene for it to be converteed

gusty comet
#

That's it! Haven't even tried it yet, but I bet

zenith wyvern
gusty comet
#

I was trying not to use gameobjects at all. That's why I scanned over the gameobject based examples.

zenith wyvern
#

They aren't really gameobject based, everything at runtime is always an entity, in every example. Gameobjects are only used for authoring. As has been said, it's annoying but it's the way they want us to do it

gusty comet
#

Well, I can testify. I've been trying to get around that for more than a week, every day. It's technically possible, but at extreme performance and stability cost.

zenith wyvern
#

From what I can tell it seems like you'll save yourself a lot of time and headache if you just take a step back and go through the examples in detail. Take your time, learn how to do it right. It'll save you time in the long run

gusty comet
#

I'll start reading over them tonight. Meantime, that one script was the issue with getting the game object converted.

toxic mural
#

Is there some kind of "manifest extension" that can sit in the Assets folder that just lets you add on github references?

#

I know I can use the Package Manager client to programatically add packages

#

but that makes me have to deal with editor callbacks and feels clunky

gusty comet
#

453320 quad limit, in any combination, and then the hybrid renderer fails a bool assert. That's a success though. Thank you, @zenith wyvern and @warped trail . Now to stop and read

dark mauve
#

Part of the reason I do this is that I plan to have quite a bit of code with different functions here

dark mauve
#

Another question: How do I find a different component system and call a function there.
For example, in my pickup system I want to do itemsystem->additem. How do I get the itemsystem from the pickupsystem?

#
    {
        base.OnStartRunning();

        ItemSystem itemSys = ???????????????????;

        Entities.WithoutBurst().ForEach((Pickup pickup) =>
        {
            itemSys.AddItem(pickup.m_ItemType, pickup.m_Amount);
        })
        .Run();
    }```
warped trail
#

World.GetExistingSystem<T>()🤔

dark mauve
#

Thanks 🙂

bright sentinel
#

I'm not so sure about the functions though. I don't really know how they even work with Burst, but it kind of seems like you may just want to schedule more jobs? 🤔

#

I'm also not sure about the performance on calling functions

#

I know there are some function pointer stuff, but that may be unrelated

dark mauve
#

I'm not sure if there is any better way to do this

#

My assignment says I have to avoid MonoBehaviors wherever possible and use the ECS and Job systems

warped trail
#

but with this approach it will be hard to use jobs🤔

dark mauve
#

Am I not using jobs already here?

#

I have no idea what other approach I could take with this

old hound
warped trail
#

you can, but with hybrid renderer V2 🤔

old hound
#

I am using hybrid renderer v2

old hound
#

using 2019.3 and BRP hawyee

warped trail
#

then you are not using hybrid renderer V2😅

old hound
#

yes, i expect you're right 😄 V2 was set in the scripting defines but from reading this page again it's clear V2 isn't supported in 2019.3

#

trying to upgrade now

#

upgraded

#

unsure as to whether this is a typo

bright sentinel
#

No it's supposed to say ENABLE

#

Just change it

odd cipher
#

still trying to figure out a better way to get values from a NativeMultiHashMap. because a Enumerator is a bit slow. (around 100 ms more than without)

mint iron
#

do you want all the values or a specific value

odd cipher
#

Well the specific values for a key

#

@mint iron

mint iron
#

it shouldn't be that slow, are you using burst?

odd cipher
#

Yeah

#

Each key has 64 values

mint iron
#

is your equality implementation slow maybe

odd cipher
#

What do you mean by that?

mint iron
#

i mean they test each key by calling the equals method (IEquatable<T>), so if you're using your own structs for keys, and your equals method does a lot of work, that would slow it down.

odd cipher
#

Oh, I think I do 4 of checks

#

if*

mint iron
#

if thats still too slow, you could use a normal hashmap that returns an index+count for your own array of values.

odd cipher
#

it could be the cause, since its ran about 40,000 times

#

so to solve this I just need a unique identifier on each? like a index

mint iron
#

for the key or value?

odd cipher
#

well the key is the struct

mint iron
#

dependa on what you're doing with the values too, for example, the key will be accelerated by hashing, but once you get the values back, if you have 40,000 values and only need a specific one, then you're wasting a lot of time iterating values.

odd cipher
#

well its not 40,000 values, I'm saying that the Enumerator loop is done 40,000 times

#

and each key has 64 values

mint iron
#

are you iterating every key or using TryGetFirstValue ?

#

maybe posting some code would help me understand.

odd cipher
#

this is what I do

public NativeArray<Color32> GetSprite(TerrainSprite data) {
            NativeArray<Color32> colors = new NativeArray<Color32>(terrainSpriteSize * terrainSpriteSize, Allocator.Temp);

            var valueEnumarator = colorTerrainTypes.GetValuesForKey(data);
            int i = colors.Length - 1;
            while(valueEnumarator.MoveNext()) {
                colors[i] = valueEnumarator.Current;
                i--;
            }

            return colors;
        }
warped trail
#

one big 1d array😋

odd cipher
#

well I would but again, I have like 3 indexes

#

which is what the struct is for

mint iron
#

you are taking all values? there should a be a block copy method to get them all somewhere.

odd cipher
#

Yeah I'm getting all values for a key

#

which is the slow part

#

or well specifically the loop

mint iron
#

wow, i see, they dont seem to such a method

#

you're forced to enumerate

odd cipher
#

yeah :(

mint iron
#

i wouldnt use it then in your case, i'd put the data elsewhere, use hashmap to lookup the key, and get something back that can let you quickly find the right block of values.

odd cipher
#

Yeah I know one alternative is using a 1D array but it wont really work because I have that struct with 3 indexes

#

other than that, I'm unsure

mint iron
#

can you explain that for me a bit more, i dont see the problem.

odd cipher
#

well I guess its just mainly me, I dont know how to get the correct values if its a 1D array

#

sine again, I have those 3 indexes

mint iron
#

what 3 indexes?

#

colorTerrainTypes and some other ones with other attributes?

odd cipher
#

no, the indexes in the struct, "public int terrainID, variantID, bitMaskID;"

mint iron
#

thats in TerrainSprite?

odd cipher
#

yeah, thats all the TerrainSprite does

#

it would be good if I could have the color array in there intead

mint iron
#

and your equals presumably checks each one

odd cipher
#

yes

#
public bool Equals(TerrainSprite other) {
        if (other.terrainID == terrainID && other.variantID == variantID && other.bitMaskID == bitMaskID) return true;
        return false;
    }
mint iron
#

yeah, thats fine, you can just have that in a hashcode.

odd cipher
#

may sound dumb but whats a hashcode

mint iron
#

umm... basically everything in c# has a GetHashCode() method, and it returns an id.

odd cipher
#

right yes, I just return 0 in there lol

mint iron
#

some of the default containers use it for stuff, Dictionary etc

odd cipher
#

so, what should I do instead in there?

mint iron
#

you could have a NativeHashMap<int, DataLocation>

#
public struct DataLocation
{
  public int FirstValueIndex;
  public int ValueCount;
}
#

and then put all your values in a 1D array

#

the key is the hash of your three fields in TerrainSprite

#

it gives you back this DataLocation, which u can use for the colors array

odd cipher
#

I dont really understand the hash thing

mint iron
#

no worries, ill write you some code

#
odd cipher
#

so in GetHashCode I have to return terrainID, variantID and bitMaskID combined?

mint iron
#

right

odd cipher
#

so just terrainID + variantID + bitMaskID?

#

woah woah

#

just doing that changed it from 350ms to 80ms

formal scaffold
#

I'm trying to count time up to a duration for a certain action. So I store "elapsedTime" and "Duration" on and Entity. I want to expand on that and make it possible to store more then one "elapsedTime" for multiple actions.

How can I store those different values? I thought of a buffer element on my entity, but how would each system know which element inside the buffer is the correct one?

odd cipher
#

@mint iron thank you! I wasnt expecting such a big improvement from just changing that

mint iron
#

Straight adding might be fine depending on what those Ids are, but this below is probably less likely to have collisions (but will be a bit slower)

    public override int GetHashCode()
    {
        int hash = 13;
        hash = (hash * 7) + TerrainId;
        hash = (hash * 7) + VariantId;
        hash = (hash * 7) + BitMaskId;
        return hash;
    }
odd cipher
#

whats the advantage of having it like this?

#

making sure that the hash is unique?

mint iron
#

it lets you store just an int in the hash map, which is going to be faster to lookup than calling equals on every IEquatable struct like MultiHashMap does. Well, maybe, i mean if the Equals method jsut returned a field and/or gets inlined then it would be the same as comparing an int. But C# also does some weird shit with equals and boxing so you have to be careful, unity was using IComparable on their collections for a while to sidestep some of those issues, but it seems maybe now they've just made burst work around it on compile.

odd cipher
#

Yes I got that but whats the difference between the GetHashCode method you sent and the one I used at first?

#

is it to make sure the hash is different than others?

amber flicker
#

Yes - otherwise collisions could be pretty common

dark mauve
#

Is there a simple way to destroy an entity when looping through a foreach loop?

#

For example in:

            {
                if (player.m_Collider.bounds.Intersects(pickup.m_Collider.bounds))
                {
                    inventorySys.AddItem(pickup.m_ItemType, pickup.m_Amount);
                    EntityManager.destroythisthingsomehow???
                }
            })
            .Run();```
amber flicker
#

There’s also a general c# one you can use. Something like ‘new {var1, var2 etc}.GetHashCode()’ (sorry on phone)

coarse turtle
#
cmdBuffer = someCmdBufferSystem.CreateCommandBuffer();
Entities.ForEach((Entity e, in SomeType c0) => {
  cmdBuffer.Destroy(entity e)
}).Run();
#

for the hash stuff you could also try xoring some values together too

mint iron
odd cipher
#

Thank you, ill take a look

dark mauve
#

@coarse turtle what cmdbuffer system would I use? I haven't created any

#

All I want is the entity equivalent of Destroy(gameObject);

coarse turtle
#

there are 3 (or 4) command buffer systems unity provides, you can pick one that fits you needs depending on the system group

warped trail
#

in your case you can use something like this😅 cs var ecb = new EntityCommandBuffer(Allocator.TempJob); Entities.WithoutBurst().ForEach((Pickup pickup) => { if (player.m_Collider.bounds.Intersects(pickup.m_Collider.bounds)) { inventorySys.AddItem(pickup.m_ItemType, pickup.m_Amount); ecb.Destroy(entity); } }).Run(); ecb.Playback(EntityManager); ecb.Dispose();

coarse turtle
#

That too works lol

warped trail
#

you can event use EntityManager, cause you are using Run() and WithoutBurst()

#

just add WithStructuralChange

#

but keep in mind that your approach is single threaded 😅

#

and without burst🤔

#

like what the point of using ecs then😅

dark mauve
#

Well

#

I couldnt use multithread because I had to refer to a ScriptableObject

#

which isn't a blittable type

#

So I had to go from struct IComponentData to class IComponentData

#

and then it required WithoutBurst and Run

mint iron
#

@formal scaffold you could make a different timer for each purpose, PendingDestructionTimer and then SpawnAfterDelayTimer etc, or if you only ever have one timer happening at a time, but want to share a component u could put a flags enum field with the purpose of the timer in there as well.

coarse turtle
#

Yeah then the EntityManager.Destroy(e) might work for your case @dark mauve if you cant convert your scriptable obj to a runtime blob asset or something similar to that

dark mauve
#

@warped trail ecb.Destroy() doesn't exist. ecb.DestroyEntity() tells me pickup cant be converted to entity

#

@coarse turtle EntityManager.destroy(pickup) doesn't work either :/ (cannot convert from Pickup to Entityquery)

mint iron
#

you could move your data into a struct inside your scriptable object, and then pass that in instead (assuming u can get it from outside the entities.foreach)

dark mauve
#

@mint iron ehh but then I can't predefine it in Editor

#

also the data in the struct has Texture2D which also isn't blittable

warped trail
#

then move to struct everything you can🤔

dark mauve
#

I also had a GameObject reference in there for UI that I had to work. Spent the entirety of yesterday trying to get it to work with struct, but eventually just gave up and went for the class. It'll have to do for now

#

I'm doing this as as training assignment where the goal is: don't use monobehaviors and use the ecs and job system, so as long as I do that, I think I'll be alright.

#

Still haven't figured out the destroy entity thing though

coarse turtle
dark mauve
#

What's the RecurseGetRoot() function? I can't find it anywhere

coarse turtle
#

no no no that's my function lol

#

i just stuck it in the a system that I'm working on

#

the destroying functionality

dark mauve
#

So I should just use EntityManager.DestroyEntity(pickup);?

coarse turtle
#

well if pickup is an entity and you can't get around without using the EntityManager then that make sense

dark mauve
#

Still tells me I can't convert it to EntityQuery though

coarse turtle
#

Well you have a couple of ways to destroy the entity/entities from the EntityManager

dark mauve
#

It should recognise it as entity.. not sure why it keeps telling me it can't convert it

warped trail
#

is this vim?👀

odd cipher
#

@mint iron it seems some have the same HashCode and then it says "an item with the same key has already been added"

coarse turtle
#

You can pass in an entity, a query, or a collection (array/slice) of entities for the EntityManager to destroy - pick how you want to handle destroying it
@warped trail yes 👀

dark mauve
#

It does work when I use Entity instead of Pickup as the type in ForEach loop, but then I can't access Pickup's variables

#

Since Pickup is an entity it should work fine using Pickup, or am I forgetting something?

coarse turtle
#

hmm maybe show the code? it's hard to tell what pickup is from this context

dark mauve
#
    {
        Entities.WithoutBurst().ForEach((Player player) =>
        {
            Entities.WithoutBurst().ForEach((Pickup pickup) =>
            {
                if (player.m_Collider.bounds.Intersects(pickup.m_Collider.bounds))
                {
                    inventorySys.AddItem(pickup.m_ItemType, pickup.m_Amount);
                    EntityManager.DestroyEntity(pickup);
                }
            }
            )
            Run();
        })
        .Run();
    }```
#

That's the full function

warped trail
#

make it like this ForEach((Entity entity, Player player)

#

and EntityManager.DestroyEntity(entity);

dark mauve
#

If you do that it uses both?

warped trail
#

what do you mean both?

dark mauve
#

So if I use ForEach((Entity entity, Pickup pickup)) I can use both pickup for the pickup's variables, and entity for the pickup's entity?

warped trail
#
 protected override void OnUpdate()
    {
        Entities.WithoutBurst().ForEach((Player player) =>
        {
            Entities.WithoutBurst().ForEach((Entity entity, Pickup pickup) =>
            {
                if (player.m_Collider.bounds.Intersects(pickup.m_Collider.bounds))
                {
                    inventorySys.AddItem(pickup.m_ItemType, pickup.m_Amount);
                    EntityManager.DestroyEntity(entity);
                }
            }
            )
            Run();
        })
        .Run();
    }```
dark mauve
#

Yeah that works

#

But it confuses me as to why it does

warped trail
#

someone should read documentation😅

dark mauve
#

That's all I've been doing these past days. Just trying and reading and watching tutorials, but it's still been pretty difficult to wrap my head around

coarse turtle
#

Well the lambda foreach doc page shows the typical structure of how to write the lambda, if you're interested in how it works under the hood - it might be worth looking into how ArchetypeChunk.GetNativeArray(ArchetypeChunkComponentType<T>) works via the source code

odd cipher
#

@mint iron sorry for ping again but are you there?

dark mauve
#

Alright. Thanks a lot for your help @coarse turtle

#

Arghh I thought it worked but apparently now I get "Structural changes are not allowed during entities foreach"

warped trail
#

.WithStructuralChanges

#

or ecb

dark mauve
#

I have that 😦

#

Only on the inner loop though

#

But the other I dont destroy anything in

#

Ooh doing it on the outer fixed it

#

Not sure why but fine for me

mint iron
#

@odd cipher if the hashamp wont handle collisions then you'd need to make sure all the keys are unique

odd cipher
#

either way, I tried ignoring the ones that arent unique and that worked with a semi deformed world and the timings are still 90

#

I think ill stick with NativeMultiHashMap, the main problem was the GetHashCode

#

also realized that its actually 30ms, 90 in editor

raw mica
#

Hey guys, I have a question concerning Unity.Physics, ECS and rendering. Carrying this over from #archived-hdrp , I found out that HDRP and the Hybrid Renderer don't play well together in regards to rendering entities, mainly for indirect lighting. However, Unity.Physics (+Havok) requires entities to work and regular GOs either don't register or breaks collisions altogether. Running in Convert and Inject GO mode breaks Unity.Physics as well.

Is there a way to make use of Entities without having to give up HDRP and AFAIK; ECS systems copy over data from the GO during conversion and attempts to create a new Entity that has the EC equivalents of the GO components in-built from Unity. However, those EC equivalents don't have the exact same functionality as their GO counterparts or outright don't exist and in Convery and Inject mode, the data is copied between the GO components and the Entity components (sync). is this correct?

For what I want to do, and for learning purposes, I want to make use of Havok Physics and ECS performance but I would very much like to use HDRP.

Anything wrong/things to note about my understanding and options/tips for combining these libraries? Thanks for any feedback/help.

safe lintel
#

if you want to use inject with physics, you will just need to create your physics entities manually

opaque escarp
#

is there a resource for how to use the new unity input system with DOTS/ECS?

raw mica
#

@safe lintel Thanks for the pointer. One problem and clarification, this issue mainly exists for world static objects like terrain and buildings. I assume the intention is to create a completely separate entity with the same collision mesh and world data as the GO, basically overlapping the GO itself. Is this process very memory intensive as you're essentially creating the world twice?

safe lintel
mint iron
#

@raw mica I think for environments the idea is to have them in all layed out in a SubScene, because it then gets compiled into a big block of memory which can be loaded in one go, cutting out any kind of processing time from the equation. Obviously a problem for dynamic content but you can get away with building tools to generate enough variations in the editor, and then switch them out/connect them together or whatever at runtime.

safe lintel
#

well i guess it depends on the scale of your project. something like megacity wouldnt work with gameobjects, but a small project might not be an issue at all. running multiple physics for hitboxes on good old skinnedmesh renderers personally and its not a big deal with multiple enemies

bold pebble
#

How do I control the camera via DOTS (it should follow/lerp to the player entity)? I tried to add a ConvertToEntity component to the camera, but this seems to break with post-processing. I am using URP with a global volume. Also adding ConvertToEntity on the volume doesn't work.

raw mica
#

The ideal scale (not my current experiment) is using sub-scenes for a dynamically loaded world. The problem is physics interactable entities, like trees (knock them down with impact force), I'm thinking as a workaround to just spawn that particular trees' Entity and simultaneously delete it's GOs on interaction/event.

#

But then the collisions will fail regardless if the entity does not exist in the first place.

#

Sub-Scene world "streaming" I imagine will become memory heavy with this.

safe lintel
#

besides hdrp what else do you need gameobjects for? i would just truck on and ignore the graphical limitations for now

raw mica
#

The problem is the graphical limitations will ruin any form of indoor lighting without a ton of light sources since light doesn't bounce properly: (from #archived-hdrp ).

I'm trying out some things with URP right now so this is not an immediate concern, but it will be when I start using HDRP for full on projects.

safe lintel
#

well yeah this is a limitation with whats available. theres a team working on the hybrid renderer fulltime now i think so hopefully its remedied sooner than later but id just get used to it, designing some sort of split gameobject/entity world based on whats temporary might give you more problems down the road than is worth

raw mica
#

Is this particular issue on their roadmap? I should probably go check.

covert raven
#

anybody ran into this error when building for iOS? No member named 'get_address_of_ecb_0' in 'U3CU3Ec__DisplayClass5_1_t713C0FF0AFF2CC377EAAE683E9F7D820B8BCB45B'

halcyon bay
#

What exactly is a dynamic buffer? I'm reading the manual and I'm not really understanding

#

I'm trying to figure out how to hold a set of data in a component, like a list, and "a variable-sized, "stretchy" buffer" doesn't really.. uh.. what? I mean supposedly this is what I want but.. ye idk

zenith wyvern
#

It's just a resizable list you attach to an entity.

halcyon bay
#

ok, the wording is a bit odd in the manual

#

ty

zenith wyvern
#

There's a bit more to it when you're concerned about how much space it takes up inside a chunk but it's easiest to just think of it as a resizable list on an entity until you're more familiar with ECS

halcyon bay
#

Ok, yeah I have yet to actually use it outside of playing around in an empty project

bold pebble
zenith wyvern
bold pebble
#

@zenith wyvern Thanks. That's a pretty long article. 😮

naive parrot
#

@zenith wyvern wont say hacky. you can have simple read/write system before/after simulation group that do the syncing

zenith wyvern
#

Yeah you can pretty much skip the first part, the "Conversion Workflow" and past that is what matters

bold pebble
#

So my goal is (just) for the camera to follow the player (which is an entity). Should I have a system which runs after physics and reads the player position and updates the camera pos accordingly?

zenith wyvern
#

If that's all you need then yeah that's reasonable enough. You can use ConvertAndInject to attach your camera to an entity so you can easily update it inside a system that's set to update in the right place. The article goes over convert and inject as well

bold pebble
#

@zenith wyvern When I put ConvertToEntity on my camera it will break the post processing. But thanks for the hint. I will go over the article.

#

@zenith wyvern For some reason the post processing will start to work again if I select "Convert And Inject GO" and then modify any property of the camera in the editor. 🤪

zenith wyvern
#

That sounds like something that would only happen in the editor, I'm guessing it wouldn't happen in a build

last jasper
#

(the section is Accessing the EntityQuery object)

#

(I realise the example is explicitly saying it can be used for preallocation - it just seems like black magic for now and I wondered what was going on behind the scenes)

zenith wyvern
#

@last jasper It says it lower on the page, it gets set during code generation. You can use it as soon as the game runs

last jasper
#

perfect, thanks Sark!

toxic mural
#

Does my syntax highlighting look broken? I feel like it should be more colorful

thorny vault
#

Does anyone have insight into this error? error DC0002: Entities.ForEach Lambda expression invokes 'GenerateCells' on a ClientHexGridRenderer which is a reference type. This is only allowed with .WithoutBurst() and .Run(). I know why its happening, but I don't know what to do about it. Is there some way to tell unity its safe to use a function from withing Entities.ForEach?

toxic mural
#

You could try making it a static functions

thorny vault
#

That is very interesting.

#

fwiw, I get slightly more syntax highlighting than you.

toxic mural
#

Oh I bet because its in a Package, maybe

bright sentinel
#

@toxic mural Your syntax is definitely broken, try restarting your IDE or even Unity, that will help usually

toxic mural
#

I got it, it was (maybe?) because I was trying to edit a file in a package

halcyon bay
odd cipher
#

I dont understand this error Burst error BC1020: Boxing a valuetype `Unity.Collections.NativeList`1<Pathfinding.FindPathJob.Node>` to a managed object is not supported
this is the line if (!neighbour.isWalkable || closedSet.Contains(neighbour)) continue;

#

also getting this whilst the Native Container it is referencing isnt ReadOnly InvalidOperationException: The native container has been declared as [ReadOnly] in the job, but you are writing to it.

odd cipher
#

anyone?

naive parrot
#

first error is thrown when you use NativeContainers for managed objects i.e classes or structs with classes within .
second error is being thrown because you have set [ReadOnly] attribute on a native container within a job , but you are also trying to update it.

#

@odd cipher

odd cipher
#

but I didnt set it to readonly

#

also the struct used doesnt have any of that ```csharp
struct Node {
public int x, y, parentX, parentY, gCost, hCost;

        public int fCost { get { return gCost + hCost; } }

        public bool isWalkable;
    }
naive parrot
#

where is your job defined ? within Entities.ForEach or is this standlone IJob ?

odd cipher
#

I dont use Entities, so standalone

naive parrot
#

can you share the job snippet ?

odd cipher
#

the entire code? it's rather long

naive parrot
#

just the job definition with field declaration in question.. (!neighbour.isWalkable || closedSet.Contains(neighbour)

odd cipher
#

the closedSet is just created in Execute, NativeList<Node> closedSet = new NativeList<Node>();

naive parrot
#

hard to tell from this tbh

odd cipher
#

well theres not much else going on

naive parrot
#

have you checked on forums for known issues? is this IJobParallellFor ?

odd cipher
#

just a IJob, and I tried but didnt really find much about the errors

naive parrot
#

if you do .Run( ) does it throw same errors?

odd cipher
#

yes

naive parrot
#

also are your using BurstCompile on it ? is the job getting burst compiled correctly? The burst job inspector can give some insights on managed references in a Job , when it detects it

odd cipher
#

yes, I can see the error I mentioned earlier

naive parrot
#

it should be telling you the line number

odd cipher
#

yeah I know, its if (!neighbour.isWalkable || closedSet.Contains(neighbour)) continue;

#

I have no idea why

naive parrot
#

neighbor is the Node struct u shared above right

odd cipher
#

yeah it is

naive parrot
#

ProjectileHealthSystem.cs(80,17): Burst error BC1033: Loading a managed string literal is not supported

#

i get this type of error in jobs inspector for eg when burst fails

#

with line number

#

this is happening say if i place string inside my job

#

do you not have any more detail in the job inspector ?

#

what Jobs version you are on ?

odd cipher
#

thats the full error

#

I'm on 0.2.6

naive parrot
#

are you using explicit casting in job somewhere from Node to something else?

odd cipher
#

no

naive parrot
#

it might help if you could share job body

odd cipher
#

I can send the full code

naive parrot
#

will take a look if you can

odd cipher
#

pretty much a pthfinding thing that I'm making in Jobs and Burst

naive parrot
#

alright

odd cipher
#

dont know if the pathfinding actually works yet cause of these issues :p

naive parrot
#

can send if you think that will help. got some time on hand , can debug it for you. upto you

odd cipher
#

what do you mean?

naive parrot
#

just meant you can share if you think that will help me figure out the issue. am trying to figure out the error in the script you shared meanwhile

#

nvm. my brain slipped there for a sec. btw Tile is also a struct right ?

#

is this from TileMap package of Unity or your own?

odd cipher
#

my own

naive parrot
#

ok

#

Tile has no class references right ?

odd cipher
#

it actually does but it works just fine in other Burst enabled Jobs

naive parrot
#

yea well those jobs wont be getting burst compiled then

odd cipher
#

but they are so

naive parrot
#

can you see their burst compiled code in jobs inspector?

odd cipher
#

Yep

#

it only has references to classes in 2 functions on the Tile

naive parrot
#

burst compilation fails silently when it encounters class references in jobs.

#

for burst disabled/failed jobs , you will see them in jobs inspector list with greyed out listing

odd cipher
#

they do compile correct though

#

they arent grayed out

naive parrot
#

🤔

odd cipher
#

so,, I dont think thats the problem

naive parrot
#

btw i created a simple Tile struct and it compiles fine. except the NativeList<>.Contains extension is missing from my project apparently. Unity cant find contains method for NativeList. if i disable those calls , rest whole code compiles fine in burst

odd cipher
#

oh, I see that extension is from System.Linq

#

what could I do instead of Contains?

naive parrot
#

that explains it i guess

odd cipher
#

yeah, I dont know a alternative though

naive parrot
#

NativeList does have Contains extension btw

#

you need to implement IEquatable for your Node struct

odd cipher
#

alright, that seems to have fixed that problem, however.. this time my game just crashes

naive parrot
#

that could be lots of things. you will have to step through your code. first run it on main thread only using .Run( ) with burst disabled. then .Schedule( ) . after that try with Burst enabled. check the jobs inspector for any errors

#

also if you can enabled Safety Checks and Stack Trace for Jobs and Burst for better error detection

odd cipher
#

Alright, enabling that gave me this instead of just crashing The native container has been declared as [ReadOnly] in the job, but you are writing to it.

#

buttt again, it hasnt been declared readonly anywhere

naive parrot
#

closedSet right?

odd cipher
#

indeed

naive parrot
#

i think the correct way to allocate native containers within a job is like this NativeList<Node> closedSet = new NativeList<Node>(Allocator.Temp);

odd cipher
#

alright, it now gives me a different error "Size overflow in allocator" and crash

naive parrot
#

perhaps allocate with a predefine capacity

#

NativeList<Node> closedSet = new NativeList<Node>(10, Allocator.Temp);

#

or whatever size is relevant

#

make sure this one is also updated NativeList<Node> openSet = new NativeList<Node>(10 , Allocator.Temp);

odd cipher
#

yeah, did that, still same error

naive parrot
#

seems to be logic issue. i think this iterator is causing overflow while (openSet.Length > 0)

odd cipher
#

possibly

naive parrot
#

could be that this line is not working reliably due to logic openSet.RemoveAtSwapBack(currNodeIndex);

odd cipher
#

I mean honestly, I dont really know all of the logic behind it

#

yeah, where I got the logic from it was a bit different than that

naive parrot
#

you could take it into standard main thread environment , make it concrete , validate it then apply the job/burst to it perhaps

odd cipher
#

they did openSet.Remove()

#

and that method doesnt exist for NativeLists

naive parrot
#

Remove( ) and RemoveAtSwapBack ( ) are functionally different from my understanding

#

/ Truncates the list by replacing the item at the specified index with the last item in the list. The list is shortened by one. you may or may not want this.

odd cipher
#

Yeah I dont think thats what was intended in the original logic

naive parrot
#

you can look into these. if that helps. these containers provide more flexibility i suppose

#

alright , i gotta sign off for now. hope you figure it out from here. @odd cipher

odd cipher
#

Alright, thank you for your help so far

odd cipher
#

ugh, making this pathfinding is proving to be harder than I thought, I have a working version but I need a faster one.. but I really just cant figure this out, so I guess ill have to stick with that for now

#

Might try again later but currently my brain just isn’t cooperating

cosmic sentinel
#

what's the recommended way to pass in a Mesh or a Material to a system?

hollow scroll
#

has anyone else noticed that loading times (the app start, specially on mobile) gets so much worse with the Entities package in the project (from ~0.29s to ~4.78s in an empty game)?? Did anyone find any way to solve that?

eager jungle
#

import physics and you'll see get even worse :p im really interested in a good fix as well. Right now I'm using the Enter Play Mode Options settings, but maybe there is a better/safer option?

hollow scroll
#

Yep, but I'm talking even on a Build (outside the Unity Editor), having that the time difference is quite big... there is this option of adding #UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP and it improves a little (obviously you need to do the creation of the world, etc by yourself in that case)

gusty comet
#

Anyone know why Unity would suddenly ignore a system's entire script without any code being changed?

amber flicker
#

because the system no longer has entities that match its requirements? You can try adding [AlwaysUpdateSystem] to see if it's that

gusty comet
#

Awesome, thank you

#

It also suddenly stopped disposing of TempJob allocations. But 2020.1.05b just randomly does that, it seems.

#

Nope that isn't it. Move entity creation to another bootstrap script, and OnStartRunning() still never fires.

mint iron
#

@hollow scroll my compile times and time to enter play mode are out of control right now, i have to wait 5-10 seconds every time i do almost anything significant, its quite concerning.

gusty comet
#

Adding the following method to a system class causes the entire script to be ignored by Unity.

#

Even if that method isn't called, Unity will outright ignore the entire script and never fire OnStartRunning(). It isn't even listed in the script order settings with that method in the class.

#

Is there a known reason for this or should I go file a bug report?

mint iron
#

Try adding [AlwaysUpdate] to the system as timboc said. and see if update is called .

#

if it is, you'll know your Entities.ForEach query is preventing execution

gusty comet
#

So, it's my query. Strange.

mint iron
#

unless you explicitly specify a RequireForUpdate, SystemBase will use the queries from any ForEach it finds in the system, to dertermine if it should run or not.

gusty comet
#

Okay, that makes sense. I have some entities instantiated and tagged in this script, and then query those tags. It's not seeing those right off, so it ignores the script.

#

I worried that I was separating my code too much elsewhere. Guess not!

last jasper
#

So, what's the current best practice for running a ForEach with a specific entity query? Say for instance I have two separate ForEach statements, with some logic in between, how can I guarantee they will both use the same entity query? The particular use case is a kind of 'many to one to many' - I have some processing in between the two ForEachs. Beforehand I could Schedule(query) on my IJobForEach

#

One solution is to migrate to IJobChunk, but I was wondering if there was a more elegant way with the newer SystemBase lambdas

gusty comet
#

Does the one have a unique tag?

last jasper
#

no

#

unfortunately not!

gusty comet
#

If the one is fished out of a chunk, and you have to keep it in that chunk then I think that's what IJobChunk is meant to be for.

mint iron
#

how can I guarantee they will both use the same entity query make them have the exact same arguments and options (WithAll<T> etc) and they will use the same query.

gusty comet
#

In earlier versions than 0.9 preview, you can do .With(someQuery) also.

last jasper
#

@mint iron I thought of this, but one of the components is readonly in one foreach and readwrite in the other - I could just mark them readwrite in both I suppose?

#

@gusty comet thats exactly what I did use, I'm upgrading some code to the latest version and finding that feature missing 🙂

mint iron
#

does it matter if they use different queries?

last jasper
#

yes in as much as i need to entityInQuery index to match between them.

#

I could instead key by Entity, but that seems like an ugly solution when before I could more explicitly bind the two together

#

Thanks for your replies - I think the answer in short is no for future entity releases, and that there is a workaround that you can match the signatures/query constraints to get it to use the same query. I guess my worry in the second case is that it is very implicit, and some other developer in the future might add some new code to one of the foreachs and introduce a nasty bug

gusty comet
#

I think I'm about to tackle a use case with similar constraints. Have you considered an Entity linked list? An Entity can be a field in a component, and it doesn't even impose that it must be shared.

last jasper
#

I guess essentially the first ForEach was building a kind of many-to-one list (the specific case: a list of Attacks made against an Entity in that frame)

#

So I think the equivalent would be something like a Buffer of Attack entities which gets populated in the first ForEach

mint iron
#

what about storing the attacks off into a collection, and then using Jobs.WithCode to iterate the list after processing to do whatever else you're doing.

last jasper
#

and that list being held on each Entity that can be attacked

#

@mint iron - that is essentially what I did beforehand. The first phase was building the list, the second was doing something to the list elements, the third phase was then executing back on the attack entities

gusty comet
#

If the attacks are numeric, that sounds like an ideal component buffer use case. Then split the procedure between two systems: one to collect attacks, and the next to apply them.

warped trail
#

if there is no structural change between ForEach indexes won't change🤔

last jasper
#

They have other metadata like attack type and hit location, etc

#

@warped trail nah they wont, but the bit that bothered me was having such a critical requirement that the two queries are equal being effectively hidden in requiring that the signatures match (whereas before I could define the query explicitly, and then give it to the two ForEachs)

warped trail
#

was it in component systems's foreach?

mint iron
#

you could use the AndStoreAsQuery(ref _query) (orwatever its called) and then use an IJobChunk for second part :*( not sure why they removed WithQuery

last jasper
#

@warped trail yeah

#

@mint iron that would also work - but then I have a kind of weird standard with one job using lambdas and the other using IJobChunk when before I could do both with IJobForEach

low tangle
#

I don't understand why you can't just use the entity as the key in the hash, or a hashcode from it for the index?

#

entityindexinquery isn't a super stable way of indexing outside of that query iteration
should really be using a stable id like the entity or a user generated mythingID

last jasper
#

actually I think that is probably the best suggestion, in that then it wont be a game breaking bug if someone accidentally changes one of the ForEach signatures

#

Thanks @low tangle

low tangle
gusty comet
#

Playing Beat Saber on max settings, PC fans say, " "
Playing Half Life: Alyx on max settings, PC fans say, " "
Importing a Unity Store asset, PC fans go brrrrr

opaque ledge
#

lol

loud matrix
#

I'm really loving ECS, and I'm really loving Scriptable Objects, but I'm mow smashing them together like dollies demanding they kiss and it's being about as productive 😛

#

so many different classes and variables, all of them called "ship"

loud matrix
#

Is it possible to make custom inspector output for a component? Setting a ScriptableObject just outputs the name of the field and no other data, being able to tell it what to output there would be really useful.

mint iron
#

yep, you can!

loud matrix
#

Neato, any idea where the docs for it are? as I can't find anything on it.

mint iron
#

its this repo https://github.com/OndrejPetrzilka/EntityComponentInspector but i had to update it for latest entities package because they changed a bunch of stuff in Entities.Properties. So here's the version i whipped up this morning.
https://www.dropbox.com/s/8sb3qj7hpji3qrf/ComponentEditorsPackage.zip?dl=0

loud matrix
#

Thanks

mint iron
#

then u just make em like this

    public class EntityArchetypeEditor : IComponentEditor<EntityArchetype>
    {
        public VisitStatus Visit<TContainer>(Property<TContainer, EntityArchetype> property, ref TContainer container, ref EntityArchetype value)
        {
            // EditorGUILayout stuff goes here.
            return VisitStatus.Stop;
        }
    }
stone osprey
#

Whats the recommended way of working with "Events" in a data oriented environment ?

coarse turtle
#

The one I use is typically a producer consumer style, produce an entity with the information, next frame, process the entity and consume it

You can take a look @mint iron 's event package - it's pretty easy to use

vagrant surge
#

either event-entities as @coarse turtle says, or some sort of event queue

#

but basically, you do messaging

#

by creating something that represetnts an event, either an entity, or some messaging queue

#

and later systems read from this and do stuff

south falcon
#

Hello, anyone know how to remove dynamic buffer from an Entity?

dull copper
#

ECS samples still 2 months behind

#

they've moved to systembase on some of the physics samples now

zenith wyvern
#

@south falcon EntityManager.RemoveComponent<BufferType>

south falcon
#

is that as same as using EntityCommandBuffer?@zenith wyvern

zenith wyvern
#

Yeah, you can do it with ECB as well

south falcon
#

commandBuffer.RemoveComponent?

#

@zenith wyvern Thank you!

humble falcon
#

Is there a way for an entity to copy the transform of a gameobject duringruntime? I dont want to rewrite the whole project to ECS because I have only one feature using ECS right now. But for that my entities needs the position of the player. So basically I am trying to run a Hybrid ECS project.

scarlet inlet
#

I am here again in the moment of need as usual

#

Would anyone be so kind to tell me how Unity knows if an entity component changed for the entity changed jobs?

#

I am wondering how it detects if a component changes and how can this detection be fast

opaque ledge
#

afaik, it doesnt detect changes on a singular entity, it detects changes on a chunk, so if you do a "ref componentA" unity will assume componentA is changed and will increase the chunk's version, thats how filters 'detect' the change

vagrant surge
#

@scarlet inlet chunk version numbers