#archived-dots

1 messages · Page 252 of 1

hard wagon
#

The job of combining images runs insanely fast than the CPU could, which is super fantastic.

rustic rain
#

You can have ad many combinations of jobs you want

#

Jobs to create your arrays and then another to combine them

drowsy pagoda
#

Has anyone successfully be able to render SceneGUI Handles (i.e. Handles.Label) on the scene window during play mode with live link?

hard wagon
drowsy pagoda
#

Don’t be afraid to be a little loopy. You’d be surprised at the performance results.

hard wagon
#

I was actually doing that technique with Coroutines. I'd break up the code into chunks of code at delay intervals. So that the cpu could resume it's next job operation.

drowsy pagoda
#

I wouldn’t compare coroutines performance and efficiency with dots side...they have different approach to handling data.

hard wagon
#

E.g.

yield return null; // wait for next frame
Do.SomeHeavy.APICalls(); // would take maybe 100-500ms
AnotherExpensiveMemoryCopyForWhateverReason(); // this could consume anywhere between 100 ms to 1000 ms
yield return null; // ahh what a relief, next call...
...
#

I know, I would like to take advantage of dots/burst. However, most of my functions require access to Unity's API... Such as Texture2D for example. I cannot access reference value in the job system.

#

I need to do more research into AsyncGPUCallback.

worn valley
robust scaffold
#

That's a read write NativeArray of the color buffer backing a Tex2D accessible directly from a bursted job.

#

Note, it's an ARGB layout. Color32 default is RGBA. So you need to make your own struct if you want to use fields to easily access the individual bytes.

drowsy pagoda
# hard wagon I know, I would like to take advantage of dots/burst. However, most of my functi...

The only reason why it feels “counter-intuitive” to set up loops to extract from Unity API, then create a burstable job to perform the computations, and write back using Unity API, is because you are still looking at it through the prism of OOP my man. You gotta really reprogram your mindset to DOD first. Just like you reprogrammed your mind when you first learned the concept of programming, along with the OOP paradigm that usually comes with it.

robust scaffold
#

To be fair, it took me years to get around to viewing everything data up rather than object down.

drowsy pagoda
#

If you ever look deeper into understanding of the way computers actually handle data between CPU, cache, and RAM, you will quickly come to the realization that you have completely misunderstood how it works, why with all the assumptions that come with OOP. You will find that CPU, even GPU absolutely love loops haha. And because of the “burst” of speeds you get, usually 5x-10x faster, and other cases 20-30x faster. Even if you loop an extra 5 times over your data sets using DOD approach, it will still perform it faster than your single loop in OOP. Seriously, it feels like magic.

robust scaffold
#

Just start thinking of everything as a frag / compute shader. And you pretty much got what DOD is.

drowsy pagoda
robust scaffold
#

The main advantage of DOTS / Entities / ECS / DOD is not having to deal with the headache of trying to pull data from the GPU. I spent 6 hours today realizing that RWStructuredBuffers in pixel shaders can not be pulled back into the CPU space.

#

Had to completely rewrite my shader into a compute and reorganize my call stack. So painful. Burst is 20x slower than a compute shader doing the same math but damn is it reliable. Data is right there in the memory. No worries about whatever undocumented shader target 69.420 isnt being targeted or whatever.

drowsy pagoda
#

Lol yeah. I remember when I first found out about the profound speed difference of GPU calculations vs CPU, that it’s so vast that the GPU waits for CPU commands more than it does compute anything lol. Not unless you utilize this (i.e. compute shaders) that is.

robust scaffold
#

That was the second half of my 6 hours of debugging. Slicing down my image processing stack into many many passes until each pass slid under the GPU timeout cutoff and actually be able to run.

#

Burst jobs dont have that problem. They can run for hours if you really wanted them to. They have no cutoff timer enforced by the OS and can be task killed manually.

drowsy pagoda
#

Thanks for that insight. Maybe saved a bunch of people 6+ hrs each 😉

robust scaffold
hard wagon
#

I need it to be a byte in order to encode it into png. Save an additional cost.

solar spire
robust scaffold
robust scaffold
hard wagon
robust scaffold
#

Works... okay. Actually the most, in plurality not majority, time consuming part of the entire image processing stack

hard wagon
#

Trying to do custom texture generation seems so difficult to work with. I'm trying to get around with background prebaking jobs for combining textures to save the hardware gpu cost.

robust scaffold
#

they're built to crunch float4s for breakfast

hard wagon
#

I'm using Unity's Job to combine multiple of texture. I would have to write the shader with finite numbers of texture 2D slot. Wouldn't that hurt the performance?

robust scaffold
#

So if you have dynamic number of Tex2Ds you need to merge together, use Texture2DArray, plug in all the textures, then in a compute shader / vertex shader, merge all the textures together

#

You will need to compute the size of the resulting merged texture before dispatch but that is done CPU side and is fully dynamic.

hard wagon
#

Huh... had a weird brainfart moment.

#

Thinking that you could encode image data to GPU to process all of the hard power the gpu could offer?

gray nexus
#

Hi, how to collide between gameobject (monobehavior) and an entity

#

And get collision event?

gray nexus
haughty rampart
gray nexus
#

oh

rustic rain
#

why have both worlds (mono and ecs) in the first place?

haughty rampart
rustic rain
#

well yeah, I assume that means

#

visual part on GO

#

gameplay part on ecs

haughty rampart
#

i mean sure

half jay
#

Hello, I am again with a similar question, but this time I want to make sure that I understand everything correctly based on the graph. I have a DeviceLocationUpdateSystem that waits for jobs to run out, but it waits specifically for LocalToParent:UpdateHierarchy, am I right?

pastel field
#

I'm using Hybrid Renderer v2 in URP 10.8.1 from Unity 2020.3.29f1 and trying to add support up to gen. 6 Intel HD 3000.
Everything render correctly in any recent devices, but Hybrid converted GameObject refuse to render on Intel HD 3000. However the rest of the scene, regular static objects, renders correctly. The supported graphic API is DX11, shader model is 4.1 and from system requirements I don't see what could be the problem?

rustic rain
#

you can try to inspect linked to entity GO

#

check it's component settings

#

maybe there's something that'll catch your eye

#

I think component is called

#

CompanionLink

pastel field
#

@rustic rain thanks for answering me.
I checked and filters component, but there is no CompanionLink on any GO.

rustic rain
#

well, that's why

#

companion object is not created

#

thus no drawing

pastel field
rustic rain
#

you can generate project files for all packages

#

and check yourself what gets compiled

pastel field
rustic rain
#

potentially because of compiler if statements

#

like

#

#if SUPPORTS_SHADER4.5

#

or smth

pastel field
#

hum maybe I'll dig that

rustic rain
#

make a search in Hybrid package

#

look for conversion keyword

#

I don't remember actual name for file

#

but it has it

#

this file contains system that looks what mono components to convert

#

and if MeshRenderer is greyed out

#

you potentially will se why

pastel field
#

MeshRendererConversion maybe

rustic rain
#

not sure, in short it has system that just has a lot of ForEach with renderer components

#

spriteRenderer

#

MeshRenderer

#

MeshFilter

#

and etc

pastel field
#

HybridEntitiesConversion correspond to that description

rustic rain
#

yeah

#

is MeshRenderer greyed out?

pastel field
#

it seems yes,
probably because of this conditional URP_7_0_0_OR_NEWER

rustic rain
#

welp

#

we got our answer

pastel field
#

Strange since my URP package is 10.8.1

pastel field
#

I checked a bit again, the log is screaming problems with Havok. The engine seems unable to load the assemblies.

#

And there is a Havok (Unity Physics) component(s) on each object that doesn't display, so I think that's surely the problem.

#

Ok if anyone fall into this problem, Havok require C++ 2017 Redist in order to load on Windows

pastel field
#

Also there are Shaders in Unity Physics package with #pragma target 4.5
You can change it to #pragma target 4.0 (in my case) by duplicating the package folder from Library\PackageCache to the Packages folder (creating a "custom" package as listed in the Package Manager).
Believe it or not, but this didn't fix my issue... yet

rustic rain
#

well, there's probably a reason it targets 4.5

pastel field
#

However, I can hear the sound that physical collisions make, so I think I must not be too far from the solution. This is probably a problem with SRP Batcher or the dozens of "AsyncGPUReadback - ComputeBufferID is invalid" that are in the log.

pastel field
rustic rain
#

I feel like it gets exception during conversion process

#

that's why no companion link

pastel field
#

Maybe.
It would be strange if this only happened on one machine and not others.
But on my production machine, I don't have a CompanionLink components anywhere and yet everything works fine.

pastel field
#

Big news... it's working in Hybrid Rendering V1

#

so... I'm confuse

#

The strange thing is that I basically use "Lit shader" and it is marked as unsupported in V1...

trim hearth
rustic rain
#

been a while I stay here kek

pastel field
#

Here, I have my answer and it is quite simple : Hybrid Renderer V2 requires Shader Model 4.5 (compute shaders), and will not work on anything less than 4.5.
@rustic rain Thank you for directing me to the solution 👍

drowsy pagoda
#

If you find your MB movements are “choppy” you will need to add a “smoothing” move script on your MB to hide it.

#

Easiest way I found was to read the transform during Update cycle, and set those values as target pos/rot/scale. And in LateUpdate move the transform closer to your target values.

stone osprey
#

Quick question here...

Lets say we are using our own network solution and dots...
An entity has a component with a list in it...

We add, update and remove stuff from that list during the gameplay frequently. But for network reasons we also wanna network those changes. So we kinda need to track which items in that list were added, updated or removed ( because we dont wanna send the whole list, only the updates ).

How do we handle such cases ? Any architecture tricks here ? Do we need to use our "own" list solution for this ?
Glad for any help here

worn valley
#

There is a networking DOTS experimental package if you wanna take a look at that. It isn't an easy solution to solve unfortunately

stone osprey
#

Well thats already a start, thanks ^^ However... how would you solve that issue ? I hope my issue is clear at all xD

#

I mean... i cant be the only one with that problem right ?

stone osprey
#

Anyone ?

worn valley
#

I would solve that issue by using Unity's networking system since a lot of people are working on it.

stone osprey
#

Well i guess thats too late xD like 90% of my project already done and its not worth the switch

worn valley
#

If you aren't sending changes that often, you could just use an RPC to propagate the change across the whole system.

karmic basin
#

keep in mind you'll still need to send whole state from time to time for reconciliation or if new players join

digital kestrel
#

how would i do atomic operations in a parallel for job?

robust scaffold
tepid abyss
#

Hey, do you guys manage to build a project for android using the latest version of Entities?

#

I get constant crashes even with an empty project it seems

digital kestrel
#

is there no Interlocked.And method in .net 4.0 😦

#

bruh c'mon lmao

#

Unity only goes up to 4.x .net framework 😢

coarse turtle
digital kestrel
coarse turtle
#

my mistake

#

misread that as add lol

#

i wanna say you could load a C++ dll and write a thin binding for atomic and 🤔

digital kestrel
#

honestly was thinking about that lol

#

not sure if OpenMP is supported on mobile VR platforms

robust scaffold
#

With interlocked exchange, you can do anything you want, just increasingly complicated

digital kestrel
#

yup, that's what im doing atm

#

it doesnt support unsigned ints / longs 😦

robust scaffold
digital kestrel
#

yeah had to convert it to an Int64 pointer in order to pass a reference to the original object and update it

#

unity was giving me unsafe code errors even though i have it enabled so i had to regenerate the project lol

tranquil jay
#

Hello friends, I am having some **jittery **behavior with a Physics Body, where if I set smoothing to **NONE **it works fine, but setting it to **Interpolate **or **Extrapolate **will make it very jittery. My car will move very **fast **(potentially) and I don't want it to teleport through a thin barrier.

Please help me figure out the solution 🙏 The code with which I move my car is:

float deltaTime    = Time.DeltaTime;
float invDeltaTime = 1f / deltaTime;

speedComp.speedCurrent = math.lerp( speedComp.speedCurrent, speedComp.speedMax, deltaTime );

float3 targetPos = translation.Value + localToWorld.Forward * speedComp.speedCurrent * deltaTime;
                    
velocity = PhysicsVelocity.CalculateVelocityToTarget(in physicsMass, in translation, in rotation, new RigidTransform(rotation.Value, targetPos), invDeltaTime);
haughty rampart
#

whatever you wanted to achieve with that lerp, it's definitely NOT doing that

dusk sand
#

Hey does anyone know how to set up a project tiny project? I am struggling to find the package in the package manager under preview packages? Is it still a thing...

rustic rain
# stone osprey Anyone ?

I'm really a person very far from networking stuff, but can't you just write some simple struct after each change that will say what index was added/removed/changed so other system that is supposed to send data can read it?

worn valley
dusk sand
haughty rampart
last swan
#

Hey there, is it possible to combine two different entity queries to one with a logical AND instead of OR? ( I found following documentation, but it is quite old and I seem not to be able to find a version of this for entities.0.17 https://docs.unity3d.com/Packages/com.unity.entities@0.8/manual/ecs_entity_query.html#combining-queries )

What I want to do: run a system only when two component types exists at the same time, but not if only one of them is present.. they are on different entities (one as singleton and one on multiple entities) but it needs both to let the system run. Currently I have a RequireForUpdate(SingletonComponent) and a Entities.ForEach(MultipleComponents) but the first one overrides the entities.foreach update requirement.

tranquil jay
haughty rampart
#

or if you want to only run when both are present, why don't you just query for both then?

#

@last swan

#

i am sorry, i had not much sleep today. the approach you have with RequireSingletonForUpdate should be exactly what you want

last swan
#

can I use two RequireForUpdates? Because when I combine two queries for one requireforupdate it will be combined with an OR - I am running a entities.foreach(), this should still be possible but only when both queries are valid

#

Because I got told, RequireForUpdate overrides the Entities.Foreach() Update requirements, so It would always run, when this singleton entity exists

haughty rampart
#

of course it always runs when the singleton exists. that's exactly what you want

#

of course it does NOT run when Entities.Foreach() matches no entity

last swan
#

So the information that RequireForUpdate overrides Entities.ForEach requirements is wrong then? Or do I explicit have to use RequireSingletonForUpdate

haughty rampart
#

RequireForUpdate does override all other queries cached by the system and runs only when all of all is present. but since you want to check for a singleton anyway, requiresingletonforupdate is much better anyways. it still overrides the cached queries as you want

#

in any case, all queries are still considered for the update. it does not 'clear' any queries

last swan
#

so I tested it real quick with a singleton and RequireSingletonForUpdate, and with none matching entities for the Entities.ForEach and the system still runs, which I want to avoid. then there is no way to avoid this?

haughty rampart
#

entities.foreach should not run

last swan
#

but the system does

haughty rampart
#

systems always run except if disabled manually. there's not much code in a system though. so it really does not matter

#

besides, how is the system supposed to know it shall not run if you need to query in the system for the required component?

#

also, you don't have any game logic in a system

#

so it doesn't even affect the game

rustic rain
#

create a query in OnCreate and then just do if (query.Count == 0) return

haughty rampart
#

Not needed though

rustic rain
#

if system contains stuff besides ForEach

#

I'd say, it will save resources

haughty rampart
rustic rain
#

wdym

#

buffer

#

Gathering data

#

packing jobs

haughty rampart
#

You'd do that preferably in a job

#

If you do not, your code can be improved

rustic rain
#

what about buffer

#

can it be created in job?

haughty rampart
#

What buffer

rustic rain
#

ECB

last swan
haughty rampart
# rustic rain ECB

1 - you get ecbs from an object pool,
2 - if you don't write to them there pretty much air

last swan
rustic rain
#

I mean you have to do
bufferSystem.CreateEntityBuffer()
And then after ForEach
bufferSystem.AddJobHandler(Dependency)

haughty rampart
rustic rain
#

I used query check to avoid that from being created which also prevented errors

#

that come up

#

if your query is empty

#

and yet you ship out buffer

haughty rampart
rustic rain
#

huh

#

yeah, that's smth to know

#

none of examples mention that

haughty rampart
#

and this is like one of the basics of basics of dots

rustic rain
#

seriously tho, no Unity example mentions that

#

examples use Create

haughty rampart
#

yeah i just did a quick search and did not immediately find it. but i know that it's all over my code

candid epoch
haughty rampart
#

i think

candid epoch
haughty rampart
#

what i mean is, should the query succeed in finding any valid entities at some point, it would still not run since you only evaluated once in OnCreate

candid epoch
#

i use this very frequently to delay some stuff by waiting for singletons, worked every time so far.

tepid abyss
#

Is anyone build a game using entities for android? if so, what version do you use?

candid epoch
#

i think it just adds it to the "internal" queries that get evaluated like Entities.ForEach but tbh didn't look it up in the code

last swan
haughty rampart
#

Interesting

rustic rain
#

0.17 for entities
0.15 for collections

#

all can be obtained automatically by subbing to 42 preview of hybrid renderer

tepid abyss
rustic rain
#

you need android build package

tepid abyss
#

Yeah I have one

rustic rain
#

if you use subscenes you use build asset

#

if you don't you can build normally

tepid abyss
#

Oh, yeah I have some subscenes

#

But it seems like the app crash on start up

rustic rain
#

did you build with build asset?

tepid abyss
#

You mean that configuration file under Create->Build?

rustic rain
#

yeah

tepid abyss
#

Yeah I have one

rustic rain
#

that's the only way you build with subscenes

#

otherwise they won't be included

tepid abyss
#

Oh - so if I don't use subscenes, than I can build without that build asset like normal?

rustic rain
#

it worked for me

tepid abyss
#

Cool, I still have a crash on startup with 0.17, don't know why, but 0.16 seems fine (on android, not PC)

tepid abyss
karmic basin
#

Even without subscenes I would still build from the build asset. Unless you dig the source and make sure nothing else than subscenes matters in the process. Even then you might catch some bug in the future as building from build menu is not supported for DOTS

rustic rain
#

starting with 8f they made some incompatibility with collections, which can be fixed tho

tepid abyss
#

Okay so after some testing, it seems that subscenes did cause the problem, I now use the build asset without subscenes and everything seems fine (except I don't get input from Touch, but I'll get to that later)

rustic rain
#

are you using 'build' button from File menu or from asset button?

tepid abyss
#

actually from the file menu, I just now saw the button inside the asset file

rustic rain
#

yeah

tepid abyss
#

should I build it from there?

rustic rain
#

you build from there

#

otherwise

#

it's unused

tepid abyss
#

Oh, and I add the subscenes the same as regular scenes right?

rustic rain
#

you add subscenes in that file

tepid abyss
#

and what about regular scenes?

rustic rain
#

those build assets are quite useful when you have different options to quickly switch from when building

#

same thing

#

you just add all scenes oyu want to include in build

#

it's just that normal build menu doesn't accept subscenes at all

#

thus they won't be added to build

tepid abyss
#

Got it! gonna try it now thanks

tepid abyss
#

I get:
AssertionException: The scene catalog has not been loaded yet
I might be setting things not right

#

This is my configuration asset, does it seem ok?

#

I have a simple set up: SampleScene is the main loaded scene, and inside of it there is the GamePlay (sub)scene

#

Oh, before the The scene catalog... asset, there is this message:
Failed to load native plugin: Unable to lookup library path for '_burst_0_0'.
might be something

drowsy pagoda
tepid abyss
#

I think I tried it, but Ill test it again when I get home

robust scaffold
#

Oh come on unity

#

[Licensing::Module] Successfully connected to LicensingClient on channel: "LicenseClient-KornFlaks" (connect: 1.69s, validation: 0.05s, handshake: 2.20s)
[Licensing::Module] Connected to LicensingClient (PId: 14364, launch time: 0.02, total connection time: 3.93s)
Entitlement-based licensing initiated
[Licensing::Module] Error: Access token is unavailable; failed to update
Hrm

steel steppe
#

I have to convert and inject game object now just for a simple cube in a scene. Is this normal?

robust scaffold
#

That's 2018 levels of DOTS. back before the rename.

safe lintel
#

@robust scaffold convert and inject still exists, i think you were confusing [Inject] on component groups that preceded entity queries. @steel steppe yes its normal if you are needing the gameobject to hang around

robust scaffold
safe lintel
#

its not officially deprecated so its still not outdated

#

or I guess you could argue everything that exists currently is outdated 🥲

steel steppe
safe lintel
#

the destroy/inject refers to the gameobject, an entity is created regardless of which one you choose

worn valley
deft stump
#

wait... TAA can be accessed concurrently?

deft stump
#

is there a way to convert AnimationCurves for use in jobs?

safe lintel
#

use the one from the animation package? also there was a community made curve somewhere

steel steppe
#

I put a physics shape on a cube with convert and inject Game Object(it disappears otherwise) what's happening in my scene?

worn valley
safe lintel
#

@steel steppe do you have the Hybrid renderer installed? entities wont render if you dont

steel steppe
#

yep its installed

#

0.11.0 preview .44

safe lintel
#

did you enable it via scripting defines?

steel steppe
#

hmm

safe lintel
#

ENABLE_HYBRID_RENDERER_V2

#

not sure if v1 works with the renderpipelines

#

but v1 is deprecated

#

actually if it disappears could be a different problem, as I guess the entity is already rendering along with the gameobject in that screenshot

steel steppe
#

yea its rendering but i had to set it to inject for it to do so. maybe by enabling hybrid ill be able to set it to convert and destroy

#

hopefully everything starts working after

safe lintel
#

give it a name and see if that name exists in the entity debugger

#

when you use destroy

karmic basin
#

Should remove the box collider no ? Can't have both with the physics shape, right ?

steel steppe
#

loll i removed it and now the cube appears in the scene and slowly disappears xD

safe lintel
#

it might turn it into a compound collider? cant remember what is intended to happen with that tbh

karmic basin
#

never tried both haha 🤷‍♂️

steel steppe
#

prob a good idea to have only one!

karmic basin
safe lintel
#

sometimes meshcollider doesnt convert properly for me, imo best to always use physicshapes

steel steppe
#

from the top to bottom, the grey area disappears out of existence xD

#

is ENABLE_HYBRID_RENDERER_V2 still in projects settings > Scripting Define Symbols? because i cant find it o.o

karmic basin
#

hmm you have a moveable component that seems translate towards 0 0 0
Might be the culprit
where is zero in your world ? 😛

safe lintel
#

you add that line to the defines

steel steppe
#

maybe it moved?

safe lintel
#

you have to add that line to the defines

#

type it in

#

anyway from the previous screenshot: if your rigidbody isnt kinematic it will just fall to the floor or forever without any physics collider to stop it, use the entity debugger(window>analysis>entity debugger) to find it and see if the translation indicates its falling

karmic basin
#

yup seems like there's no ground

steel steppe
#

i put a physics shape on it now, so it stopped falling. There's still a weird black cube tho

#

nvm got it!

safe lintel
#

what was the cause?

steel steppe
#

now everything works 😄

#

it was the convert and inject

#

it made the grey cube disapear but the black cube was the good cube actually

#

although now it doesn't take materials so maybe that's another problem

robust scaffold
#

As another week rolls by, still no DOTS 0.50. Or, more importantly, Burst 1.7.2...

rustic rain
#

as long as you don't expect, waiting doesn't hurt you

steel steppe
#

were they supposed to release it soon?

rustic rain
#

they said Q1 if I'm not wrong

safe lintel
#

they've said many things at this point

rustic rain
#

as long as you don't expect, waiting doesn't hurt you

#

xD

#

I doubt we'll be able to start LTS projects in dots earlier than 2025

fallow mason
#

DOTS is following the nuclear fusion timeline - always a few years out.

stone osprey
#

How do i get a reference to an entity component ? I dont just want a copy ^^ im looking for something like ref var health = ref entityManager.Get<Health>(en);

#

Is there something like that ?

rotund token
#

there is not

#

if you add this extension

            where T : struct
        {
            return ref UnsafeUtility.ArrayElementAsRef<T>(array.GetUnsafePtr(), index);
        }```
you can get a ref via chunk iteration for a component though
stone osprey
#

Thanks ^^ is there another way which just takes an entity as a input ?

rotund token
#

no

#

using a ref breaks safety

#

the safety system has no idea when you stop referencing it

#

so while you could do it, you shouldn't do it

stone osprey
#

Hm... damn... that sucks... i still wanna do it :/

rotund token
#

if you do insist on removing all safety and having unexpected errors for years to come, to answer your question get an internal reference to EntityComponentStore and call

public byte* GetComponentDataWithTypeRW(Entity entity, int typeIndex, uint globalVersion)

#

but just realize doing this will completely break entities if you ever hold the reference past the end of the function (or use it in a job or anything)

#

you've been warned

lapis yoke
#

Is there a way to get all components of a type on an entry? It seems like GetComponentDataFromEntity only returns 1, but i might have multiple on the same entry.

rotund token
#

you can't have more than 1 of the same component on an entity

stone osprey
#

I am sure there was an easier way somewhere...
Probably im just thinking to complex but imagine following scenario...

You have a huggeee component with dozends of fields... there are incoming network changes and you dont wanna copy that component every time you change some stuff in it.

So it would make sense to have a ref to that component to just change like 1-2 fields instead of copying the whole component and setting it new... or am i wrong ?

rotund token
#

AddComponent<Translation>(entity)
AddComponent<Translation>(entity) -> this just does a SetComponent

#

that is a legit use of it genar

lapis yoke
#

Oh. That actually makes sense. Thanks. Guess I'll have to use DynamicBuffers 😣

stone osprey
rotund token
#

you are optimizing the wrong thing

#

get your network update into a job

stone osprey
#

Is the entitymanager so bad ? ^^
Oh i see, but how would this work ? Im using my own network solution ( using LiteNetLibs )...

rotund token
#

if you're using entity manager for network then you are stuck entirely on the main thread at this time

#

all your other cores are likely completely empty

#

(i'm not suggesting you have to try make it burst compiled which would be a lot more complicated unless you are using a native library)

stone osprey
#

Well thats true, i accept my network events on the main thread basically and forward them to my ecs entities by using the entitymanager ( and some buffers ).
So should i move my network logic to its own job ? Would this even work, because im using a non job network lib ?

rotund token
#

well for starters you can use entity manager in a job via ExclusiveEntityTransaction

#

and while this probably the most basic approach, it still lets you move the work off main thread

stone osprey
#

That sounds nice, thanks 🙂
But wasnt there some sort of limitation to jobs & allocation of arrays for example ?

I actually would need to allocate normal c# arrays because there a lot of network events containing them.

#

Ah shoot... guess that wont work

#

If i see this correctly jobs are limited to blittables and native containers

#

So i cant put my networking stuff in a job, because it needs to allocate normal arrays at some point

#

And i cant change those to native array and stuff because my server relies on plain c#

worn valley
#

I mean you can flop them back and forth between plain Arrays and native arrays. It isn't too hard. Just have to keep track and do a lot of mem copies

rotund token
#

you don't even need to memcpy

#

you can just pin managed arrays and make a native array point at it

#

NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray<>()

#

var handle = GCHandle.Alloc(myArray, GCHandleType.Pinned);

unsafe {

    var addr = handle.AddrOfPinnedObject();

    var nativeArray = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray<int>((void*)addr, myArray.Length, Allocator.None);
#if ENABLE_UNITY_COLLECTIONS_CHECKS
    NativeArrayUnsafeUtility.SetAtomicSafetyHandle(ref nativeArray, AtomicSafetyHandle.Create());
#endif
}```
something like this. Just make sure you call handle.Free() when you're done using the NativeArray
#

this is how you can read managed memory in burst jobs

stone osprey
#

WEll that on the other hand looks great 😄 Thanks ! Im gonna try this !

#

Another little question i have... i often use "component objects" on my entities ( Mono renderer, other mono components )... I add them later on, will this trigger a copy of the entity or is this fine because those are managed components ? No idea how that concept works with archetypes...

I just know that normal add,remove operations will copy the entity

robust scaffold
waxen quail
#

does DOTS runtime ( Tiny project BaseCodeLibrary) support only subset of 2.0 .net stanard

if I want to deploy to wasm with latest .net 5 ( the unified api) futures is it possiable with c# dot solution ?

as of what I understand the target platform (.net in this case) codes which compiled against Tiny project BCL is limited

but Microsoft release asp .net core .net7 framework to target wasm without blazor my question if I could integrate between unity's runtime with ..(net 5 TFM) on wasm or it's not possible atm

drowsy pagoda
#

I have a job that requires an UnsafeList. If I instantiate the list outside the job to feed into it as input, does this mean I have two lists now? Or just two instances of structs pointing to one list?

Later after the job, I take that list and pass it into a static function that will convert it to array and store it in a singleton of a class. It is there, during that conversion, that I call UnsafeList.Dispose().

Is it safe to assume that it disposed the actual list properly and freed up memory? Or did I need to Dispose the one in the job as well?

weak spire
#

what is dots

weak spire
#

google is banned in my country

#

kidding of course, just too lazy to google rn

#

but perhaps people are too lazy to explain as well

#

I suppose we're in a lazy standoff

low hazel
#

Or you can just not ask low effort questions.

#

The answer to yours, being at the very top of the google search. One click away.

weak spire
#

it was a joke, but thanks for taking it seriously

low hazel
#

👍

gusty comet
#

I currently have an IComponentData that a ton of jobs have as a write dependency. As a result, those jobs are always scheduled one after the other. If I were to instead make that IComponentData a read or not a dependency, and do writes using an EntityCommandBuffer, would those jobs finally start running in parallel?

worn valley
drowsy pagoda
#

Since the caveat of an UnsafeList is that there are no leaks checks and what not, would it be enough to just keep an eye on system ram to suspect leakage? Or are there more precise ways to keep your peripherals on your Unsafe containers?

karmic basin
karmic basin
drowsy pagoda
karmic basin
#

yeah I figured you would have nested containers hehe

drowsy pagoda
#

I don't like to...so it's a last resort, or if a workaround proves more tolling.

white island
#

What exactly are authoring components? They allow me to create (mostly) normal GameObjects and convert them into entities at runtime?

safe lintel
#

its just a monobehaviour with an interface that allows you to run custom code during conversion

#

unless you mean [GenerateAuthoringComponent] which if placed on an IComponentData struct, adds that component during conversion

white island
#

How does gameobject to entity conversion work

rotund token
#

i was working my own own DynamicHashMap for entities yesterday and I had this brain wave on how to do a 'ClearAndBatchAdd' to NativeHashMaps
This is adding 100k elements to a native hash map in parallel with Add()

#

this adding 100k elements with my new batch add in a single thread

#

previously 1.21ms to quantize my data and then Add 100k elements
now 0.09 to quantize my data, then 0.23ms in a single thread to add 100k elements

#

improving the performance of this job is something that troubled me 6-12months ago and just stumbling upon the solution feels so nice

white island
#

That’s awesome. Great feeling

#

Also. So. Could I theoretically, make a prefab that’s for an NPC with the necessary scripts, and then add the converttoentity script? I don’t fully understand. I tried doing they with a single rigid body cube and it crashed Unity so

rotund token
#

These days you should avoid the convert to entity script and use subscenes

#

But yes in theory that should work fine

white island
#

… subscenes? Man I have a lot to learn

safe lintel
#

Take a look at the samples repo if you haven’t already @white island

white island
#

this is like unlocking a whole new world... a few questions:
-Am I able to generate subscene assets from script or only the editor?
-Do all of the entity-ified gameobjects have to have authored components instead of monobehaviour? logic says yes but i want to make sure

rotund token
white island
#

hmmm

#

i imagine my monobehaviours will have to only use blittable types... I can work around that though

rustic rain
#

No, your ecs components are about avoiding managed types

#

Monobrhaviour doesn't exist in ecs world

#

So you either use authoring components to add ecs comps to entity during conversion

#

Or create conversion systems to do that outside of mono

white island
#

what are some good resources for learning how to use these conversion systems

rotund token
#

samples are probably the best

rustic rain
#

There's also manual that provides quite a lot of explanation

white island
#

are there links to the manual. All i have found so far are the package pages which while helpful make me have to piece everything together from the function definitions

worn valley
#

The classic engineer's mantra, "It was hard to make, it should be hard to learn!"

#

It really is frustrating how disjointed all the tutorials are on ECS. I did some prior work with ECS before it was on Unity's radar back in 2015, but it was still hard to understand how use it with Unity.

white island
#

great

karmic basin
bright cypress
#

Started making an ECS C# Comparison chart.

Didn't add DOTS/UECS yet, since it's still in preview & might have API/major changes.
Still added which ECS solutions support Unity, & by how much, burst, jobs, editor, etc.

https://github.com/Chillu1/CSharpECSComparison

deft stump
#

oh

#

that's really helpful

worn valley
bright cypress
worn valley
#

It was the first framework for ECS I used and was pretty good. I don't know how performant it was either. Was just getting into programming. Also hasn't been updated in 7 years so probably no good. It looks like it has an MIT license, but maybe not. What would make it a true MIT license?

bright cypress
# worn valley It was the first framework for ECS I used and was pretty good. I don't know how ...

Yeah, it probably still works fairly well. But newer, more optimized & better QoL-wise ways most likely have been discovered since. So using something so old wouldn't be beneficial for most, I think.

The license does strike me as odd. With the "All rights reserved.", but it seems to be "obsolete"/redundant. Since it's always "All rights reserved" by default.

Ah nvm, it seems to be the BSD license? But a modified one? Really wish they used the approx name of it on the copyright/top ngl

worn valley
#

haha yeah for sure. And I agree about not including unmaintained ECS systems. I had no idea there were so many other ECS systems that are being developed

bright cypress
worn valley
#

Well that is awesome, thanks for doing that. Really good chart. Would you want to include Unity's native ECS in there??

tepid abyss
#

Hey, it seems TextMeshPro shader is not compatible with hybrid renderer, anyone is using an alternative or solved this? I thought about create a custom one but just wanted to make sure

bright cypress
worn valley
#

Smort.

safe lintel
#

@bright cypress nice comparison, though I sort of disagree and think you should include unity's own given how largely it looms in comparison to other unity engine compatible ecs solutions, and its really not changing all that quickly(been static for over a year now). while dots is very much incomplete, the entities core is pretty solid and source is available for all the ecs based packages even if it isnt "open source".

bright cypress
# safe lintel <@!150970855466336256> nice comparison, though I sort of disagree and think you ...

Thanks

Yeah, I haven't been following the dots/ecs stack for a good while now, so don't know the current news/changes.

I'm not really "against" adding UECS. It's just that I would have to do some research & checks on it. While I don't want to use UECS in the future.
So I wouldn't mind if someone who uses UECS would list the feature support here or make a PR/issue with it's data.

"How largely it looms in comparison to other unity engine compatible ecs solutions,"
Some people would disagree hard with you right there.

tepid abyss
#

Hey, I managed to find SRP shaders for TextMeshPro that is compatible with Hybrid Renderer, but it seems like the MeshFilter upon entity creation is None, I assume that TMP is building them at startup (?) and when converting to entity they are not available? any ideas?

safe lintel
coarse turtle
tepid abyss
coarse turtle
#

I think you can query the vertices from the TextMeshPro component

safe lintel
#

(question marks are where my understanding of what the feature in question is lacking so unsure)

coarse turtle
#

and just copy it in Editor time

tepid abyss
#

You mean when converting the gameobject to entity?

coarse turtle
#

No just reading the vertices in Editor time, you can use ConvertAndDestroy to read it, but iirc TextMeshPro should have an ExecuteInEdit (or similar) mode attribute, so the vertices are generated in EditorTime

safe lintel
#

@bright cypress also the 0.0 in url links should be 0.17, google pulls up old versions for whatever reason instead of the latest

tepid abyss
#

Ok but accessing the vertices will eventually require me to mesh's for every entity font I create

coarse turtle
#

if your use case is you want to be generating meshes on runtime for any supported character, then you'll need a font mesh generating system

bright cypress
tepid abyss
#

I'll try to play around with TMP some more and see if I can maybe bake the mesh and store it in the entity upon creation

#

Oh - I guess it does take the mesh - but because I use Convert and Destroy, the mesh is destroyed (?), I assume this because when debugging I see that I have the right RenderMesh (and it contain the right mesh), but later on it becomes null

#

But when I come to think of it - I probably will need to go with your idea of creating the meshes my self, when I'll need to modify them the baked mesh wont suffice..

#

(I can choose not to destroy, but that will have a gameobject companion that I want to avoid)

rustic rain
#

if that's about Hybrid renderer

#

convert and destroy indeed destroys game object and then creates clone only with hybrid components

#

mesh renderer, mesh filter and etc

white island
#

Is there a way I can create a sub scene from a list of GameObjects within the script. (For a level editor)

rustic rain
#

doubt, but if it's supposed to be runtime exclusive

#

you can just create your own subscene alternative

#

as rn it's done by using special tags with reference to subscene

#

so you can do just your own component that will keep reference to your level entity

hot basin
#

how exacly .WithChangeFilter() works?

#

can I find "new" entities with it?

#

and how to properly use System State Components?

karmic basin
hot basin
#

so the only difference between state component and component is that the former is not deleted when entity is destroyed?

rotund token
#

yes you need to remove the components manually yourself

gilded glacier
#

is UpdateWorldTimeSystem internal ?

#

because I cannot access the type, despite having the proper assembly reference

rustic rain
#

some systems are private, not even internal

gilded glacier
#

docs say it's just public

karmic basin
#

looks public yeah

gilded glacier
#

what the hell ??

#

so ... I had to add Entities.Hybrid assembly reference, despite the fact it's located in the base Entities namespace ?

coarse turtle
#

it's in the Unity.Entities.Hybrid asmdef tho

#

so yea you would have to add Entities.Hybrid

gilded glacier
#

it would be so nice to be able to scream out loud right now

hot basin
#

so what about .WithChangeFilter()? it triggers on content changed or on creation? or both?

hot basin
#

can I use somehow ComponentType to get data from entity? .GetCompponentData<> needs name of the class

steel steppe
rustic rain
verbal pewter
#

Does anyone know how to check whether the values of math.quaternion are equal to NaNf. I can't find any mention of this value, and comparing the values to float.NaN or math.NAN doesn't return true.

verbal pewter
#

@tepid abyss Exactly what I was looking for, thanks!

hot basin
worn valley
# hot basin it's strange you can add/remove a component with `ComponentType` but not get it

This is because ECS is different from OOP. When you add or remove a component you are telling the computer to change the state of an Entity. It wouldn't be a good idea to now have this entity reference because that reference is a struct and thus not a reference at all. It is just data. If you update the component you received from for example a GetComponent (like you would in Mono) that data is just a copy and won't update the entity information if you change it.

#

That is why you need to get the data, modify it and then set it back to an Entity.

hot basin
#

but that's not the problem here

worn valley
#

Oh sorry then I didn't understand your question. My bad.

hot basin
#

I have common component with saved ComponentType of it's behaviour, I can do many things that way, like add and remove, even use in EntityQuery but I can't use it in EntityManage.GetComponent() which I need to update my UI as I have entity by Raycast

worn valley
#

So it is a component attached to an entity and you want to get the info? Is this is a For.Each loop?

hot basin
#

nope, but it's in SystemBase

worn valley
#

wait so GetComponentData<T>(Entity) doesn't return the struct containing the data??

#

hmm, I don't think I am qualified enough to help, sorry!

hot basin
#

I don't have the T, I have ComponentType

#

but i.e. ecb has possibility to use ComponentType like this: ecb.AddComponent(entityInQueryIndex, entity, nextNodeDefinition.ComponentType);

worn valley
#

ah yeah, I have no clue. That is an interesting use case.

coarse turtle
#

You might have to use the EntityManager.GetComponentDataRW(entity, typeIndex) although the method is internal & returns a pointer

#

also the method wouldn't exactly work if you're baking ComponentTypes onto entities in a subscenes, the type indices in Editor time != type indices in a build so you would get mismatches

hot basin
coarse turtle
#

yea

#

just stating that baking ComponentType into an entity in a subscene is a bad idea as the type indices would not match in a build

frosty siren
coarse turtle
#

Yea, I'm pretty sure I'm disabling something which is causing Editor types to not match Build types

frosty siren
#

also there is TODO in component type or TypeManager code, where dev tell to use hashcode or something to make type stable independent of type set changes

coarse turtle
#

Cool, I probably didn't see the comments since I'm only looking at the decompiled assemblies versus the actual source

hot basin
frosty siren
hot basin
#

but can I somehow setup ComponentType from inspector?

rotund token
#

add/remove a field, reorder fields, rename a field, change namespace etc

#

it's not considered safe to save component type indexes

#

this is why it's HIGHLY advised to not use SerializeWorld to save your games - any component change in your project will break your save files

#

you'd be much better off saving Type and converting it to a ComponentType at runtime

foggy hornet
#

Just a random question: Does Citites Skylines use DOTS? It's an old game but it seems like the perfect place to use the system.

worn valley
#

Probably not. Came our way before unity introduced their DOTS stuff

#

It may use Concepts around what DOTS does like proper data structuring

hot basin
#

it may use ECS as it's an old concept

hot basin
#

I wonder if I should rethink my approach with ComponentType. How do you guys update GUI?

#

I have Selectable units and buildings and I need a way to differentiate between them

#

any other way that I can think of is to make one:

Entities
                .WithAll<Selectable, Selected>()
                .ForEach((
                    Entity entity, 
                    in SELECTABLE_DATA_COMPONENT sdc) =>
                {
                    uiComponent.ShowSelected(sdc);
                })
                .WithoutBurst()
                .Run();

per every thing in my game

#

the only thing that will probably change is SELECTABLE_DATA_COMPONENT

#

as uiComponent.ShowSelected() is overloaded

north bay
#

enum+union could work depending on what data will be in SELECTABLE_DATA_COMPONENT

hot basin
#

oh yeah I forgot to mention SELECTABLE_DATA_COMPONENT will be many different components, I don't think union will work in this case

drowsy pagoda
#

I keep seeing that term union in relation to ECS. What does it mean?

safe lintel
#

where did you see that?

plain hatch
#

Does anybody know what the "conventional way" is for converting a given world position into a local position for nested Entities?

hot basin
#

invert localToWorld and multiply

#

if i'm remembering it correctly you need to do this from parent->child

#

so take l2w of parent, invert it and multiply by world position you need

#

if it's nested deeper you need to multiply the whole chain of objects: root->child1->child2->etc

coarse turtle
# drowsy pagoda I keep seeing that term *union* in relation to ECS. What does it mean?

could be in relation to 'c' like unions, where you can define the offset of a variable to be the same as another offset. (e.g. you can have 2 variables in struct at offset 0, meaning they share the same address). Overall it keeps your struct size smaller.

// The size of this struct is 4 bytes compared to a
// typical 8 bytes with sequential layout
[StructLayout(LayoutKind.Explicit)]
struct S {
  [FieldOffset(0)]
  public int ValueI;

  [FieldOffset(0))]
  public float ValueF;
}
drowsy pagoda
fresh ginkgo
#

Hey everyone, I have a question about rendering graphics on mobile devices while using DOTS. I read up a bit on Hybrid Renderer - documentation states that for now it's not suitable for mobile devices - it requires Vulkan which isn't comptabile with many android devices. Also Hybrid URP doesn't support point lights and shader keywords. So it looks like I shouldn't use Hybrid. How should I proceed with rendering then? Do I use DOTS for creating entities in code but render them using GameObjects?

half jay
#

is it a right decision store some data in dynamic buffer, but count of elements might be few thousands ? I thought better create some static NativeArray and store in it

rustic rain
#

but perfomance of dots on mobile is really meh

#

unless you have some high end project with big cpu consumption

fresh ginkgo
#

thanks for information, is DOTS performance on mobile worse then using regular GameObjects? or is the difference negligible?

rotund token
#

i think performance of dots on mobile can be amazing

#

it just unfortunately requires really strong knowledge of dots and a lot of experience

#

doing what comes naturally will probably not end with good results

fresh ginkgo
#

hm ok, I'm worried about the rendering though, if Hybrid renderer excludes many devices then I'm not sure how to proceed

rustic rain
fresh ginkgo
rustic rain
#

just think of it this way:
you get threading and poggers perfomance but you have to pay tax for it

#

which not worth for super casual games

#

allthough, tertle mentioned some "simple scheduling" which might make it better

#

I still haven't tried it

hot basin
#

I will send again my question as i'm genuinely curious about: How do you update GUI?

rustic rain
#

well, considering there's no built in UI

#

you just do it without burst

hot basin
#

but the issue here is (sorry for the pun) I need to differentiate between selected units to display proper values

Entities
                .WithAll<Selectable, Selected>()
                .ForEach((
                    Entity entity, 
                    in SELECTABLE_DATA_COMPONENT sdc) =>
                {
                    uiComponent.ShowSelected(sdc);
                })
                .WithoutBurst()
                .Run();

I need to do this for every different component I want to show as selected, seems like a lot of copy&paste

pliant pike
#

How are people dealing with Unity UI events with dots, like does anyone have a clue how I get a button press event in a system? 😕

hot basin
#

you can make managed component with reference to UIDocument

#

or Canvas or whathever

rustic rain
#

make a abstract system that already implements everything you want

#

and then just inherit from it

pliant pike
#

hmm 🤔 I'm thinking I might just do the simplest and have a monobehavour called UIEventcollector and have that create all the entityevent stuff

north bay
pliant pike
#

Yeah you could surely have a burstable job that finds the selected and then sends that to the UI stuff 🤔

hot basin
#

you don't need that, EntityQuery will suffice

hot basin
#

is there a way to EntityManager.Exists() in parallel?

drowsy pagoda
hot basin
#

if saved entity still exists

lucid lake
#

Is Unity still supporting ECS/DOTS?

worn valley
#

Yes, they are going to be releasing a new .50 version at some point this year. Current .17 does stop at 2020.3 though. So it is still a bit jank @lucid lake

lucid lake
#

Thanks. I will check it out again and look forward to v0.50

drowsy pagoda
# hot basin if saved entity still exists

You could use a ComponentDataFromEntity to check if entity has a tag. Create tag at conversion and don’t take it off. That way, if an entity doesn’t have it, it doesn’t exist. Think that will work?

worn valley
# lucid lake Thanks. I will check it out again and look forward to v0.50

There isn't much info other than it will be different and probably better. I think Unity underestimated how much time to get a real awesome ECS system going but I am pretty sure ECS is the future of game development as high core count becomes the thing in CPUs while processing power only goes slowly up.

lucid lake
worn valley
plain hatch
hot basin
#

I didn't know it even exist

#

probably Unity wrote that calculation for us already

worn valley
hot basin
#

like Traslation Rotation and Scale are automatically calculated to l2w

hot basin
#

Can I somehow get an Entity from instanced entity with ECB?

#

I get ArgumentException: All entities created using EntityCommandBuffer.CreateEntity must be realized via playback(). One of the entities is still deferred (Index: -1). when I try to do it

#

I'm assuming it doesn't get id before playback

rotund token
#

it does not

#

when you create an entity in ECB it's a virtual entity with a negative ID

#

any use of this entity in this ECB will be remapped to the correct entity on playback

#

for example you can do this

ecb.AppendBuffer(existingEntity, new EntityReference {Value = newEntity});```
#

and your EntityReference will be updated when the ecb plays back and your existing entity will have a reference to the correct entity

#

so yeah, you can only store these entities using ECB methods otherwise the entity is not valid until after playback

hot basin
#

I have a Spawner component with a FixedList

rotund token
#

you need to use a buffer

hot basin
#

yeah maybe it's better solution

rotund token
#

otherwise you'd have to do something like wait till next frame, check for newly spawned entities, add them to your fixed list then add a component to stop them appearing in next search

hot basin
#

I was thinking about additional component which will assign reference after the frame but your solution seems reasonable

#

as probably DynamicBuffer is here to keep lists

#

thanks!

cerulean pulsar
#

Hey, my Time.DeltaTime started returning 0. Does anyone know which ECS system updates this value so I can investigate? I must have broke something

#

I think I found it for my project: Netcode's ClientSimulationSystemGroup.cs

drowsy pagoda
rotund token
#

I've been coding with DOTS for 4 years, over 2.5 years professionally. I've read nearly the entire source code multiple times.

drowsy pagoda
#

Wow. Well it shows. Everytime I'm surfing the forums, I always stop to read all your responses. I learned more there than anywhere else haha.

verbal pewter
#

Hey all! I'm using the hybrid renderer v2 and am having issues with some entities flickering as shown in this gif. The brown background is a quad. This flickering only happens when the background quad is enabled. Any thoughts on how to fix this?

#

Solved it by changing the renderQueue value on the material.

fresh ginkgo
#

should I use Canvas and RectTransforms when using DOTS? do you guys create UI part of the game without using entities?

verbal pewter
#

@fresh ginkgo Yeah, you should use one of the UI systems. DOTS is more for the data in the game, less about presentation of that data.

#

I have two systems, A and B. System B is set to update after system A. System A is part of EndInitializationEntityCommandBufferSystem, while System B is part of BeginSimulationEntityCommandBufferSystem. System A uses EntityCommandBuffer.AppendToBuffer to add an element to a buffer. System B uses GetBufferFromEntity to retrieve that buffer. When searching in system B for the element appended to the buffer in system A, the element is not found until the next frame; the length of the buffer returned by GetBufferFromEntity is 0 in system B. Can someone explain why the element doesn't exist until the next frame, and if there are any work arounds?

rotund token
#

Is SystemA in InitializationSystemGroup and SystemB in SimulationSystemGroup or are they both in SimulationSystemGroup?

verbal pewter
#

Ah sorry, I'm not familiar with SystemGroups. I thought setting the CommandBufferSystem would do the trick. Sounds like I need to assign them to a SystemGroup?

rotund token
#

What it sounds like to me what you're doing is

EndInitializationEntityCommandBufferSystem Runs
SystemA Runs does AppendToBuffer in EndInitializationEntityCommandBufferSystem
SystemB Runs

Next Frame

EndInitializationEntityCommandBufferSystem Runs Applies AppendToBuffer change
System A Runs
SystemB Runs on updated change

#

Groups work like
Initialization -> Simulation -> Presentation
With a command buffer Begin/End on each side

#

All systems update in Simulation by default

verbal pewter
#

Aha, so CommandBufferSystems apply their changes during the next frame, not during the same frame those changes are queued?

rotund token
#

they apply it whenever they run

#

if you had a system update in simulation group then used endsimulation command buffer system thats teh same frame

#

anything in presentation (i.e. the renderers) would use the correct value

#

that all said, you should generally treat command buffers as a deferred action to the next frame.
this i because command buffers are performance killers as they cause sync points so you don't want these in the middle of the frame

#

anyway i was just heading to bed, hopefully someone else can step in if you still have questions

verbal pewter
#

Okay, thank you for the explanation. It makes much more sense now!

rustic rain
hot basin
#

can I convert objects without LocalToWorld, Transform and Rotation?

worn valley
#

And you can create entities without LocalToWorld but they are just floating in a nothing space then.

hot basin
#

not everything is rendered on the screen

#

the problem is conversion workflow will automatically add these on conversion

worn valley
#

Sorry, I really didn't understand what you were asking.

hot basin
#

np.

#

and I'm using conversion workflow to setup some values on those components

#

but every component will end up with those 3 additional components which seems unreasonable

rustic rain
#

or whole system

hot basin
#

probably just ignore it for now, everything seems like unreasonable amount of work for just an entity without transform

robust scaffold
#

Burst 1.7.0 is out and I think they fixed the burst inspector failing to update bug:

Fix a bug where if you had a long running compilation and a new compilation came in, some threads in the thread pool could (if unlucky) block trying to dirty the assembly in our Burst caching infrastructure while waiting for the compilation to complete.

Crossing my fingers this was the issue. Sounds like it.

#

Also hoping that they fixed the inspector burst compilation stalling unity.

#

You can highlight things and right click to copy things in the inspector now. Amazing

#

And you can now click on the arrows anywhere along the length to instantly move to the jump command that started the arrow and click again (without moving the mouse) to get the the jump destination

#

Honestly, text highlighting is the best feature I didnt know I needed until now. Considering I read text by highlighting where I am like my finger on a page ( I have a mild form of dyslexia, pain to read blocks of texts as my eyes skip entire lines ). Burst inspector isnt so bad but having this feature is so nice.

rustic rain
hot basin
robust scaffold
#

If you want to remove transforms from GO converted to entities, query for the transform component (translation and rotation) and just input that entity query into EM directly. Extremely fast.

#

Or, you could just construct all the required entities at runtime start.

#

0.50 will be changing this though. EM will no longer have overloads for EntityQuery chunk based actions on typical entity actions like AddComponent and whatnot. No clue what they'll be doing but that was confirmed as one of the breaking changes.

rustic rain
#

In conversion systems you query through game objects by their monobrhaviour components

drowsy pagoda
#

Are enums not compatible with Burst Parallel jobs? Or am I misunderstanding some here?

worn valley
#

Enums are just an integer. Should have no issues. I've never see that error before

drowsy pagoda
#

Yeah I'm just dumping my enum in Debug.Log. There can only be two values PickingUp and PickedUp. And it's reading it them like you see in the screen...

worn valley
#

It looks like that data is unitialized memory

#

so it's getting random values from whatever was in the memory before you assigned it

drowsy pagoda
worn valley
#

well I am all out of ideas

drowsy pagoda
# worn valley It looks like that data is unitialized memory

You were in fact correct! I confirmed that it was the case. I had a job that prepared data for writing, and I missed a condition, and so the data wasn’t being forwarded if no changes were made. As a result, it would leave the array item uninitialized in memory.

worn valley
#

haha, I've had so much screwy results cause I forgot to clear data cause I LOVE to intialized arrays with dirty memory. I want that sweet speed

#

glad I could help

drowsy pagoda
#

Yeah I can’t resist shaving every bit of performance cost I can either.

worn valley
#

have you been looking at the assembly created and trying to make that faster??

drowsy pagoda
#

Probably not as I am not sure what you mean.

worn valley
#

Oh so you can inspect the assembly code produced for jobs

#

and it helps you optimize everything. See where things have been vectorized.

drowsy pagoda
#

I also found out that if you SetComponent new Translation() or new Translation { Value = default }, it will also throw NaNs you must be explicit.

worn valley
#

It's really fun, but I can't stop

#

oh hmm, why would it throw NaNs. I would imagine it should throw 0, 0, 0

drowsy pagoda
#

Oh yeah, I've seen that. I am not that advanced though.

#

That's what I thought.

#

But I kept running into that error even though I fixed the fall through

worn valley
#

I can barely understand how the assembly code works but I can kind of see it getting shorter

drowsy pagoda
#

then when I explicitly set them...it worked.

worn valley
#

very weird, I wonder if to speed everything up all new components are uninitialized memory

drowsy pagoda
#

that's what I am assuming from now on.

worn valley
#

good call

#

I am only using Jobs, Burst etc, no ECS for my current project. So I just get to screw myself over with my own code

drowsy pagoda
#

nice.

hot basin
#

dots physics seems strange, constantly rebuilding collision world even if nothing changes

#

seems to mismatch queries as I don't have any PhysicsVelocity on my entities

karmic basin
hot basin
#

Yeah but I checked them with entity debugger

karmic basin
#

Sorry I don't understand your concern. Are you wondering why you have a PhysicsVelocity component though you didnt explicitely put one on your Entity ?

hot basin
#

I'm wondering why physics rebuild query shows a match while there is no PhysicsVelocity in my project, and thus rebuilding world

karmic basin
#

As to why the physics world is always rebuilt, that's what I would expect anyway from a stateless physics engine. Even if you don't intend to have PhysicsVelocity, it rebuilds even for static colliders (imagine wanting to raycast against a newly spawned building)

#

As to why your debugger seems off with the query matches you expect, I have no clue at first glance

#

maybe the entity cache is "behind" your actual setup

hot basin
olive kite
#

is burst 1.7 not available through package manager?

karmic basin
worn valley
karmic basin
#

looks like it's out of preview since yesterday if I trust the package manager (but dates were wrong for latest entities release, so.... ^^)

rustic rain
#

Where can I find changelog?

karmic basin
olive kite
#

hmm yeah, usually that's how it is but not showing up for some reason

karmic basin
#

maybe takes some time to propagate around the world ?

#

some kind of DNS cache issue maybe 🤷‍♂️

#

and what about the manager last refresh time for you ?

olive kite
#

current time where I am at

#

maybe not released for 2021.1 yet

karmic basin
#

last resort, you can always explicitly declare it in the manifest

olive kite
#

Yeah, I will end up doing that, was just curious why it wouldn't show

#

thanks for the help

karmic basin
#

gtg grab a snack, good luck, I just spent hours solving assembly conflict - _ -

olive kite
#

fun

karmic basin
#

yup you're welcome

misty wharf
drowsy pagoda
#

Notice Prefab tag, all systems ignore entities with this tag unless explicitly included in query...

#

Which in your case you should not include that.

coarse turtle
#

Prefabs are not queried by default unless you include them into your query options

drowsy pagoda
#

You will need to store a reference to Prefab entity (usually during conversion) then use EntityManager.Instantiate or ecb.Instantiate passing in that entity Prefab as argument. Then it will create the entity you want to be processed by your system(s)

misty wharf
#

Ah that makes sense, the approach gave me a bad gut feeling from the start. Do you have any tips how i can create actual entities from my created prefab ? Before i only used archetypes but the don't really support children and initialized rendering components as i understood them

#

Ok @drowsy pagoda i will try that. Thanks for the answer

#

That was it. Fantastic, thank you !

dull copper
#

"This session will cover the improved Editor tooling in the upcoming Data-Oriented Tech Stack (DOTS) 0.50 release, including the Hierarchy, Inspectors, Profiler modules, Systems window, and entities journaling. It will also address a new Editor workflow, coming in Entities 1.0, which allows artists, gameplay programmers, and level designers to author with familiar GameObjects, while giving engine and systems developers easy access to the runtime state made of entities. Other new features to be covered include the ability to record all data and structural changes in a searchable journal and author scenes during Play mode and retaining those changes when exiting Play mode."

karmic basin
#

This looks huge

#

So that's what the "further announcements to come Q1 2022" was all about then, waiting for GDC ? Can't wait

safe lintel
#

I hope an actual release accompanies these talks or precedes them, and it isn’t some hand wavy “it’s coming soon in the future guys, promise!”

karmic basin
#

Aouch, it's in-person. So I figure I'd have to wait 3 years to eventually see it on Youtube 😭

worn valley
#

Dear gosh I hope there will be a way to totally skip the GameObject conversion and just do my own entity creation that isn't a huge pain in the butt

safe lintel
#

I think you are hoping in vain

cerulean pulsar
#

Does anyone have any tips for using FMOD with DOTS?

rustic rain
karmic basin
dull copper
#

it doesn't mean we miss the info itself... or that Unity wouldn't stream something themselves

#

also they've marked that talk to have vault recording so there's a real chance that even if they didn't broadcast the talk live, it would be available in gdc vault few weeks after the event (unless it goes behind vault's paywall but sponsored talks like this don't usually go)

low oyster
#

Hello guys. How would you set data to the MeshFilter component? I am creating an entity as bellow but I can't manage to set data to the MeshFilter component like I do with the RenderMesh shared component:

protected override void OnUpdate()
    {
        EntityManager.DestroyEntity(GetSingletonEntity<InitIcoSphereComponentData>());

        EntityArchetype icoSphereArchetype = EntityManager.CreateArchetype(
            typeof(IcoSphereComponentData),
            typeof(LocalToWorld),
            typeof(RenderMesh),
            typeof(MeshFilter)
        );

        Entity icoSphereEntity = EntityManager.CreateEntity(icoSphereArchetype);

        Mesh mesh = GenerateMesh();

        EntityManager.SetSharedComponentData(icoSphereEntity, new RenderMesh
        {
            mesh = mesh
        });
    }
karmic basin
#

thanks for that insight @dull copper

karmic basin
#

it's converted to a MeshComponent IIRC This looks wrong, can't remember where I saw this component but it does not seem involved in rendering

low oyster
#

@karmic basin yeah that's what I saw. So, do you have any idea how I can modify anything related to the MeshFilter?

karmic basin
#

You don't really need the meshfilter in ecs land if I'm not mistaken

#

the hybrid renderer will use the mesh in the RenderMEsh component

#

(am not a pro at rendering though, I let Unity handle it for me :P)

low oyster
#

humm ok 🙂

#

Gonna try without it

#

thanks

karmic basin
#

during conversion the gameobject mesh filter + renderer get converted as a RenderMesh

#

looks like you're trying pure ECS, check the hybrid renderer manual, IIRC they show how to create an entity at runtime

#

with what you need to make them render correctly

#

they do it from a job but hopefully it helps

low oyster
#

yes thanks gonna check it, and yes I am trying pure ECS.

karmic basin
#

Yeah so I just checked the Utility method they used in the manual and it adds a bunch of necessary components for rendering for you

#

(there's more, screenshot cropped)

low oyster
#

ok I see so basically I don't need to add manually LocalToWorld it seems as well

karmic basin
#

yup

low oyster
#

it adds all the dependencies

#

ok

karmic basin
#

yup

#

same for renderbounds if it's missing your object is culled but you don't especially know at first 🙂 and so on...

low oyster
#

true

karmic basin
#

actually the comments explain it xD the source itself is well documented, they did a good job on that

low oyster
#

Seems to "work", I have my 6 entities representing my 6 faces of my sphere properly generated as bellow image, but nothing on the game vue, did I miss something?

lofty sequoia
#

Is there a list somewhere of the platforms that DOTS supports?

rustic rain
#

to build dots you need special package for each platform

#

I'd say all those packages are basically a list you are looking for

#

it's in package info down in the bottom

safe lintel
#

See the hybrid renderer docs for runtime creation @low oyster

low oyster
#

@safe lintel Thank you but I guess that's what I did following my code:

protected override void OnUpdate()
    {
        EntityManager.DestroyEntity(GetSingletonEntity<InitIcoSphereComponentData>());

        EntityArchetype icoSphereArchetype = EntityManager.CreateArchetype(
            typeof(IcoSphereComponentData),
            typeof(Transform),
            typeof(LocalToWorld)
        );

        Entity icoSphereEntity = EntityManager.CreateEntity(icoSphereArchetype);

        EntityArchetype sphereFaceArchetype = EntityManager.CreateArchetype(
            typeof(Transform),
            typeof(LocalToWorld),
            typeof(LocalToParent),
            typeof(Parent)
        );

        NativeArray <Entity> facesEntitiesArray = new NativeArray<Entity>(6, Allocator.Temp);
        EntityManager.CreateEntity(sphereFaceArchetype, facesEntitiesArray);

        Vector3[] directions = { Vector3.up, Vector3.down, Vector3.left, Vector3.right, Vector3.forward, Vector3.back };
        for (int i = 0; i < facesEntitiesArray.Length; i++)
        {
            Mesh mesh = ConstructMesh(10, directions[i]);

            RenderMeshDescription renderMeshDescription = new RenderMeshDescription(
                mesh,
                new Material(Shader.Find("Standard")),
                shadowCastingMode: ShadowCastingMode.Off,
                receiveShadows: false
            );

            RenderMeshUtility.AddComponents(facesEntitiesArray[i], EntityManager, renderMeshDescription);

            EntityManager.SetComponentData(facesEntitiesArray[i], new Parent
            {
                Value = icoSphereEntity
            });

            DynamicBuffer<LinkedEntityGroup> buffer = EntityManager.AddBuffer<LinkedEntityGroup>(icoSphereEntity);
            buffer.Add(new LinkedEntityGroup
            {
                Value = facesEntitiesArray[i]
            });
        }

        facesEntitiesArray.Dispose();
    }
low oyster
#

ok got it

#

Basically LocalToWorld data for my parent entity and LocalToParent data for the childs had to be set:

// Parent - LocalToWorld
EntityManager.SetComponentData(icoSphereEntity, new LocalToWorld
        {
            Value = float4x4.TRS(
                 translation: new float3 { x = 0f, y = 0f, z = 0f },
                 rotation: new Quaternion { x = 0f, y = 0f, z = 0f, w = 0f },
                 scale: new float3 { x = 3f, y = 3f, z = 3f }
            )
        });

// Childs - LocalToParent
EntityManager.SetComponentData(facesEntitiesArray[i], new LocalToParent
            {
                Value = float4x4.TRS(
                    translation: new float3 { x = 0f, y = 0f, z = 0f },
                    rotation: new Quaternion { x = 0f, y = 0f, z = 0f, w = 0f },
                    scale: new float3 { x = 1f, y = 1f, z = 1f }
                )
            });
hot basin
#

can I somehow get existing BlobAssetStore for manual conversion?

blobAssetStore = new BlobAssetStore();
var conversionSettings = GameObjectConversionSettings.FromWorld(defaultWorld, blobAssetStore);
knightPrefabEntity = GameObjectConversionUtility.ConvertGameObjectHierarchy(knightPrefab, conversionSettings);```
this is my current code but I would like to use existing AssetStore to prevent many copies of the same prefab
karmic basin
low oyster
#

yes I did

karmic basin
#

I think you mixed between Translation and Transform, but if you set LTW, doesnt' matter now ^^

low oyster
#

I guess the transform component write automatically into LocalToWorld or Parent depending if I work on the parent or the childs, and it's an easier component to manipulate if you only change the position

karmic basin
worn valley
#

The translation updates LocalToWorld at some point during your frame. But you could set it and then try and grab some other info and it isn't up to date. I just dumped using Translation and only use LocalToWorld. And just write helper classes to set the position and rotation of a LTW matrix

low oyster
#

oh I see

safe lintel
#

theres float4x4.TRS(t,r,s) where t = translation, r = rotation, s=scale if you didnt know of it

karmic basin
#

Which already existing one you're trying to access anyway ? You could cache your own and work with the same when you need

hot basin
#

I'm doing both conversions, by ConvertToEntity and custom script (Monobahviour)

#

and I would like to prevent creation of same prefabs if it happens to be subject to both

karmic basin
#

Oh then if you use conversion it's actually easy, grab the store from the system (stripped unrelevant code)

public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) {
            var registry = BlobAssetExtensions.CreateReference(itemMap, Allocator.Persistent);

            // Add the generated blob asset to the blob asset store.
            // if another component generates the exact same blob asset, it will automatically be shared.
            // Ownership of the blob asset is passed to the BlobAssetStore,
            // it will automatically manage the lifetime of the blob asset.
            conversionSystem.BlobAssetStore.AddUniqueBlobAsset(ref registry);
            
            dstManager.AddComponentData(entity, new ItemDefinitionRegistry {
                Registry = registry
            });
        }
#

assuming your MB implements IConvertGameObjectToEntity

#

got to go for now, hope I was not offtopic with your question

hot basin
#

Can I somehow make a list of Entities in managed component? I can make a Entity field to work as prefab reference so it will be automatically converted, can I do same with a list? I'd like to use [GenerateAuthoringComponent] and skip writing it by hand as I know it would be a solution.

rustic rain
#

object component can be quite anything

#

as it won't be bursted or paralleld

#

Really wish they'd add some ScheduleMainThread so you can schedule unbursted jobs

#

instead of running them

robust scaffold
#

As in you can do that right now.

rustic rain
#

how?

#

I mean

robust scaffold
#

My entire loading sequence is in a job, unbursted since it deals with string deserialization and reflection. But it works since it's not bursted.

rustic rain
#

jobs with managed components

robust scaffold
#

The only requirement for a job is that the data interface between mainthread UNITY and jobs is blittable unmanaged. You can use managed components if you construct them within the job itself.

#

I'm going wild with classes, strings, reference components, and so on inside a job. The output back into Unity has to be either blittable to fit inside a Native Container. or I could write the results into a json file, then in mainthread unity, read from that file.

#

That json round trip is kinda terrible though so I very rarely use it.

#

All of these are done in a struct job. inlined jobs are a lot more restrictive and feels half baked

hot basin
rustic rain
#

ah, you care about serialization?

#

can't help in this one

low oyster
#

Morning guys. Do you have a general rule that you apply to define when to use a job and when not to?

still pewter
#

I personally use it only when necessary for performance. It can be tempting to jobify everything and squeeze out all the performance possible, but it's most of the time not really necessary. I tend to make everything in the standard way, and profile to see what to improve. Or sometimes when I'm sure it's going to be performance heavy, like a path finding system, I'll make it a job to start with

#

Anybody has experience with instantiating and destroying an entity in the same frame before it has reached the playback?
I have a projectile which spawns an attack entity that will, in the same frame, check which targets are in range and damage those and disappear again.
But it's giving me the error that "all entities created using entitycommandbuffer.create entity must be realized via playback()"

#

Would it be better to simply delete them next loop? Or is there a way to keep the entity deferred?

hot basin
#

Jobify everything that's easy to do

#

Next jobify what you need to for performance reasons

#

If you need to rewrite some code you need to weight cost of rewriting vs eventual performance gain

hot basin
calm edge
#

is there any way to specify priority with jobs?

low oyster
robust scaffold
robust scaffold
#

You can use EntityManager in a job if it's a .Run() job without Burst

low oyster
# robust scaffold Yes. Or suffer through ExclusiveEntityTransaction (which will break everything).

Ok in this case I have a lot of questions. Let's assume I start with:

var ecb = endInitializationEntityCommandBufferSystem.CreateCommandBuffer().AsParallelWriter();
        Job.WithoutBurst().WithCode(() =>
        {

        }).Schedule();
  1. In mostly all the ecb methods they required an int sortKey where do I get this?
  2. How to set data to a component using the ECB? Meaning, the equivalent of EntityManager.SetComponentData()
  3. Run() or Schedule()? Any tips to chose the right one?
robust scaffold
#

Lambda job only can do single threaded for now. You must use struct based job for multithreaded.

hot basin
#

you still need it whe you ScheduleParallel()

robust scaffold
#

As for the rest, if ya want to wait uhh 30 min for me to get to my laptop, I can answer but I bet someone else here also has answers.

low oyster
#

Thanks for your answers of course I'll wait 🙂

hot basin
#

this and ForEach both are using "lambda jobs"

dense crypt
#

Hello, I've written an authoring script that converts a string to a SharedComponentData of FixedString128. When I close my sub-scene I get an error: Failed to deserialize Property=[Value] for Type=[Unity.Collections.FixedString128]Are FixedStringXXX not supported for subscenes?

robust scaffold
# low oyster Ok in this case I have a lot of questions. Let's assume I start with: ``` var e...

Right. Here's an example in which EntityManager is used directly inside a job (I personally recommend this as ECB is just like taking out loans, you'll need to pay the performance cost with interest later):

Job.WithCode(() =>
{
  var newEntity = EntityManager.CreateEntity(typeof(ComponentA));
}).WithStructuralChanges().WithoutBurst().Run();

Notice the .WithStructuralChanges(), .WithoutBurst() and .Run(). Note, I just relocated to the end the WithoutBurst but it doesnt matter where it's located.

If you ant to use a generic ECB, here's an example:

var ecb = new EntityCommandBuffer(Allocator.TempJob);
Job.WithCode(() =>
{
  var newEntity = ECB.CreateEntity(typeof(ComponentA));
}).Schedule();

// Do something here.
Dependency.Complete();
ecb.Playback(EntityManager);

Note that I now used Schedule to shift the job onto a thread but I still need to call Dependency complete before I can playback. Also note that I now removed .WithoutBurst() as ECB can be used in burst compiled jobs, with some restrictions. Namely anything dealing with shared component data can not be burst compiled.

#

Now if you want to use endInitializationEntityCommandBufferSystem, this basically shifts the Dependency.Complete(); and ecb.Playback(EntityManager); to another system at the end. You still are calling playback, just the "Do something here" is other systems.

#

So for example:

var ecb = endInitializationEntityCommandBufferSystem.CreateCommandBuffer();
Job.WithCode(() =>
{
  var newEntity = ECB.CreateEntity(typeof(ComponentA));
}).Schedule();

endInitializationEntityCommandBufferSystem.AddJobHandleForProducer(Dependency);
#

The issue wit ECBs is, like I said, akin to taking out a loan from the performance bank. You're enabling threaded "changes" to the entity component store done during the main systems update but those changes havent been applied to the actual entity store yet and will need to be "played back" on the main thread rather slowly.

low oyster
#

thanks for the examples!

robust scaffold
#

ECBs are ideal when you have large computation to determine whether you should structurally change a very small amount of entities. Otherwise, for large scale changes, directly modify with EntityManager.

#

And most ideally of all, dont use either. Structural changes such as adding or removing entities or their components should not be done at all.

#

Memory is cheap. Memory is free. It's far better to just pre-allocate all components ever possibly needed and use bitflags to determine what is "enabled" than use structural changes to modify the chunks.

#

Well, no. There are certain cases where structural changed tags win out. Specifically when components change in real time seconds rather than frames.

#

If something needs to have a component or entity added and removed every frame, use a component with a bool signifying if it's enabled or not. If it's being added or changed every second (i.e., every hundreds of frames), take the hit and use EntityManager directly in a job. EntityQuery performance gains by filtering wins out in the long run.

low oyster
robust scaffold
low oyster
#

no

robust scaffold
#

Alright, i'll not do that then

#

Give me a sec. I in fact uninstalled Entities (rolling my own ECS solution now with a bunch of native arrays) so the actual code may come out wrong. I'm basing this entirely on my own memory of DOTS API

robust scaffold
# low oyster no

Do you want the best performance way or the easiest to understand way?

low oyster
#

the best performance way 🙂

#

I usually prefer to learn the hard way

robust scaffold
#

Alright. i'll try to explain what I'm doing. How well do you know Burst?

robust scaffold
low oyster
#

thanks

robust scaffold
low oyster
#

my private method where I generate the face mesh

#

do u want it?

robust scaffold
#

Nah. I this part probably cant be bursted anyways

#

Well, it probably can but that is a whole other can of worms

low oyster
#
public Mesh ConstructMesh(int resolution, Vector3 localUp)
    {
        Mesh mesh = new Mesh();

        Vector3 axisA = new Vector3(localUp.y, localUp.z, localUp.x);
        Vector3 axisB = Vector3.Cross(localUp, axisA);

        Vector3[] vertices = new Vector3[resolution * resolution];
        int[] triangles = new int[(resolution - 1) * (resolution - 1) * 6];
        int triIndex = 0;

        for (int y = 0; y < resolution; y++)
        {
            for (int x = 0; x < resolution; x++)
            {
                int i = x + y * resolution;
                Vector2 percent = new Vector2(x, y) / (resolution - 1);
                Vector3 pointOnUnitCube = localUp + (percent.x - .5f) * 2 * axisA + (percent.y - .5f) * 2 * axisB;
                Vector3 pointOnUnitSphere = pointOnUnitCube.normalized;
                vertices[i] = pointOnUnitSphere;

                if (x != resolution - 1 && y != resolution - 1)
                {
                    triangles[triIndex] = i;
                    triangles[triIndex + 1] = i + resolution + 1;
                    triangles[triIndex + 2] = i + resolution;

                    triangles[triIndex + 3] = i;
                    triangles[triIndex + 4] = i + 1;
                    triangles[triIndex + 5] = i + resolution + 1;
                    triIndex += 6;
                }
            }
        }
        mesh.Clear();
        mesh.vertices = vertices;
        mesh.triangles = triangles;
        mesh.RecalculateNormals();

        return mesh;
    }
robust scaffold
#

Let me just finish this one.

robust scaffold
#

I die a little inside every time I use a lambda job but this should work. Should as in I havent run it through a linter yet. Just Notepad++

#

I added comments for every change I made.

low oyster
#

wow thanks so much I am gonna read all this

robust scaffold
#

I managed to burst and parallel-ize the setting of components except for the mesh creation. Which I honestly have no clue what that does. I dont have experience with meshes, at all.

#

The key is pre-allocation and data oriented code processing. DOTS is a frag shader. Operate along entities like you're operating along pixels of a texture.

robust scaffold
low oyster
#

linkedEntityGroup I guess

robust scaffold
#

line 49, should be for(var i = 1; i < FaceCount + 1; i++)

#

Yea

#

Or for(var i = 1; i <= FaceCount; i++)

#

Otherwise yea, it should be okay

#

The last Job.ForEach isnt really needed to be in a job. It should just be plain code but eh

robust scaffold
low oyster
robust scaffold
devout prairie
#

We had the dots update yet?

safe lintel
#

Sadly no @devout prairie

devout prairie
#

I think they said Q1 right, maybe

#

curious to see what it'll bring

safe lintel
#

Yeah q1. Hoping it’s soon but sorta expecting a delay regardless of the scheduled gdc talks

worn valley
#

There are two constants in this life, taxes and delay of Unity ECS. Which I am not surprised about since changing 10 years of programming mentality for one of the largest engines on the market is no small task

bold totem
#

Hi all, I'm trying to use Unity Physics (asking here because I guess its specific to DOTS?), and receiving an index out of range error every (fixed?) update even doing the "getting started" cube with a sphere that drops on it scene setup. Is this a known issue? I'm on 2021.2.8 with unity physics 0.6.0

#

the error is in the Broadphase collision script, apparently

Unity.Collections.NativeArray`1[T].FailOutOfRangeError (System.Int32 index) (at <15e405c9beda435fb78db5a973118bc4>:0)
Unity.Collections.NativeArray`1[T].CheckElementReadAccess (System.Int32 index) (at <15e405c9beda435fb78db5a973118bc4>:0)
Unity.Collections.NativeArray`1[T].get_Item (System.Int32 index) (at <15e405c9beda435fb78db5a973118bc4>:0)
Unity.Physics.Broadphase+DynamicVsDynamicFindOverlappingPairsJob.Execute (System.Int32 index) (at Library/PackageCache/com.unity.physics@0.6.0-preview.3/Unity.Physics/Collision/World/Broadphase.cs:1052)
Unity.Jobs.IJobParallelForDeferExtensions+JobParallelForDeferProducer`1[T].Execute (T& jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.jobs@0.8.0-preview.23/Unity.Jobs/IJobParallelForDefer.cs:62)
#

the line in question is

NodePairIndices[arrayIndex++] = new int2(Ranges[i].Root, Ranges[i].Root);

but I'm not going to pretend i understand much of the script haha

worn valley
bold totem
#

oh! i missed that

worn valley
#

Yeah, it isn't clear. The documentation is hard to keep track of cause it is always changing

bold totem
#

thanks for the heads up, let me try in 2020.1

#

oh cool this is old enough that the package manager just works in the background with no UI and then fails 5 minutes later 😄

robust scaffold
worn valley
#

oh shoot, I forgot I can't post gifs here.

devout prairie
cunning perch
#

They’ll most likely talk about 0.50 at the GDC.

rotund token
#

they have a few specific dots presentations scheduled for GDC (unlike nothing last year)

#

i would not expect 0.50 before this

#

Considering the biggest changes in 0.50 are debugging tools this kind of lines up

#

This session will cover the improved Editor tooling in the upcoming Data-Oriented Tech Stack (DOTS) 0.50 release, including the Hierarchy, Inspectors, Profiler modules, Systems window, and entities journaling. It will also address a new Editor workflow, coming in Entities 1.0, which allows artists, gameplay programmers, and level designers to author with familiar GameObjects, while giving engine and systems developers easy access to the runtime state made of entities. Other new features to be covered include the ability to record all data and structural changes in a searchable journal and author scenes during Play mode and retaining those changes when exiting Play mode.

rustic rain
#

so I guess by Q1 they mean 31.04 xD

deft stump
#

maybe 03/31

#

still technically q1

full epoch
#

yes I also think it(dots, ecs v0.50) will be published before march 31 - hopefully lol (edit : i mean march 31 2022 - I honestly hope that rule of thumb : "when Unity set some date add 2y to know the exact date" will not work in this case xD)

stone osprey
#

Crafting, Building recipes... would those be entities on their own or rather just pure data attached to the player ?
I mean they arent that dynamic at all... like BuildRecipe{ Ingredients[], Result, requiredLevel, ...} so i assume it doesnt make sense to design recipes as a own entity ?

stone osprey
uncut rover
#

Hello, I'm trying to instantiate a prefab entity that has a child game object that is not converted. if I place the prefab in the hierarchy it works fine. If I spawn the prefab through a spawning system, both the parent and child seem to be converted even if the game object has a stop conversion component. Any one has any Id how to make it work ?
Details : https://forum.unity.com/threads/spawning-prefab-with-child-gameobject.1249525/

karmic basin
safe lintel
#

@uncut rover might need to store the animated gameobject as a managed prefab on your entity, and then use a mainthread system to instantiate it right after the entity is created

uncut rover
uncut rover
#

@safe lintel It's ugly but it works, thanks.

safe lintel
#

thats how I feel about hybrid 🙂

worn valley
#

Just like a Prius

viral sonnet
#

Unity is dropping the ball so hard with DOTS communication. I asked for patch notes on dec 9th. (the notes are being worked on. We'll share more details as we get closer.) - So, march 31st will be very optimistic. I expect a delay yet again.

haughty rampart
#

yeah, we just got told to 'wait like adults' in the thread XD 😪

safe lintel
#

would take 2 months to answer some forum questions supposedly 🙄

haughty rampart
#

well i mean the thread has derailed massively because of people so i do kinda understand it. although it wouldn't have had if unity would've been more active in the first place.

safe lintel
#

silence breeds anxiety, the other examples where they communicated well(.net) are pretty clear that some sort of dialogue goes a long way to sooth frayed nerves

haughty rampart
#

omg i just hate the auto remove of this discord

safe lintel
#

auto remove?

haughty rampart
#

yeah, when messages are just instantly deleted

#

they said they'd publish a changelog a few weeks before release of 0.50. which they said will release Q1 2022. ...well, there's less than 4 weeks left...

stone osprey
#

However... another little question, how do we design chained actions in an ecs ?

Like : Make player move to position XY -> When he reached his target -> Build house-> When he interrupts that movement -> Cancel house building
I have a component that controlls the movement, basically interpolates the player to reach his desired movement target... however i cant find any nice structure for those chained actions

safe lintel
#

how would you approach this in oop?

primal pond
#

Is this the correct place to ask Burst related questions? If not, let me know and I will ask my question in the appropriate channel:

I have editor code that is part of an Asset Store Product. It uses Jobs, and I'd like those Jobs to make use of Burst when the burst package is present and Burst Compilation is enabled. However, the jobs should be useable without Burst being present and I don't want to force my users to download the Burst package. Is there someway to detect if Burst is added and compilation enabled using conditional compilation or some other means? Basically, I'd like the BurstCompile attribute to be ignored when Burst is not present. Is this possible?

rustic rain
#

Aren't jobs already depend on burst?

#

That's like main reason to use jobs in the first place

hot basin
rustic rain
#

I could be wrong

primal pond
rustic rain
primal pond
#

Yes, that's what I was hoping for but I cannot find any information about burst symbols being defined for conditional compilation

rotund token
#

then just wrap your

[BurstCompile]
#endif```
but an even cleaner approach is to create your own BurstCompileAttribute that only exists if burst is not found
```#if !UNITY_BURST
namespace Unity.Burst {
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Assembly)]
    public class BurstCompileAttribute : System.Attribute {
        // Add public properties and constructors
#endif```
#

this avoids you having to wrap every BurstCompile attribute. If burst is not found it'll just use your local copy.

#

I use this pattern for things like Netcode [UpdateInWorld] etc so my systems can work in both netcode or regular projects

primal pond
primal pond
# rotund token on your asmdef you can do something like this

So this works; the only caveat is that the assembly definition file needs to be reimported after adding/removing the burst package, in order for the Version Define to be updated and either add or remove the UNITY_BURST symbol. This means my user needs to still perform some action, however at least it is a simple enough action for them to do.

rotund token
primal pond
#

I tried adding an assymble reference to Unity.Burst.Unsafe.dll as well, hoping that would trigger a recompile when the burst package is added/removed, but that did not work either

#

I feel like this is a bug since the whole point of the version defines is to make code work/not work depending on packages installed. It doesn't make much sense that the defines would not be updated automatically when one of the packages is installed.

safe lintel
#

it should just work? its how unity do conditional stuff between packages(like the different rps, checking if input package exists etc)

rotund token
#

i think you need to regenerate your project files for your ide to realize it's changed

devout prairie
#

There's a known problem where the sub-quantum spin-reciprocator can phase-shift just enough to throw off the calibration of the field stabilizers but it only normally happens when you're overriding mass-deviance within the toroidal dimensionality adjusters..

#

Sorry wrong channel!

pulsar jay
#

Does anybody use dots with domain reloading disabled? I encountered an ObjectDisposedException: The Unity.Collections.NativeHashMap2[Unity.Entities.Hash128,Unity.Entities.BlobAssetReferenceData] has been deallocated, it is not allowed to access it error in the line I am trying to dispose a BlobAssetStore

primal pond
#

Yes, you were right. It was just the IDE not updating. Thanks!

pulsar jay
#

Can anybody help me with finding a memory leak? It looks like the "Other Native memory" is gconstantly growing with about 2MB/s but I cannot narrow it down any further

#

I have no clue how to go on as there is no indication what that "other" memory actually is

analog edge
pulsar jay
#

I even tried disabling all Systems and all gameobjects and it still keeps allocating more memory

analog edge
#

could it just be garbage? does it go down after the GC goes off?

pulsar jay
#

I dont think its garbage as that would be managed memory wouldnt it?

#

Thats the most likely allocation I could find. But the only thing that line tells me is that its a native array at a specific address. I have no clue how to trace that back to the allocating code

analog edge
#

hm, and you have all your systems disabled?

safe lintel
#

might have to bite the bullet and just search every instance of new NativeArray or other collections you use and check to ensure its disposed. how big is the project?

vital sandal
#

Is there an equivalent to Quaternion.lerp in the Job system? (not slerp)

dense crypt
vital sandal
rotund token
inner estuary
#

is it possible to convert a vector3 to a float3?

solar spire
inner estuary
#

could you elaborate please?

#

or viseversa, a float3 to vector3?

solar spire
#

Have you tried converting between them

inner estuary
#

i dont know the process for that, so before wanted to know if even possible to convert

#

to be specific, just the x values of those

solar spire
#

what? Just the x values? What does that mean, the x values are floats

inner estuary
#

ahh yes so that should be pretty easy to convert right thanks

tribal juniper
#

how do you go about implementing jumping in a character in dots

haughty rampart
#

just like normal? change it's y position

pulsar jay
pulsar jay
#

Actually I have one native array left to dispose. It is part of SharedComponentData. Is there a way to dispose anything when a SharedComponent gets "destroyed"?

tribal juniper
pulsar jay