#archived-dots

1 messages Β· Page 103 of 1

warm topaz
#

I'm actually making my own font sprite but would like to make an animation system later.

willow plaza
#

Maybe you should try modifying the UV property offset instead.

warm topaz
#

Which property would that be?

willow plaza
#

That's how I do animations based on the codemonkey tutorial. I have a spritesheet and pick a sprite from it by setting the correct UV width/height and offset.

#

Not sure about standard shader, I'm using a transparent unlit one.

warm topaz
#

Hmm. I'm looking for a shader with normal maps, spec maps, emission maps, and maybe occlusion maps as well.

worldly pulsar
#

what render pipeline are you using?

warm topaz
#

Maybe both lol.

#

Universal and HDRP.

worldly pulsar
#

You can't be using both -.-

warm topaz
#

I can if I am targetting multiple platforms.

#

But lets just pick HDRP for now.

dull copper
#

you actually CAN use multiple

#

it's just not supported or endorsed by Unity

#

plus things get complicated fast due to differences between the RPs

worldly pulsar
#

in URP writing Vector4(tiling_x, tiling_y, offset_x, offset_y) to _BaseMap_ST works for me

#

I assume there is an equivalent in HDRP

#

@dull copper you mean like switching between render pipelines at runtime?

dull copper
#

yeah

#

I did a proof of concept with LWRP and HDRP runtime swapping a long time ago when Unity staff insisted it can't be done

#

after that they just said it's strongly not recommended and not supported πŸ˜„

worldly pulsar
#

hah, the scariest thing in the world - a programmer having a "hold my beer" moment πŸ˜„

dull copper
#

I haven't tried on any recent version... my main concern would be if the shaders from other would be stripped etc

#

but that should be somewhat easy to fix as the relevant code is on c# side

#

I have a real reason to want that, altho I hope I never have to go there

#

I'm using HDRP for my main project but it doesn't scale down to low end devices that nicely

#

so having some crappier graphics mode using URP or built-in is something I could consider swapping into for these computers

#

in ideal case, HDRP would have just some super slimmed mode that doesn't do anything fancy... for example UE4 has one

worldly pulsar
#

Yeah, can see how swapping SRPs at runtime would be useful, just always assumed the resource management differences between them would mean trouble. (Do SRPs manage their shaders/vertex buffer layouts/textures sent to the GPU, or is that done at the lower level they all share?)

#

Last time I tried looking into SRPs was back in the early days when looking the wrong way caused the editor to crash, so I kinda gave up on learning them πŸ˜›

dull copper
#

each have their own managers for that kind of stuff afaik

#

if you have both URP and HDRP packages on your project, you can just simply swap the SRP asset from the settings via script

#

this mechanism is originally designed to be used for swapping SRP assets for the same SRP but different default confs

#

but there's nothing preventing you from swapping HDRP asset to URP asset there too

#

after that you have to swap to compatible shaders for each material, swap sky system, tweak lighthing etc

#

there's like dozen things that would change there

worldly pulsar
#

So that would cause each SRP to have their copy of every mesh/texture on the GPU?

dull copper
#

when I did the test, I only implemented HD template scene swap

#

ah, I dunno about those

#

anyway, one could have really funky bugs with this approach that Unity would never solve πŸ˜„

worldly pulsar
#

b/c that may kill the "swap for low end devices" use case

#

(apart of the whole "swap every shader everywhere" thing being kind of terrifying)

dull copper
#

I dunno, you could just load different scene variant

#

you could automate the conversion 100%

#

I mean, nobody would do that kind of work manually

#

there's one thing that's kinda difficult nowadays and it's the shader graphs for URP... since nonHDRP SG's still work on HDRP, I dunno which one it would pic for the compilation target in the editor

#

if you use PBR Graph on URP and save it, it generates URP variant for it.. if you have HDRP and use PBR Graph, it generates HDRP variant for it, it's not the same shader on both, only same graph

#

of course you could just generate the shaders manually and save them as shaders instead of shader graphs for the other option

#

but yeah, I'd rather try to put effort in trying to make HDRP have some slimmer mode than going through all this nonsense

safe lintel
#

i do wish hdrp had more options to strip it down, and make it look super ugly but run faster

warm topaz
#

I already have two versions of every asset. One for SD (URP) and on for HD (HDRP). Different scenes for different versions. Though, if it's too much work, I will probably just have two different projects for the SD and HD versions and reuse code and assets where I can.

I can try _BaseMap_ST when I get back later, but can anyone confirm that this is the way to do it in HDRP with the standard shader?

worldly pulsar
#

I suspect the name in HDRP is different (but the convention is {TextureName}_ST). Look at the HDRP Lit shader

hollow sorrel
#

looks like the next step for entity conversion is node based tools

#

seems they are doubling down on gameobject > entity conversion instead of entity editor tools

safe lintel
#

ive made my peace with conversion. i just want native ecs parts faster though πŸ˜‰

safe lintel
#

that tool looks interesting though i guess from that example such a thing wouldnt be that high up on my wishlist for dots features

soft nova
#

@warm topaz Cannot use Quaternion.LookRotation since it will flip over when the direction changes from left to right, ended up using quaternion.RotateY, but I don't like this approach

trail burrow
#

@soft nova If you're dealing with full 3d rotation and want to reason about it found that spherical coordinates work really well

#

i.e. for doing logic like 'how far left is this of me', etc. and other shit that both quaternion and euler are annoying for

vagrant surge
#

gameobject->entity conversion does make a lot of sense

#

a lot of game projects have some sort of "bake" step that optimizes in-editor into runtime friendly stuff

#

but at the moment its more of a bandaid and quite buggy

#

and has some very funny shit like only being able to have 1 component per file

#

great unity, let me have 50+ files each of them of 3 lines of code

verbal pewter
zenith wyvern
#

At the top

#

And no it looks like it's not supported yet even in 1.1

verbal pewter
#

Alright, thanks

verbal pewter
#

I'm having trouble using an enum as the key value for a NativeHashMap. Getting the following error: The type 'RockMine.CityGen.Networks.GrowthRoles' cannot be used as type parameter 'TKey' in the generic type or method 'NativeHashMap<TKey, TValue>'. There is no boxing conversion from 'RockMine.CityGen.Networks.GrowthRoles' to 'System.IEquatable<RockMine.CityGen.Networks.GrowthRoles>'. [Assembly-CSharp].

#

Been searching around but no luck finding similar cases. It works with dictionaries so I assumed it'd work for NativeHashMap, but maybe there's some limitations I don't know about?

mint iron
#

can you implement IEquatable<T> on GrowthRoles?

trail burrow
#

@mint iron can't add interfaces on enums by hand

#

they should exist

#

@verbal pewter I would think this is a unity bug

#

assuming that RockMine.CityGen.Networks.GrowthRoles is a real enum

#

it should handle it fine

verbal pewter
#

It is

mint iron
#

ahhh... yeah 😊

verbal pewter
#

Hmmm, guess I should report it.

zenith wyvern
#

Not ideal but you could just use an int as the key instead and convert it

trail burrow
#

unity bug then, @verbal pewter workaround is to use int instead and cast

verbal pewter
#

Alright, thanks πŸ™‚

trail burrow
#

casting from enum to int is a nop

#

so

fast moss
#

Hi everyone, I am trying do this : transform.up = hit.normal during a raycast but in ECS. as Entities can't have Transform, I need to do it by hand or by using something else. I saw that there is something called LocalToWorld but I don't know if it is applicable. Do you guys know How I can do that ?

Second question : I would like to know how I can make my entity rotate around an axis. just like transform.LookAt(Vector3) but only around a given direction. I don't know if it is possible but it would make my life easier πŸ™‚ Maybe something like Rotation.LookAt(Vector3 target, Vector3 axis)

tawdry tree
#

@fast moss Entities have things roughly equivalent to transforms (Translation, Rotation, Scale). You would use them for both of those things. Link with documentation: https://docs.unity3d.com/Packages/com.unity.entities@0.0/manual/transform_system.html
The first part is essentially setting the rotation to one derived from a raycasthit normal. IIRC Rotation uses quaternions, no sure about ECS physics raycasts, but you might need to do some conversion there.
As for the second one, vector and matrix math is where I started to really fall off in math classes, but what you want is to set the rotation such that the forward vector is towards another point (getting the direction is trivial: TargetV3-OriginV3), while maintaining some 'up' direction. it would be more correct to do this as one matrix operation, but honestly if you could solve the look at problem, you could then just rotate around the lookAt axis to have your up be correct.
That's just how I would think about this; hopefully someone else has more familiarity with the APIs in question and can give you more specific directions.

fast moss
#

@tawdry tree thanks ! I'll read this, I was looking for a documentation for the new Entities package but I wasn't able to find what I wanted πŸ˜‚ I'll try some stuffs and if I manage to do what I want I'll tell you πŸ˜‰

verbal pewter
#

Just want to clarify, is it possible to change a value in an entity component from a Monobehaviour by getting it using GetComponentObject and changing the value? Or would changing that just change the local struct's value?

tawdry tree
#

Components are structs, and as such passed by value, not reference. You need to use the entity manager helpers (SetComponentData and the like) as you would from ECS. World.Active.EntityManager Should be available from monobehaviors too, IIRC

zenith wyvern
#

World.DefaultGameObjectInjectionWorld

verbal pewter
#

I'm curious what the difference between GetComponentObject and GetComponentData is in that case?

zenith wyvern
#

"ComponentObject" is Unity's name for a monobehaviour that's been attached to an Entity

verbal pewter
#

Ahhhhhh, so I need to use GetComponentData.

zenith wyvern
#

ComponentData is just to get regular old IComponentData

verbal pewter
#

Makes sense, thanks πŸ™‚

opaque hemlock
#

Hey guys, do you know if there is a way to use the PlayerInputManager and still take advantage of DOTS?

hollow sorrel
#

@opaque hemlock typically for input you'd have a system that runs at the start of the frame and reads input from somewhere (e.g. Input.getkey or rewired or whatever new inputmanager uses) and sets input components such as playerinput that has jumpingPressed and float2 movement etc

#

just looked up playerinputmanager cuz apparently it's a monobehaviour and docs say

Note: These components are built on top of the public Input System API. As such, they don't do anything that you can't program yourself. They are meant primarily as an easy, out-of-the-box setup that eliminates much of the need for custom scripting.
#

so ideally you'd make your own version that doesn't use a monobehaviour

#

but if you really want to use it you could add the monobehaviour to an entity and poll it in your inputsystem

opaque hemlock
#

ah okay great thanks @hollow sorrel !

untold night
#

I've got a system that adapts player input manager and the player input monobehaviours via hybrid ECS. I just pull what I need during the Init system group phase and write it to a "raw input" component struct. Further processing is entirely in pure ecs

zenith marsh
#

Hello guys, I am currently experimenting with DOTS trying to create some floating island made of cubes of different sizes.
Until now I relied on Mathf.PerlinNoise(float x, float y) function to create the 3D noise used to build my islands. But now I am looking for some performance improvements so I tried to use Unity Mathematics cnoise(float3) function thinking it would be faster, but at my biggest surprise using this function slowed the process by about 20 times.
I am simply triple looping over my island size et computing perlin noise for each point.
Am I doing something wrong? If anyone has some ressources talking about how to use Unity Mathematics's perlin noise I would be gratefull, thank you!

hollow sorrel
#

@zenith marsh new math lib is optimized for burst but tends to be slower than Mathf in mono

#

il2cpp build should be a lot faster than mono but in-editor will still be slow so would prob be best if you can compute noise in a burst compiled job so it's fast in both

zenith marsh
#

@hollow sorrel Thanks for the info, so if I understand well, I should find a way to compute my noise in a job instead of doing it in a Monobehaviour script ? Then both editor and build would have better performances because it would use burst?

hollow sorrel
#

yes

zenith marsh
#

Okay I will try to do that then thank you!

verbal pewter
#

Welp, just learned that IComponentData can't have NativeContainers as fields. Now that I think about it that makes sense, but I'm left wondering what the best practice is for dealing with IComponentData structs that need to reference NativeContainers? My first thought is storing the NativeContainer on my singleton manager, but that makes me feel dirty. Are there different best practices for this?

north bay
#

Why do your components need to reference NativeContainers, can you replace them by DynamicBuffers?

verbal pewter
#

I have two different use cases right now. One is needing to store a NativeList of Nodes and Connections for each Network. Items will be added to this list on a regular basis. The other use case is a NativeHasMap in the NetworkSettings component that stores GrowthPatternSettings. I'm not familiar with DynamicBuffers so let me look into those a bit more.

trail burrow
#

These can be put on a component

#

tbh is a big oversight on unitys part that the collections can't be put on components, i understand that why in the general sense you usually wouldn't want that - but ofc there's A LOT of cases where being able to pair a collection with an entity in an easy way is by far the best solution to whatever problem is at hand

dire frigate
#

any news on compiling burst to linux?

verbal pewter
#

@trail burrow Interesting, thanks! To be honest, I'm not very familiar with "unsafe" code. Did some reading just now and have a general understanding, but I'm not sure I understand it enough to use those types safely. Are there any special considerations that need to be made when using them? As an example, at certain points in the program NetworkSettings gets overwritten with new data. This doesn't happen very often, but I still don't want to use UnsafeCollections in that situation naively. Would it be a bad idea to use them in situations where the data gets overwritten?

trail burrow
#

@verbal pewter well you need to free the memory by hand, like you do with unitys native collections

#

thats about it

#

The same thing would happen if you over-wrote one of unitys collections, etc.

#

Main difference is that the unsafe collections dont have any leak detection, compared to unitys

#

but the leak detection is the reason you cant put them on components... so πŸ˜„

verbal pewter
#

Alright, makes sense. And freeing the memory is done by using Dispose()?

trail burrow
#

no, there's a CollectionType.Free(ColletionType* ptr) on each of them

#

i.e. UnsafeHashMap.Free(map);

#

UnsafeList.Free(list);

#

etc.

verbal pewter
#

Ahhhh okay

#

Thanks for putting together that collection, going to save me a lot of headache along the way I think haha

trail burrow
#

np, there's a few concurrent collections coming also i've been fiddling on

#

mostly fairly narrow use-cases tho for those

#

Which ones are available there @digital scarab ?

#

tell me about it, i wrote the serializer for us which can handle serializing pointer/generics, etc.

#

it's a fucking mess

#

nested collections of collections of collections with pointers back and forth

verbal pewter
#

Oh, ya, that's a consideration...

trail burrow
#

@digital scarab Which package are these in?

verbal pewter
#

So for serialization sake DynamicBuffers are the way to go?

#

Yeah, makes sense

trail burrow
#

@digital scarab lol looked at the hashmap you guys have

#

its so similar to my code haha

#

i mean not many ways to do a fast unordered hashmap

#

just funny when even variable names are close :p

#

okey closer inspection, not that similar

#

was just alloc method (First i saw) that was similar enough πŸ˜„

#

anyway, looks good

hollow sorrel
#

fholm says as he hits cancel on the call to his lawyer

trail burrow
#

lol?

#

what? o.O

hollow sorrel
#

is joke

trail burrow
#

oh, lol i get it now

#

okey yeah i wish i had the patent on hashmaps

#

i'd be raking it in πŸ˜„

verbal pewter
#

@digital scarab Trying out the built-in UnsafeList, but I'm not sure how to release the list properly once I'm done with it. I'm guessing it's with the Destroy() method, but I'm getting this error: Argument 1: cannot convert from 'Unity.Collections.LowLevel.Unsafe.UnsafeList<int>' to 'Unity.Collections.LowLevel.Unsafe.UnsafeList*' Which is probably because I'm trying to use it on a copy of the data rather than the pointer? Not familiar with this stuff at all haha

zenith wyvern
#

@verbal pewter Unless you're comfortable with pointers and unsafe code, you should just stick with DynamicBuffers

#

They let you attach resizable arrays to entities and they are integrated nicely with ECS

trail burrow
#

... yeah but not every problem can be solved by an array

verbal pewter
#

Pretty much.

zenith wyvern
#

My point is DynamicBuffers should be the first suggestion. If for some reason your problem can't be solved using those, THEN you should consider unsafe code.

#

What is it about DynamicBuffers that doesn't work for you?

verbal pewter
#

I need to be able to access the values with keys, so I was hoping to use a HashMap.

zenith wyvern
#

You want to attach a hashmap to an entity? What exactly are you trying to do?

trail burrow
#

the problem is looking up values on keys? πŸ˜„

verbal pewter
#

The struct NetworkSettings has a number of GrowthPatternSettings that need to be accessible by the enum GrowthPatternType.

zenith wyvern
#

Are you sure NetworkSettings needs to be a component? It can't be it's own NativeContainer?

trail burrow
#

that can be solved with an array and casting the enum to an int tho

#

or rather a NetworkSettings* buffer

#

or in this case, a dynamicbuffer

#

and just cast to int to lookup

verbal pewter
#

What if the GrowthPatternSetting has one GrowthPatternType value which casts to the value 2?

trail burrow
#

size the array on maxvalue+1 and accept the memory waste

#

assuming that max isnt like 521232

#

or something else

zenith wyvern
#

If in the end you decide you really need a unique container attached to your entity I suggest you read this

#

And use the NativeArray source as reference

#

Build a simple nativecontainer and go from there

verbal pewter
#

Okay, will look into it. Thanks!

zenith wyvern
#

If you're going to use other people's nativecontainers you should still read that so you have some idea what's actually going on under the hood

trail burrow
#

@zenith wyvern the native containers still cant be put on components tho

zenith wyvern
#

I thought the Unsafe ones could?

trail burrow
#

yes the ones in Unity.Collections.LowLevel.Unsafe can

#

but native container means something specific tho doesnt it?

#

i.e. the Native<T> structs

#

and the ones in my repo can, ofc

zenith wyvern
#

Yes, and if he wants to start writing unsafe containers he should probably learn from the higher levels ones first, which are built around the unsafe ones

#

For someone with no experience with low level memory management the nativecontainer attribute is a great place to start

verbal pewter
#

Ultimately it probably makes the most sense to use @trail burrow's implementation since it sounds like Unity's built in unsafe containers aren't straightforward to use.

zenith wyvern
#

I haven't used fholm's containers, he obviously knows what he's doing so I can't speak to that, all I can suggest is that if you can find any way to fit your problem into a DynamicBuffer, you should

#

Especially if you're not really comfortable with low level memory management, it will save you a headache in the end, trust me

trail burrow
#

I agree, if you can make your problem fit in DynamicBuffer, use it.

#

Or rather, lets put it like this: If you want to learn how to deal with memory yourself, using unsafe collections and such is a great starting point. But if all you want to do is to move on from this problem and keep working on your game then you will inevitably blow your foot off with the native mem at some point.

#

There's nothing to be 'scared' of when it comes to unsafe C#, native mem or pointers.

#

It's easy to get your head around, it's not some dark magic

#

But it might take a little while to change your thinking compared to dealing with C#s garbage collected reference types

verbal pewter
#

Fair enough. But it sounds like that's already the case with NativeContainers? I guess my understanding at this point is that if I need to overwrite some data in one of these collections, I need to release the data that was stored in the collection first. As long as I have a straightforward method of making this happen (which it sounds like Unity's built in unsafe containers don't have) I should be good to go, right? There's always the chance of forgetting to unlocate it, which is definitely a risk worth considering. Or am I over simplifying it?

trail burrow
#

changing the data of the collection itself, i.e. what elements are in the hashmap for exampled

#

doesn't require you to 'free' anything

#

(assuming that the data itself doesnt contain pointers to other allocated memory ofc)

zenith wyvern
#

Basically there's a good reason Unity makes it so complicated to attach an array to an entity, and DynamicBuffers will protect you from all the pitfalls that entails while keeping it sufficiently simple

trail burrow
#

i can only answer for my collections, but what you need to remember is this:

1) When adding a component with the collection pointer on it, allocate a new collection
2) When removing a component with the collection pointer on it, free the collection
#

that's it

sonic oyster
#

Hi

#

I'm struggling with garbage collection that comes from allocating NativeArray's

#

My voxel world checks for neighbour XYZ (-1 to +1) chunks and grabs Block Data NativeArray from there, but if the chunk is not yet generated, i have to create temporary NativeArray

#

but

#

when i actually generate A LOT of chunks at the same time, GC is slowing down the game by ~10-20 frames

#

and all the garbage comes from those allocated Natives

#

so, my question is

zenith wyvern
#

Disposing a nativearray should only allocate in the editor

trail burrow
#

It's the dispose sentinels afaik

zenith wyvern
#

Try disabling safety checks

trail burrow
#

Could be editor only yes?

sonic oyster
#

can i somehow create empty nativearray?

#

without alloc

#

to pass to job

#

and inside job check if it's created?

#

because when i try to do Allocator.None it yeets an exception

#

and i can't just simply not allocate those NativeArray's, because - exception

#

@zenith wyvern i'll try, gimme a minute

trail burrow
#

If you need high throughput/lots of allocations, i would advise using UnsafeUtility.Malloc manually and just allocate the data you need, and doing voxel stuff seems like a fairly high throughput scenario

#

No need to restrict yourself to unitys native<T> wrappers, i mean NativeArray<T> is just a wrapper around a void* ptr + int length

sonic oyster
#

this is why every chunk has it's own NativeArray of BlockData

#

and i just pass them as readonly for render jobs

#

so i don't copy them over

#

@zenith wyvern disabled those and still GC hits hard

zenith wyvern
#

Profile standalone build

verbal pewter
#

@trail burrow So I was over complicating it πŸ˜‚ Thanks for the explanation!

trail burrow
#

np

sonic oyster
#

@zenith wyvern gonna try compile it, maybe it wont be as laggy as it seems @ build

#

but in editor i'm getting around 35fps

#

and i don't have bad pc

zenith wyvern
#

Make sure you attach the profiler to it, you'll see the allocations are gone

#

Assuming those are in fact the source of the allocations

sonic oyster
#

ok!

#

aaaaaand it didn't even work, lol

#

brb, bugfix time

#

@zenith wyvern ok GC is gone in build

#

thanks!

gusty comet
#

Is there any way to get the parent or child entity while in gameobject conversion? I mean the real converted child/parent entity not the prefab entity

gusty comet
#

ok i just connected them with GetPrimary entity

remote coyote
#

Is there a way to get isPlaying status when running a unit test I wonder? Since scene loading's async operator seems to require the isPlaying status to work (otherwise we just have OpenScene in editor), this prevents me from testing some of the functionality of my game code, and not exactly easy to mock async operator in this case...

#

I guess some code just isn't meant to work with unit tests and I should just manually test this area of the code.

#

Hm, thinking about this, I could apply the adapter pattern to this, and simulate the async operation internally when in editor mode when isplaying is false.

dull copper
#

is there any preferred approach to debug draws (lines etc) for DOTS?

#

or is this still something that everyone has to improvise with?

#

I remember some usermade early ECS linerenderer but I doubt it's up-to-date anymore

#

I guess I could just use thin cylinder meshes for this purpose....

#

or arrows

amber flicker
#

Samples have a gizmo example which might be the way Unity see things being done for now

dull copper
#

you mean dots physics samples?

#

I think they do it on monobehaviours there

#

those physics samples barely use dots

#

and afaik, you need monobehaviour to draw those gizmos too

#

I guess I could just populate some list of vectors in native container and sync it between dots and monobehaviours where I actually do the draws

#

but it really feels like there should be something directly on dots for this

amber flicker
worldly pulsar
#

btw, I assume you mean drawing in the game view? Because Debug.DrawLine still works just fine for drawing in scene view

dull copper
#

but surely you still need monobehaviour for it?

worldly pulsar
#

you don't

dull copper
#

ah

#

@digital scarab is that in current a18 already?

#

I'm fine with using 2020.1

#

I hope a19 is getting out soon as well for other reasons :p

#

but yeah, things are still tad slow after holidays, need patience

trail burrow
#

@digital scarab it'd be amazing to have a "BURST_ENABLED" and "BURST_DISABLED" constant or something so we can put [Conditional("BURST_DISABLED")] on methods and have them automatically be stripped when burst is enabled or not

#

Manually having to comment code in/out depending on if burst is enabled or not

#

is annoying to say the least

mint iron
#

@dull copper i wrote something for debug drawing, and it can draw from within burst jobs (by using a NativeStream). I won't claim its production ready but if you just need to see some stuff easily while developing, it should be fine. https://github.com/jeffvella/UnityDebugDrawer

verbal pewter
#

Is there a way to filter entities by the DynamicBuffer they have?

trail burrow
#

@digital scarab reverse would be nice also

zenith wyvern
verbal pewter
#

@zenith wyvern Very nice, thanks!

trail burrow
#

@digital scarab lol

#

but you have to see why it would be useful to be able to switch a methods implementation based on if burst is enabled or not for example?

#

i.e. BURST_ENABLED or BURST_DISABLED

dull copper
#

@mint iron sounds good, I'll check these options out πŸ™‚

#

have you tried that on recent 0.4 entities btw?

#

ah, it has demo scene, I'll just try what happens

#

Assets\DebugDrawer.cs(1162,33): error CS0426: The type name 'BlockStreamData' does not exist in the type 'NativeStream'

#

well, it was expected as these APIs evolve a lot

#

tried with 0.4 entities and collections

mint iron
#

mmm, its a few months old now, ill take a look

#

i'm moving to montreal next week πŸ™‚ not sure im quite prepared for the cold...

mint iron
#

/sigh they renamed it and moved to internal

dull copper
#

unfortunately stuff like that is quite expected, hence wanting to see some official solutions as they would be kept up-to-date

mint iron
#

very true; this is only a problem because i wrote a clear method for NativeStream; i didn't want to allocate them every frame.

verbal pewter
#

I'm curious if there are any best practices for dealing with general use functions that get used by multiple systems relating to specific entity archetypes? As an example, my Network entity keeps a buffer of child Node entities. The nodes aren't related to any systems directly, they're just used within the Network related systems. My first thought is to create a helper class for the Node entities that can be accessed from anywhere. Is there a better way of approaching this?

tawdry tree
#

Dunno about best practice, but as long as they have no side-effects, public static helper classes should be non-problematic. If they operate on a specific data type you could even make them into extension methods, though I don't see why you would unless you were making a library for others (or yourself, down the line) to use

#

And to add to that, I've seen several other people also use it.

verbal pewter
#

Alright, thanks for the input. Can't think of a better way to handle them so I might as well do it πŸ™‚

#

If I have a list of lists, does disposing the parent list dispose the child lists as well?

trail burrow
#

@verbal pewter What type of list?

#

NativeList<T> or UnsafeList* ? It's no for both

verbal pewter
#

A NativeList with NativeLists.

trail burrow
#

Need to dispose it all by hand

#

no automatic stuff here, sorry πŸ™‚

verbal pewter
#

Alright, thanks!

#

Should've guessed πŸ˜„

tawdry tree
#

Speaking of extension methods,

public static void DisposeWithChildren<T>(
  this NativeList<NativeList<T>> parentList)

would be one case where an extension emthod would be kinda useful.

verbal pewter
#

Yeah, my situation is a bit more complicated. As an example, I have NativeList<MyStruct>. MyStruct has a field which is a NativeList. Still probably makes sense to go that route and just create a one-off extension method.

#

Or helper method at least. Can you even have a NativeList extension method if it's not a generic type, such as public static void DisposeWithChildren<T>(this NativeList<MyStruct> parentList)?

tawdry tree
#

Minus the <T>, that looks valid

verbal pewter
#

Ah, switch out <T> for <MyStruct>?

tawdry tree
#

Extensions methods are just syntactic sugar.

public static void ExtensionMethod(this object extendedObejct) { /*stuff*/}

//Used like
var obj = new object();
obj.ExtensionMethod();

//it becomes this when compiling:
ExtensionMethod(obj);
#

As long as you have no generic argument, you don't need the <T> between method name and arguments.

verbal pewter
#

Ahhhh okay, nice. It works πŸ™‚

tawdry tree
#

So yes, think of extension methods as static helpers that have extra syntactic sugar which lets intellisense/code suggestions tell you it exists.

verbal pewter
#

Yeah, I've used them in the past but hadn't tried it for non-generic lists.

tawdry tree
#

I've mostly used them for giving myself more convenient access to often-used helper methods on non-owned types and enums.
In fact, 'adding methods to enums' is probably my number 1 use of them. But other that than, adding methods to built-in or library types. And in one more recent case, extending a particular type from one solution I worked on, in another solution with a specific context. (The first solution being a nuget package shared between several other solutions)

verbal pewter
#

Oh interesting, hadn't considered adding them to enums.

verbal pewter
#

Hmmmm. So I just finished up refactoring everything to DOTS and tried playing the project for the first time, but it threw the following error:

```Unexpected exception Burst.Compiler.IL.Helpers.MethodDecoderException: Unable to decode RockMine.CityGen.Networks.GrowthStrategies.RoadGrowthStrategySystem+<>c__DisplayClass_OnUpdate_LambdaJob0, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null::RunWithoutJobSystem(Unity.Entities.ArchetypeChunkIterator*, Unity.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null|System.Void*, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089) ---> Burst.Compiler.IL.Helpers.MethodDecoderException: Unexpected char < while decoding assembly name reference, expecting , instead of <>c__DisplayClass_OnUpdate_LambdaJob0, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null::RunWithoutJobSystem(Unity.Entities.ArchetypeChunkIterator*, Unity.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null|System.Void*, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)

#

Can't make heads or tails of it. Something about Unexpected char `<` while decoding assembly name reference, expecting `,` instead of `<>?

mint iron
#

the joys of generated code 😦

verbal pewter
#

Yeah, no idea what they expect me to with this πŸ˜„

tawdry tree
#

Uh, I suspect burst does not like generics

#

Does it work without being bursted? Did it work previously? What did you change? Try to isolate that.
Using a Git or other source control (even locally) for your project can make checking such things easier.

winter veldt
#

yeah to me converting to dots is not in the wheelhouse of "just change the code to how i think it should work in dots and run it expecting no errors" there are far to many gotchas in general dots and ecs theory and just... alpha quirks

verbal pewter
#

Yeah, it works without Burst.

#

There is one extension method that uses generics. Is that what you had in mind in mentioning generics, or something else?

tawdry tree
#

TBH if converting code it's probably best to jobify first, then make it work with ECS. Don't bother with burst unless it seems trivial or you need the perf. Or to learn, I suppose.

winter veldt
#

generics don't work in burst as far as i know.

tawdry tree
#

The extension method should not be the cause, but where does the generic in the extension come from? Can you sahre the extension method?

verbal pewter
#

My code can't be jobified. And I've finished converting it to DOTS.

tawdry tree
#

That's fine too, I meant ore of a general order of things. The main thing is really to focus on perf only when and where you need it, and oeehrwise go for convenience and maintainability (ie. good code)

verbal pewter
#

Here's the extension method:

public static NativeList<T> SubsetGetByIndexes<T>(this NativeList<T> list, NativeList<int> indexList)
    where T: struct
{
    var subset = new NativeList<T>();

    for(int i = 0; i < indexList.Length; i++)
    {
        subset.Add(list[indexList[i]]);
    }

    return subset;
}```
tawdry tree
#

Make the first line like '''csharp (but backticks for the apostrophes) to get C# highlighting. "cs" should work, too

#

No space after the word, immediate linebreak

verbal pewter
#

Ah nice, thanks

tawdry tree
#

Sooo.... where is this used?

#

In bursted code?

verbal pewter
#

Yes

tawdry tree
#

Looks to me like you don't need the where clause, what happens if you remove that?

verbal pewter
#

The type 'T' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'NativeList<T>'

tawdry tree
#

Or more like

//Non-generic
public static NativeList<struct> SubsetGetByIndexes(this NativeList<struct> list, NativeList<int> indexList)
verbal pewter
#

Ah hmmm

tawdry tree
#

Don't use generics (``MethodName<T /T2, T3, .../>(/arguments/)`) unless you need to

verbal pewter
#

Well I was hoping to have it as a generic for future use, but if I can make it a one-off.

tawdry tree
#

it still works with any struct, same as the original code

#

Well, any NativeList of struct

verbal pewter
#

Ah sorry, you mean changing it to struct. I was thinking you meant it more as MyStruct kind of thing.

winter veldt
#

yeah i think the compiler freaks out using the T, not sure it's smart enough to catch the where clause.. didn't know you could type it as a generic struct. nice!

verbal pewter
#

Actually, I'm not sure you can. It's saying that a type is expected.

tawdry tree
#

Oh yeah, no. where T : struct makes no sense when you can just replace T for struct (unless you have other constraints)

#

Similarly, where T : class constrains to only classes, ie. by reference objects. If you don't care, just use object instead of T (again, unless you have other constraints)

#

Both generics and extensions methods are tools that... well, they're hammers hungry for nails, so to speak.

verbal pewter
#

It's not liking this 😦 Throws an error for struct saying "Type expected."

public static NativeList<struct> SubsetGetByIndexes(this NativeList<struct> list, NativeList<int> indexList)
tawdry tree
#

Hmm, that's NativeList complaining, I believe

#

I think you'll have to choose between bursting that code or the generic

winter veldt
#

booo πŸ˜›

verbal pewter
#

Tried using it with List just to see what would happen and it's the same 😦

#

Burst or generic... hmmmmm, tough choice!

tawdry tree
#

if I had any value from the generic, i'd go for that in a heartbeat, unless I specifically needed the extra perf.

winter veldt
#

could see the performance gain between the two... kinda hit or miss without jobs in my experience (and my poor coding :P)

verbal pewter
#

Interesting point, guess I was assuming it'd be better by default hah. Well, fingers crossed.

tawdry tree
#

Beware of premature optimization.
Which here means making worse code (harder to understand, maintain, extend, against best practice, or similar) for performance you don't need (ie. have nood profiled to see that you specifically need. Always profile first)

dull copper
#

it's also for older ECS

winter veldt
#

especially when the API is technically still up in the air

dull copper
#

but still cool that someone did that

winter veldt
#

ooh. nice! it'd be fun if stuff like that was even on unity's radar...

winter veldt
#

@verbal pewter well thats part of the issue with DOTS. it's touted as the savior of everything right now... so everyone assumes it'll be better at everything. It's actually just REALLY good at specific things built for it, then it's usefulness goes down from there. it's a problem a lot of people have with the "magic keywords" stuff like burst end's up being.

tawdry tree
#

DOTS is great at the stuff that is typically demoed - A lot of stuff doing something relatively simple (Boids being slightly beyond that - and it shows if you try to understand the code).

mint iron
verbal pewter
#

@mint iron Thanks, will check it out.

#

@winter veldt Yeah, fair point. I'm still at the start of my project so the decision was to either build it in the standard way or refactor what I had to DOTS and continue development that way. Would've been nice to be able to do a side by side comparison of the speed, but that would've been doubling the work. I already know the code I'm working on needs to be as performant as possible, so going the DOTS route would still theoretically be the way to go. Or would it? Too late now, but I'm curious if there have been cases of DOTS being slower than the standard approach. If not, then I still think I made the right call.

#

@tawdry tree I haven't gotten there yet, but there are definitely parts of the program that'll make use of jobs in that way. Looking forward to seeing what it can do!

zenith wyvern
#

@verbal pewter You should really read up on generics if you're going to be writing generic functions.

public static NativeList<struct> SubsetGetByIndexes(this NativeList<struct> list, NativeList<int> indexList) It doesn't make sense to use struct as a generic parameter.

verbal pewter
#

That was suggested by someone else to try. Didn't work, bummer.

zenith wyvern
#

If you're familiar with generics it is very clear why. Read up on it.

verbal crescent
#

Putting it simply: "struct" is not a type, so it doesn't work for a type parameter (the part of the generic in <>)

stray topaz
#

When using the HDRP, what is the preferred way of creating meshes with ECS? Earlier Ive used the hybrid renderer "RenderMesh" class etc. but Im not sure how this interacts with the HDRP or if its even still a thing since the DOTS stuff deprecates sort of quickly

safe lintel
#

rendermesh is just a sharedcomponentdata that has a mesh and material and some other things. its equivalent to a meshrenderer and very much not deprecated. its definitely what you use to render an entity, regardless of the pipeline

stray topaz
#

I need the Hybrid Renderer to render the rendermeshes though right? or is that not the case

zenith wyvern
#

The hybrid renderer works by iterating over entities with rendermesh and position components, yes

safe lintel
#

imo hybridrenderer should be renamed dots or entities renderer or something, seems to cause a little confusion with the hybrid part

stray topaz
#

I was reading this thread which confused me a bit but what I gather is that the hybrid renderer should work fine side by side with HDRP

zenith wyvern
#

Yes, it works fine wherever. It's slow as hell compared to almost any other option unless you have your scenes set up in the exact right way.

#

But it does work.

stray topaz
#

I could just make a system and call Graphics.DrawMesh I suppose

zenith wyvern
#

And in that thread I certainly wasn't implying that it's going to be deprecated, it just hasn't been updated in a long time. I've seen a couple of posts from Unity people saying that it's being actively worked on and a big update is coming....at some point.

stray topaz
#

Yea I see, Ive worked with ECS before so I was just referring to deprecation in general. Ive had to relearn stuff a few times and now again I think depending on how they are doing the iteration

#

archetypes chunks or whatever it is now

zenith wyvern
#

Well Unity has been pretty clear that Hybrid Renderer is here to stay

#

So no worries about it being deprecated

stray topaz
#

I find it a bit frustrating that the samples seem to do all kinds of conversion, I just want to write pure ECS I dont have any need for game objects atm but I cant find a sample that does that

zenith wyvern
#

The idea moving forward is that you used gameobjects/prefabs/editors to represent everything at edit time. When you press play everything gets converted to entities and at that point it is "pure" ecs

#

Despite the name Hybrid renderer is in fact as "pure" ECS once you hit the play button

stray topaz
#

Oh okay, so it is in fact the "future" that you are meant to do the conversion. That explains a lot then.. Still for my purpose since Im going to do a lot of runtime generation of meshes etc. so I need to generate these from code either way

zenith wyvern
#

Very much so yes. And speaking from experience you will not want to use the hybrid renderer for anything procedural right now

stray topaz
#

I see, Graphics.DrawMesh it is, maybe instanced if I can be bothered :p

#

Thanks for the help πŸ™‚

safe lintel
#

@zenith wyvern are you by chance using ecs with urp?

zenith wyvern
#

I am yeah. I don't think I'm really utilizing any URP specific features though

#

To be honest I will probably be porting to Project Tiny once it has better support for procedural meshes

safe lintel
#

do hierachies give you problems with rendering?

zenith wyvern
#

I don't really have hierarchies atm, most of my stuff has been basic test cases so I haven't really needed to get that far. What problem are you having?

safe lintel
#

just scale going kinda bonkers in a simple child parent conversion. i know urp isnt their target and people have had other issues with it, but its still kinda disappointing

zenith wyvern
#

Ahh okay, sorry I haven't messed with the transform system hardly at all. You could always poke at the Transform conversion systems to see what might be going wrong

safe lintel
#

oh its static tickbox causing issues

#

does the same thing in hdrp, wonder what happens

stray topaz
#

How do you guys handle global settings? If I use a Monobehaviour so I can throw in materials etc. in the editor I would have to make it a singleton or something since Id need an object reference to access them, but the settings cant be constant since then they cant be accessed by ComponentSystems etc

zenith wyvern
#

ScriptableObject with Resources.Load or Addressables

stray topaz
#

Yea okay, so no drag and drop, but it might be the way to go

worldly pulsar
#

I just have a few components converted into the scene (managed components for mesh/material references, structs for simple values)

#

then access them via GetSingleton<SomeSettings>()

remote coyote
#

I wrote a converter, that converts scriptable objects to blobs, and I use that for my global settings now that only the ECS worlds will touch

#

and just apply blob refs to singleton components

dawn forum
#

So, I have a bunch of entities rendering via the hybrid renderer - how can I assign per-entity shader properties - color, texture, etc? Is there an example somewhere that does this elegantly? Or do I just loop through each entity on the main thread and set material properties there?

safe lintel
dawn forum
#

thanks!

dawn forum
#

yay!

#

does that include URP support?

dull copper
#

last comment was that DOTS team is focusing with HDRP support till next summer at least

#

so, I wouldn't expect huge amount of URP support but I'd expect some patching to make it compatible

tawdry tree
#

Yeah, was about to say 'focus on HDRP' doesn't mean they won't do anything for URP, just that their effort won't be focused there. (less stable, less features)

sonic oyster
#

i have a small problem, is there any way to bypass it?
I'm trying to edit nativearray while job reads it. It's set as [ReadOnly] in job. Can i somehow force the edit, or i have to wait for the job to finish and then edit it? (i.e. enqueue the edition)

safe lintel
#

NativeDisableParallelForRestriction if you want to write to disable the write restriction

sonic oyster
#

thanks! i'll read about usage of it!

#

nope @safe lintel
InvalidOperationException: The previously scheduled job Chunk:Job_RenderChunk reads from the NativeArray Job_RenderChunk.blocks_CurX_PluY_CurZ. You must call JobHandle.Complete() on the job Chunk:Job_RenderChunk, before you can write to the NativeArray safely.

dull copper
zenith wyvern
#

@sonic oyster The error message is telling you the problem. You're trying to write to the array before a previous job that uses the array has completed. If you can't figure out that error you need to take a step back and learn more about how job dependencies work

sonic oyster
#

yeah, but that's my question

#

if i can bypass it

#

because i can enqueue the change

zenith wyvern
#

Sorry but I'm not sure what you mean by "bypass" it

winter veldt
#

yeah.. bypassing it would be.. not editing it in a job..

sonic oyster
#

im not editing it in job

#

i only read it

#

πŸ˜›

#

edition was outside of the job

zenith wyvern
#

Then you need to tell whatever you're passing it to that you're accessing it as read only

#

Or call complete on the last job that reads from it.

#

Or pass in the last job that reads from it as a dependency on the job that writes to it.

#

Like the error message was telling you.

winter veldt
#

[ReadOnly] on a variable in a job marks it as read only

amber flicker
#

Or WithReadOnly() if working with entities.ForEach πŸ‘

dull copper
#

huh

#

this was a really weird full version number bump:

#
## [DOTS Editor 0.2.0] - 2020-01-14
* Updated package dependencies```
#

one would think they could have just done that on 0.1.1

#

you can now also see which things are using the selected package

#

(instead of only listing packages it depends on)

safe lintel
#

is being used by looks very useful

low tangle
#

the only thing I dislike is if you install the top level 'entities' package kinda like a meta package it only puts that package in your manifest

#

I had a problem on a new 2020 project trying to get all my packages to a proper version and couldn't manually update collections because it was using the one entities said to use

remote coyote
#

Anyone else encountering this exception in their DOTS code?
System.ArgumentException : All entities created using EntityCommandBuffer.CreateEntity must be realized via playback(). One of the entities is still deferred (Index: -1).

#

I'm only creating ECBs from EndInitializationEntityCommandBufferSystem in this isolated test

#

so I don't understand how this is possible

#

hm

#

Invalid Entity version: 0
EntityCommandBuffer was recorded in Server.Game.Systems.ServerStateMachine and played back in Unity.Entities.EndInitializationEntityCommandBufferSystem.

#

So my ECB is getting played back, but the entity version is 0?

#

weird

remote coyote
#

ah, I figured it out

#

I was storing the entity as a reference in my singleton component, the entity created via ECB (so it's just stored as (-1, 0)

#

I had to set it in a query next frame to get the real entity

#

rather than continue to use the (-1, 0) ECB created version

#

makes sense

#

I noticed though, that running unit tests against Netcode, I often get an exception where I need to update OnDestroy() on RpcSystem to do m_ReceiveSystem.LastDriverWriter.Complete(); before m_RpcTypeHashToIndex.Dispose(); is called, because there's a job dependency there requireing the Complete() before Dispose()

pseudo epoch
#

Is there a way to GetPrimaryEntity() from outside of a IConvertGameObjectToEntity ? I'm trying to instantiate some entities i've loaded from file and i'd like to convert my referenced prefab in an entity like in the Spawner of unity Samples but in the oppposite way. I've tried to recreate an GameObjectConversionsystem on the fly with World.GetorcreateSystem and getprimaryEntity on it but we can't create this system like this (it return an error) .

remote coyote
#

Well, GetPrimaryEntity is a concept of the GameObjectConversionMappingSystem

#

public Entity GetPrimaryEntity(UnityObject uobject)

#

internally it maps between the instance id of the gameobject to an entity

#

it uses ConversionJournalData to store those mappings

#

public bool TryGetPrimaryEntity(int objectInstanceId, out Entity entity)

#

If you already have entities though, isn't Blob what you're looking for?

pseudo epoch
#

I use a Spawner which convert gameobject to entities then instantiate them with some Data, i save some Data on a file, reload these Data and i would like to instantiate the prefab and set component on it from those loaded data. So no i don't have these entities i'm trying to instantiate them

remote coyote
#

right, I have no good answers there, so please share if you find any solution πŸ™‚

pseudo epoch
#

Ho really ? i was trying to use the GameObjectConversionUtility with ConvertGameObjectHierarchy and looking for what a BlobAssetStore is since it's needed to create a GameObjectConversionSetting

winter veldt
#

the conversion stuff is really only meant to allow you to create things in the editor, and have them converted to entities when you hit play. i don't think its meant to be used in any other context really.

#

i believe the conversion stuff is literally created in it's own world and referenced once then deleted, that's why DefaultGameObjectInjectionWorld is a thing i think

azure nacelle
#

I was trying to rebuild the FPS sample and using it to learn more of ECS & DOTS. However when moving to newer versions of Entities I have more peformance problems.

In the older version they use this:

var entityArray = Group.GetEntityArray();
        var dataArray1 = Group.GetComponentDataArray<T1>();
        var dataArray2 = Group.GetComponentDataArray<T2>();
        var dataArray3 = Group.GetComponentDataArray<T3>();
        var dataArray4 = Group.GetComponentDataArray<T4>();
        var dataArray5 = Group.GetComponentDataArray<T5>();

But in the new one I would have to use 'ToComponentDataArray' (https://docs.unity3d.com/Packages/com.unity.entities@0.0/manual/component_group.html), this one requires me to give a alloc type. But this seems to kill my peformance more drastically.

Am i replacing the 'GetComponentDataArray' with the wrong thing?

dull copper
#

@azure nacelle you mean the old fps sample for Unity 2018?

#

or the new dots shooter sample that was just released a while ago?

#

oh right the new thing is 3rd person.. so I guess you meant the old one

wary anchor
#

I'm being really dumb... been exiled to shader land and am just returning to systems so it's probably just that.

I have jobs where I set eg a NativeArray to a public job variable and that's written to within the job, then readable after completion of the job. For some reason I'm not getting an int out of a job the same way and I'm sure it's just me being dumb about it but I'm stumped

#

I suppose I could just add another component to do it that way thinking about it.

#

k nm I was being dumb ^^ πŸ˜„

amber flicker
#

If I understand you correctly @wary anchor I think the usual way is to use e.g. a NativeArray with a single element. I believe there's an intention to make it a bit easier to get return values out from jobs via the foreach syntax at some point in the future.

wary anchor
#

yeah I found that, thanks @amber flicker

azure nacelle
#

@dull copper sorry notification didnt pop up for me. But yeah i mean the old one, had some peformance issues with it in the new version.

I didn't know the new one was made public yet, that's huge fpr me too, thanks!

dull copper
gusty comet
#

Im sorry to bother everyone. I wonder how I would pass a readonly reference to systems for a bounding box struct.

#

I need to check if an entity is outside said bounding box

coarse turtle
#

Hmm how is it set up?

#

I imagine you would likely compile the job without burst and run instead of schedule since you have a reference type - but that's me thinking out loud πŸ€”

Entities.WithAll<...>().ForEach((some-args) => {
  // Some logic here with the reference type
}).WithoutBurst().Run();
gusty comet
#

Could I add the reference as a component to each entity?

#

I think ISharedComponentData will work

safe lintel
#

you can store reference types in components now, if you use AddComponentObject, probably a better option than sharedcomponentdata

gusty comet
#

oh nice, thank you!

low tangle
#

Anyone know of some performance benchmarks of the unity hybrid renderer? Last night in a secondary project I was testing out terrain generation just spawning lots of cubes (with instanced material (9000->300 batches) and it was still abysmally slow

#

Something like 200ms just traversing them in presentation system. Only 1ms to actually render

#

I did testing way back and don't remember it being this slow

#

Thats uh 700k cubes

#

I wonder if a custom Graphics.DrawInstanced would be sane

azure nacelle
#

@dull copper you're a champ, thanks!

low tangle
#

I was just thinking about static/frozen tags. thanks you for confirming @digital scarab

low tangle
#

does much better but I cant quite structure the whole frozen scene batches data. guess I'll have to wait for that update. we talking 1 or 3months+ on it?

silver dragon
#

Had the same problem, my dynamically spawned environment took 20-40ms to render with RenderMeshSystemV2.
Ended up writing two simple systems:

  • ChunkSystem: Creates chunks and sets visibility according to player distance: Culled, Billboard , LOD
  • RenderSystem: Does culling/LOD selection based on player distance and view angle. Renders with Graphics.DrawMeshInstanced
    -> 1-4ms instead of 20-40ms
low tangle
#

dang alright

flat talon
#

Unity Entities 0.5 (ECS) and related packages is out πŸ™‚

slow epoch
#

There is no link to any page?

flat talon
#

they sometimes lag behind by a few hours

#

I got the changelog from the .exe file in the downloaded package

dull copper
#
## [Entities 0.5.0] - 2020-01-16

### Added

* Added AndroidHybrid.buildpipeline with RunStepAndroid
* EntityManager.MoveEntitiesFrom now has the full method overload combination of output, filter, remapping parameters.

### Changed

* `Entities.WithReadOnly`, `Entities.WithNativeDisableParallelForRestriction`, `Entities.WithDeallocateOnJobCompletion`, `Entities.WithNativeDisableSafetyRestriction` and `Entities.WithNativeDisableUnsafePtrRestriction` now check their argument types for the proper attributes (`[NativeContainer]`, `[NativeContainerSupportsDeallocateOnJobCompletion]`) at compile time and throw an error when used on a field of a user defined type.
* Log entries emitted during subscene conversion without a context object are now displayed in the subscene inspector instead of discarded

### Deprecated
 
* Adding removal dates to the API that have been deprecated but did not have the date set.
* `BlobAssetReference<T>`: `Release()` was deprecated, use `Dispose()` instead.
   
### Removed

* `EntityQuery.cs`: Removed expired API `CalculateLength()`, `SetFilter()` and `SetFilterChanged()`.
 
### Fixed

...```
#

fixed list was tad long

flat talon
#

cheers @dull copper

dull copper
#
## [Collections 0.5.0] - 2020-01-16

### Added

 * Added `UnsafeRingQueue<T>` providing fixed-size circular buffer functionality.
 * Added missing `IDisposable` constraint to `UnsafeList` and `UnsafeBitArray`.
 * Added `ReadNextArray<T>` to access a raw array (pointer and length) from an `UnsafeAppendBuffer.Reader`.
 * Added FixedString types, guaranteed binary-layout identical to NativeString types, which they are intended to replace.
 * Added `FixedList<T>` generic self-contained List struct
 * Added `BitArray.SetBits` with arbitrary ulong value.
 * Added `BitArray.GetBits` to retrieve bits as ulong value.

### Changed

 * Changed `UnsafeBitArray` memory initialization option default to `NativeArrayOptions.ClearMemory`.
 * Changed `FixedList` structs to pad to natural alignment of item held in list

### Deprecated

 * `BlobAssetComputationContext.AssociateBlobAssetWithGameObject(int, GameObject)` replaced by its `UnityEngine.Object` counterpart `BlobAssetComputationContext.AssociateBlobAssetWithUnityObject(int, UnityEngine.Object)` to allow association of BlobAsset with any kind of `UnityEngine.Object` derived types.
 * Adding removal dates to the API that have been deprecated but did not have the date set.

### Removed

 * Removed `IEquatable` constraint from `UnsafeList<T>`.

### Fixed

 * Fixed `BitArray.SetBits`.```
flat talon
#

πŸ€”

dull copper
#

no update for DOTS samples

flat talon
#

I didnt check the other packages, was there anything new in hybrid rendering for example?

silver dragon
#

Hybrid Renderer 0.3.2p17

#

No changelog though

solemn ice
#

Anybody knows if the hybrid renderer works with HDRP? I tried some time ago and it wasn't working. Also, can you use lightmapping with it?

silver dragon
#

Hybrid Renderer works with HDRP

amber flicker
#

but limited features right now I believe? Don't think lightmapping is supported yet but I could well be wrong.

solemn ice
#

Ok thanks, I guess I'll try it again then. But if it doesn't support lightmapping it limits my use cases a lot.

amber flicker
#

it's very bare bones.. and doesn't perform well either... generally would recommend sticking to traditional rendering for now

#

*unless you have mostly static renderers

silver dragon
#

(in subscenes)

winter veldt
#

wow

silver dragon
#

@winter veldt You were right, too much chunk fragmentation hurts performance

#

I removed most ISharedComponentData for that reason

winter veldt
#

haha ok. i posted because it looked like that was the last message to me. hit enter and pages of msgs appeared magically.. so i thought i might as well delete it πŸ˜›

silver dragon
#

In my RenderSystem i got a huge performance increase by just removing all ISCD. Having too many chunks with only a few entities are a bad idea πŸ™‚

winter veldt
#

yeah, took a bit of learning to get the concept of chunks. there's the way you want it to work to make it easy for you.. and the way it actually works

amber flicker
#

I'm hoping the later version of rendermesh will support either mode? Maybe doing something fancy with auto-evaluating if there are many instances of the same mesh or something?

gusty comet
#

Hello guys. One simple question. What is the current state of DOTS on webGL builds? I created a simple project of creating 30K spheres from code with basic physics (needed for raytracing) and I have great performance in editor. however in webgl build nothing gets rendered

silver dragon
#

This is done by using RenderMesh @amber flicker. There is one chunk for each Mesh + Material combination.

amber flicker
#

I'm saying.. in the future perhaps RenderMesh could be an ICD instead of ISCD dynamically?

silver dragon
#

Maybe once there are material and mesh components?

winter veldt
#

@gusty comet i really don't know, if you have the hybrid render package added.. then it must not be supported yet

gusty comet
#

hybrid renderer is not supported yet in WebGL?

#

I couldnt find any solid answers on the web

winter veldt
#

not sure. i just know a lot of people don't add hybrid renderer and then see no rendering of entities. if you've done that, then it must not be working with webGL. i don't use it, just didn't want you to get radio silence and think you were being ignored

gusty comet
#

thank you for your answer. I was prepered for radio silence when asking non-popular things on experimental features though πŸ˜›

#

tha thing is that i wanted to achive better performance than DrawMeshInstanced + collider gameobjects for raycasting

#

on webgl however that do not support compute shaders for now

zenith wyvern
#

RenderMesh is currently horribly slow for anything that isn't set up exactly like Megacity, you shouldn't expect it to give better performance in most cases

#

Not sure about webgl support though, I haven't tried it

#

Your best bet is probably to stick with normal mesh renderers for now

#

You can improve performance a lot by combining meshes if possible or making use of batching

gusty comet
#

I know but thats not enough, thank you though

#

combining spheres into a bigger one is one thing i try to implement right now

dull copper
#

@flat talon there werent any changes to other packages

#

they only updated the dependencies

low tangle
#

sweet

#

fixedlist is gonna be useful

inland root
#

@gusty comet as a general rule, don't expect any new features to be supported for WebGL. Best case scenario --latest Chrome on desktop computer, it's based on a version of OpenGL ES from 2012 (WebGL 2.0), or for many browsers it's based on OpenGL ES from 2007! (WebGL 1.0) the year the iPhone was released. Nor is this a problem specific to Unity, it's a WebGL / W3C / Web standards problem.

#

The good news is WebGPU is poised to become the modern graphics API for the web to succeed WebGL, with compute shader support, command buffers, HLSL based shader language, lower level abstractions, etc

knotty radish
#

I would be curious as to what would be the downside of using FixedList

#

Like everywhere

#

One I could see at the moment would be the size of the IComponentData struct which should be small

safe lintel
#

i dont quite understand, is it a list with a max size of whatever the type is(32,64,128 etc)?

knotty radish
#

From what I'm reading, I would assume so

#

Basically a nice wrapper around an unsafe byte array

safe lintel
#

ah ok

coarse turtle
#

Certainly looks like it

#

(version 0.4 API tho)

safe lintel
#

huh thought it arrived in 0.5

knotty radish
#

Not having to create IBufferElement thingies for simple usecases is nice

#

Yeah I've missed that update in 0.4

safe lintel
#

is there a vector3/float3 like type that fits into it? brief test shows neither of those work

dull copper
#

They bumped Burst to stable on 1.2:

## [Burst 1.2.0] - 2020-01-15

- Update to stable version.```
amber flicker
#

Anyone else struggling with compile times switching to jcs entities foreach? Mine are getting insane (I am generating hundreds of systems tbf but anywhere from 30s to a few minutes - only 4s of which assembly reload time).

dull copper
#

jcs?

amber flicker
#

JobComponentSystem

dull copper
#

ah, I didn't know πŸ˜„

amber flicker
#

sorry πŸ™‚

safe mist
#

Any thoughts on how to randomly instantiate an object from a list of objects using ECS?

safe lintel
#

i did feel like it increased but i dont have anywhere near the number of systems that you have

#

how and why are you generating hundreds of systems?

amber flicker
#

Well, more like hundreds of jobs in many systems. It's a Tween library - every property tweened requires multiple systems. Code is generated for each user-required Component (MB or ICD). I believed it should have in theory been the most performant (majority of systems would never run) and given the reduction in code, I thought foreach was the way to go. However in a lot of instances I had to duplicate a job rather than switch on the presence of a tag like I can with IJobChunk. In theory, the lib will rarely need to be recompiled so wondering whether to stick with it or go back to how I had it before with IJobChunk's written out in full, less jobs but more switching per chunk.

#

The most frustrating part is that nothing seems to be cached - everything's compiled from scratch each time.

safe lintel
#

sounds kinda exhausting to keep track of πŸ™‚

amber flicker
#

Easy compared to the rest πŸ™‚ - been working on it for a year so far πŸ˜…

untold night
#

I think the caching issues should be improved either in 2019.3 or 2020.1

#

not exactly sure when that's supposed to land

dull copper
#

burst caching should be in 2020.1 afaik

#

either it's in there or planned to be there

amber flicker
#

ah thank you - I'm on 2019.3.0f5 so may give 2020 a go

dull copper
#

regular dots works just fine on current a19

#

HDRP is still special case there but if you don't use it, then that's not an issue

gusty comet
#

It looks like the Rotation component in ECS is localRotation?

#

How do I convert it to worldspace rotation

#

I have a LocalToWorld component

#

I read this:

#
For an entity without a parent you can set the rotation to the world rotation and then you need to recalculate the LocalToWorld matrix. This can be done by creating a new float4x4 matrix from the Translation and Rotation values.
#

But, I have no idea where to go from here

#

My rotation code is:

#

rotation.Value = Quaternion.LookRotation(float3.zero-translation.Value, localToWorld.Up);

#

Which of course doesn't work πŸ˜‚

coarse turtle
#

if you want world space rotation - I think you should just get it from the LTW matrix

#

I think there's a property which allows you to grab said quaternion value in the LTW matrix (I forget what's it's called - it might be like localToWorld.Rotation)

#

as for setting a rotation - I typically update it in the LTW matrix πŸ€” (honestly not sure if that's recommended if the Rotation component gets copied to the LTW matrix)

safe lintel
#

new quaternion(localToWorld.Value)

amber flicker
#

Thanks @digital scarab - ok to dm?

remote coyote
#

hm, I get this now after updating to entities 0.5:

InvalidOperationException: Trying to get iterator for Unity.NetCode.NetworkStreamConnection but the required component type was not declared in the EntityQuery.

For this code:
var connectionSingleton = GetSingleton<NetworkStreamConnection>();

#

HasSingleton<NetworkStreamConnection>() works as expected

#

If I set up a manual query, it works.

#

var connectionSingleton = _networkStreamConnectionQuery.GetSingleton<NetworkStreamConnection>();

solar ridge
#

Entities .5?? @remote coyote

remote coyote
#

yes, the latest version

#

0.5.0-preview.17

silver dragon
#

At least GetSingleton isn't generally broken. I just updated my (networked) game and it still works πŸ™‚ After reading your issue i got some fears @remote coyote

mystic mountain
#

@remote coyote

        public T GetSingleton<T>()
            where T : struct, IComponentData
        {
            var type = ComponentType.ReadOnly<T>();
            var query = GetSingletonEntityQueryInternal(type);
            return query.GetSingleton<T>();
        }
solar ridge
#

No docs yet :( (more accurately no changelog on unity's latest page)

mystic mountain
#
        internal EntityQuery GetSingletonEntityQueryInternal(ComponentType type)
        {
            for (var i = 0; i != m_EntityQueries.Length; i++)
            {
                var queryData = m_EntityQueries[i]._QueryData;

                // EntityQueries are constructed including the Entity ID
                if (2 != queryData->RequiredComponentsCount)
                    continue;

                if (queryData->RequiredComponents[i + 1] != type)
                    continue;
                
                return m_EntityQueries[i];
            }
            
            var query = EntityManager.CreateEntityQuery(&type, 1);

            AddReaderWriters(query);
            AfterQueryCreated(query);

            return query;
        }

@remote coyote Looks like it should solve itself. It's weird.

remote coyote
#

Yes Jaws, I didn't understand why it wouldn't. It worked previous to the 0.5 update. But my workaround works so, I'm good for the minute.

#

Its GetIndexInEntityQuery that actually throws that exception, but I don't have time to look more into it atm.

verbal pewter
#

Question about disposing NativeContainers. I have a NativeList<MyStruct> extension method Filter that returns a NativeList<MyStruct> with a subset of the original list's values. It would be called using: myNativeList = myNativeList.Filter(filterValue). Do I need to dispose the original list within the Filter method, or does overwriting the value to the same variable handle this?

#

Though I guess there are situations where I wouldn't want to dispose the original list, such as:

var allValues = new NativeList() { value1, value2, value3 };
var filteredValues = allValues.Filter(filterValue);

So putting it in the Filter method doesn't seem like a good idea anyway. Hmmmmm.

gusty comet
#

@coarse turtle @safe lintel thank you so much!

#

annnndd now I guess I need to know how to update localToWorld.Value

#

gosh this is a little confusing πŸ˜‚

#

what is the best source of documentation on the topic of ECS rotations?

coarse turtle
#

I typically use that to update LocalToWorld's rotation value (create 3 rotation matrices for the x,y, z axis and multiply it to the localToWorld.Value float4x4)

gusty comet
#

and then apply that to the rotation.Value?

#

or just update the localToWorld.Value?

coarse turtle
#

I typically update localToWorld.Value

gusty comet
#

Also, thank you for posting a link to the math, that is really really helpful

#

great! I shall try this tonight

#

once again, thank you so much for your help

coarse turtle
#

I remember digging into the source code and there should be a system like LocalToWorldTRSSystem or something like that - which should build the LocalToWorld matrix so you can probably dig through its source code too

gusty comet
#

Fantastic

#

i might write a little article on this, it is very interesting

#

and hopefully I can save somebody some time in the future

safe lintel
#

in the entities docs theres a big section on how the transform system works

scarlet inlet
#

Hello here, does anyone know how Unity decides the number of worker to spin according the CPU? I am having some weird results. For example I have 6 workers on I7 which is fine, 3 on I3 which is fine, but still 3 on I5 why?

safe lintel
#

might be a lot of components that could spare you modifying the ltw @gusty comet

coarse turtle
slow epoch
#

Every time i see the graphs in that link my head hurts

safe mist
#

So I suppose animation is still not supported in ECS?

#

Like switching run animation to idle etc

coarse turtle
#

No idea about it of its current state + ECS

autumn sleet
#

Very primitive vertex animation with no support of blending

safe lintel
safe mist
#

Thanks folks!

glass tiger
#

is there a way to use Entities.ForEach in a ComponentSystem to access GO components?

#

I'm trying to do hybrid ECS where I attach the "Convert to Entity" script to my GO and set it to "Convert And Inject Game Object", essentially so I can use Systems to drive the components' behavior

scarlet inlet
#

for the animation you don't really need to wait for the UnityECS support, you can use this too: https://assetstore.unity.com/packages/tools/animation/gpu-instancer-crowd-animations-145114?_ga=2.39530667.927516563.1579262831-1609202245.1579262831 .It's data oriented and use compute shaders to do the animation. We use GPUINstancer in place of UnityECS rendering already. (although I guess a proper ECS support would make things simpler)

BETA RELEASE
Download Demo Build (Windows PC)​

Crowd Animations is an extension for GPU Instancer , and requires it to work.

Support Forum | Documentation | F.A.Q.

Crowd Animations is an out of the box solution for using massive amounts of animated charact...

coarse turtle
#

@glass tiger Entities.ForEach((GameObject go) => {});

Look at the EntityBuilderQueryDesc struct for the order of args if you want to do like gameObject, icomponentdata in a query processor

glass tiger
#

thanky @coarse turtle

granite birch
#

Hi guys!

Is there a way to check if an entity is already modified in an EntityCommandBuffer?

#

(I mean... if an entity is already added to the internal " nativeArray" that the ECB uses.)

glass tiger
#

why do all entities and worlds get removed whenever I make changes to a script during play mode?

#

is it a configuration thing or does it happen for everyone?

chrome pond
#

Is it possible to remove safety checks when doing something like this? Obviously, the 2 jobs would never touch the same entities

var job1 = Entities
    .WithNone<CompX>()
    .ForEach((ref Translation pos) => {...}).Schedule(deps);

var job2 = Entities
    .ForEach((ref Translation pos, in CompX x) => {...}).Schedule(deps);
gusty comet
#

Oh wow! thank you! @safe lintel @zenith wyvern @coarse turtle

frosty siren
#

does ECB still can't work with burst?

frank knoll
#

it works now with burst

#

that was fixed in 0.3 I think

mystic mountain
#

@frosty siren I figured it out today you have to update burst manually to latest in the selection

frosty siren
#

@mystic mountain thx for clarification

alpine sphinx
#

@everyone
Has anyone here managed to get a dots build running in the browser/WebGL? Is this actually supported? It seems like the EntityCommandBuffer is leaking memory, works fine in a windows standalone. Confirmed bug from unity, but I haven't seen other people complain about this, so I'm wondering, am I the only one here looking to get a dots browser build working? How is nobody else blocked by this/complaining about this being completely broken in 2019.2 and upwards?

coarse turtle
#

I haven't touch webgl - i'm mainly on mobile atm πŸ€”

zenith wyvern
#

I will be switching to focus on browser at some point but I'm just going to use project tiny once it gets a bit further since it's being built with dots from the ground up for a browser.

alpine sphinx
#

I will be switching to focus on browser at some point but I'm just going to use project tiny once it gets a bit further since it's being built with dots from the ground up for a browser.
@zenith wyvern I think it will be a very long time until Tiny catches up to the full unity runtime. I think unless build size is a strong desire, going the Hybrid approach is probably the best. It's just that the damned thing doesn't work in browser it seems.
@coarse turtle Well if you plan to eventually, best you take a look and let Unity know of any issues you encounter soon enough that they're fixed by the time you actually plan on doing the move.
Seems like maybe I'm one of the first to look at dots on webgl? Just tried an android build just now and that one worked fine, interestingly.

zenith wyvern
#

My current project is very small scale so Tiny should be a good fit for me when it gets a bit further, but yeah it's definitely not appropriate if you need most features of the engine

#

Aside from the leak bug you could use an alternative solution for rendering and still utilize dots/ecs for the rest. But unless I'm mistaken threading doesnt work at all on webgl right?

#

If I remember right any job scheduling code just gets forced into main thread in webgl

alpine sphinx
#

@zenith wyvern I think threading works now, not sure. But the dots bug isn't rendering related, it's more basic than that, the ECB has a memory leak. ECB has nothing to do with rendering.

#

i build it with threading enabled, it works for a while but then runs out of memory. But the same issue happens with threading disabled, so Im pretty sure it isn't caused by threading

zenith wyvern
inland root
#

@alpine sphinx @zenith wyvern that doc linked above mentions only Javascript not allowing for threading, but Webassembly / Wasm will allow for threading Though there are have been some significant challenges in making that a reality, some of them have been out of unity's control such as browser support for it, but it will happen sooner or later.
https://blogs.unity3d.com/2018/08/15/webassembly-is-here
Scroll down to the "Multi-threading" section of this blog post for an official word from Unity about it in 2018. Not sure how far long it has come since then, though.

Unity Technologies Blog

It’s been a while since we announced our intention to switch to WebAssembly (a.k.a. Wasm) as the output format for the Unity WebGL build target. Since Unit...

#

another point i mentioned yesterday on the topic of @gusty comet asking about WebGL support for the DOTS Hybrid renderer is even though DOTS + Wasm + WebGL is technically possible, it makes very little sense to invest in a API such as WebGL that has been completely stagnant for nearly a decade. So it's more likely that DOTS + Wasm + WebGPU is the target we will be working with in the coming years.

alpine sphinx
#

I guess I misspoke, I meant WASM build

inland root
#

In fact you can download Chrome canary today on Windows or macOS and start developing with an early draft of WebGPU with compute shader, SPIR-V, GLSL, HLSL support, reduced CPU overhead for draw calls etc.

alpine sphinx
#

i just have a wasm build with dots hybrid, it crashes, and i'm extremely surprised how nobody complains about this

inland root
#

@alpine sphinx once the draft is complete and browser support is widely adopted (Google, Mozilla, Apple all are on board) then it makes sense for Unity to get heavy into DOTS with Wasm threading support + WebGPU

#

it doesn't make a lot of business sense for them to do that now with Wasm + WebGL when that will very soon be deprecated

#

double work

alpine sphinx
#

@inland root well right now nobody can deploy dots in the browser, so it does make business sense to fix some basic bugs

inland root
#

@alpine sphinx by all means I wish it worked now and the more bug reports the better. But DOTS isn't even production ready yet, it's still a futures project. It makes sense for them to target modern APIs, not a soon to be sunsetted APIs I feel your pain and I push for data oriented design and multi-threading efficiencies at every opportunity. but I have to be realistic on timing and current demand. DOTS is only "needed" by a certain minority of developers and projects that are willing to risk writing production code on WIP subject to change framework + toolchain. The, DOTS on the web is even smaller piece of that pie. So, that's why it seems nobody complains about this.

#

Not to mention the web standards groups.. the W3C that develops Wasm, and the GPU for the Web Community Group that develops WebGPU. All of these hundreds of companies and organisations that are members of these groups have to deliberate and agree on these standards before any progress can be made on architecture, implementation, etc.. It's a very slow process that Unity and everyone else is beholden to.

#

We have to be extra vocal about our needs because of this, and it feels like it's constantly an uphill battle. But don't lose hope!

dull copper
#
## [DOTS Editor 0.3.0] - 2020-01-17
[Changed]
* Updated package dependencies
[Fixed]
* Fixed multi-selected GameObjects conversion toggle issue
* Fixed inaccurate conversion message
lost lagoon
#

Just wanted to see what people thought of this idea. Generating a simple addition job for each numeric type in Unity. I created enough by hand and got sick of it!

#

And another idea I wanted to sanity check. A NativeValue native container that uses Interlocked synchronisation for thread safety. Generate classes in a similar way to above. It just seems nicer then using 1 element NativeArrays for counters, etc. What do you think?

remote coyote
#

Hm, odd case. I first Get a dynamic buffer, and I have a valid copy of it. I then call CreateEntity with archtype, count and temp job (batch call), when I do this, the buffer no longer is valid and I have to Get it again. Is this intended behavior, I wonder?

#

I'll set up a reproducible little snippet for this when I have a bit more time.

alpine sphinx
#

entity creation invalidates native arrays, it's intended

#

buffers probably fall under that category too, but in general, i know for a fact it's intended to invalidate nativearray of components you fetched previously, for example

remote coyote
#

ah, makes sense. That is indeed the exception I got (NativeArray no longer valid)

#

thank you

remote coyote
#

Are we aware of the reasoning behind why entity creation invalidates native arrays?

low tangle
#

@remote coyote
When you create the entity you are really asking for a chunk with x archtype. so your entity is really x memory location within that chunk (bit more than that but keep it simple). When you add the buffer, or do anything to change the archtype, it will move that data to the chunk that matches it. This invalidates the buffer pointer stored inside the buffer struct.
Dynamic buffers if small enough, can be stored within the chunk as a wide/fat component just like the rest, so that linear processing can keep them more cache coherent (not have to fetch external memory if your lucky). Thats what the [Internal something(100)] attribute is for.
So when your getting it again you are saying, lookup this entity, find the current chunk and return the
buffer within the chunk or external buffer location elsewhere.

Theres also another tricky situation as well, with EntityCommandBuffers. What they are is a basically a native list of bytes, that you slowly fill up with operations. When you add a dynamic buffer to one, you are basically asking for a stretchy byte[] casted to your type within the tail of them
I haven't really looked into their internal type much, as they pretty much just work great

I highly suggest when constructing types, you follow a natural order of
CreateEntity(optional:archtype)
Add/Set Component
...
Add Buffer
Resize Buffer
Memcopy, Add to the buffer
...

opaque ledge
#

Hello, i was trying to learn Entity system and i cloned the samples from https://github.com/Unity-Technologies/EntityComponentSystemSamples but i get the following errors when i press play button, i see that many ECS related packages updated recently, i was wondering if it was something about that or something else
http://prntscr.com/qpezlz

Lightshot

Captured with Lightshot

#

Last 2 errors just simply repeats

low tangle
#

"Burst failed to compile the function pointer" error basically means you have the 1.1 ish Stable version of burst install

#

you should go into the package manager and select show more versions on it, and update it to the newest

opaque ledge
#

i have 1.2.0 on Burst

low tangle
#

unitys loading hold up

#

hm, yeah thats correct

#

forgot they brought stable up to match

#

last few times I got that error, it was that

#

oh, what version of unity?

opaque ledge
#

2019.3.0f5

tawdry tree
#

Have you tried restarting Unity? I don't know if it's still like that, but has had issues where you needed to restat Unity or you'd get package-related issues

low tangle
#

well I'm kinda stumped on that one and need to start work.
I'd suggest double checking all packages are up to date then restarting unity to get a domain reload

opaque ledge
#

alright i will try that

craggy orbit
#

if it is the same, i'm having trouble with something else 😬

opaque ledge
#

@tawdry tree @low tangle it worked πŸ˜„ \o/

#

i can start learning now

craggy orbit
#

figured it out. turns out i had the parent object rotated, which caused the child to be rotated as well, which didn't let it collide with anything 🀦

low tangle
#

ah, glad you got it. your bit shifts are correct on the filter as well

craggy orbit
#

thanks for the confirmation on that!

low tangle
#

1u = unsigned int32, value of one aka:0...01 in binary, << bitshift to the Left, 0 or 1
for the non zero one simply moves 0...01 to 0...10 giving you a value of 2

craggy orbit
#

double thanks for the explanation. im new to the whole bit math stuff πŸ˜…

alpine sphinx
#

Has anyone managed to get a browser wasm build working with dots? hybrid, not tiny, i know tiny works. EntityCommandBuffer seems broken in wasm

remote coyote
#

@low tangle thank you for the breakdown. Makes a lot of sense

gusty comet
#

if i instantiate an entity from an entity prefab all SystemStateComponentDatas are not copied with the entity. Is this working as intended? Should SystemStateComponents always added after the entity is spawned?

gusty comet
#

Sorry to jump in with another question. I was wondering if there are any examples of passing traditional data into ECS? i have an octree that I wrote in C#, and I'd like to be able to query and update it from ECS jobs.

#

How does one handle locking/blocking

#

or even.. passing the tree references into ECS jobs and systems

glass tiger
#

wrap it in a component?

#

since you can query components

gusty comet
#

oh cool

glass tiger
#

(I'm very new to ECS and I'm just guessing)

gusty comet
#

so initialize it as a component.. and make it a shared component?

#

thats a good idea, I am really new as well

#

thanks for sharing your ideas btw

glass tiger
#

heh sure thing

#

I'm not too sure yet about when shared components are meant be used

gusty comet
#

I wonder if unity handles the locking of the data as it is being shared...

#

I'll go read and see what I can find πŸ™‚

glass tiger
#

if you use a ComponentSystem, all of those run on the main thread in sequence, but if you use a JobComponentSystem instead those execute in parallel, scheduled automatically according to what their queries declare

gusty comet
#

oh nice! thank you!

glass tiger
#

sure thing

#

I want to make a simple 2d game and am trying to figure out whether to go hybrid or pure ecs

#

classic UnityEngine components have SpriteRenderer, Rigidbody2D, Animator, maybe some other stuff

#

maybe I'll try to go down the pure ecs route and figure out how hybrid works if I get stuck missing a feature somewhere

zenith wyvern
#

Sorry to jump in with another question. I was wondering if there are any examples of passing traditional data into ECS? i have an octree that I wrote in C#, and I'd like to be able to query and update it from ECS jobs.
@gusty comet
You can't use reference types inside jobs. You could try remaking your tree as a NativeContainer

#

Or build it using entities and dynamic buffers

gusty comet
#

Uh oh haha. That sounds like a neat puzzle though.

zenith wyvern
#

So a dynamic buffer would be a leaf of the tree that you can query

gusty comet
#

oh wow

zenith wyvern
#

Unfortunately google still leads to old version docs

gusty comet
#

Cool, thanks so much. I'll read through these and the example. This should be an exciting challenge πŸ™‚

zenith wyvern
#

I would personally recommend trying the NativeContainer approach, it's complicated but seems like the right fit for what's meant to be an entirely self-contained container

#

And it will let you use your container in jobs like you'd expect

coarse turtle
gusty comet
#

fantastic, this is great!

trail burrow
#

woop woop

#

@zenith wyvern you can use reference types inside jobs just fine?

zenith wyvern
#

Uhh, when you try to pass a reference type to a job it literally says "Job structs may not contain reference types"

#

Or am I missing something there

trail burrow
#

@zenith wyvern Can just use a static reference?

#

And you can just GC PIN it and pass the handle

#

Works fine

zenith wyvern
#

It seems like you're kinda being pedantic there but sure

#

If you want to bypass the safety system and use unsafe code sure, there's lots of things you can do, that might not be the best place to start for someone just getting into dots

autumn sleet
#

@zenith wyvern you are not bypassing "safety system" by using unsafe context

#

Not all NativeContainers offer the best performance / burst compatibility

#

With the same attitude I could say that DOTS is not the place for someone just getting into Data Oriented Design

zenith wyvern
#

Writing a nativecontainer forces you to work within the confines of the safety system, throwing exceptions when any jobs tries to access your unmanaged memory without obeying the rules of the safety system. If someone is new to dots, that seems like a good place for them to start so they can understand why those rules exist. Performance should not be your primary concern when you're learning imo.

trail burrow
#

@zenith wyvern All DOTS ever talks about is performance lol.

#

it's the #1 reason people use it.

#

So yes, performance should be considered right away.

#

Because performance is how you get to clean memory layout and structure

#

which is what DOTS is all about

zenith wyvern
#

Performance is the end goal of dots, not the starting goal (at least it seems that way to me, not trying to speak for Unity). First and foremost they want to expose jobs and ecs in a beginner-friendly way, which by definition requires people to work within the confines of the safety system. Telling a beginner to start working manually with unmanaged memory outside the confines of the safety system seems pretty contrary to what Unity is trying to do.

#

If someone wants to that they're better off not using jobs at all.

trail burrow
#

@digital scarab DOD principles is easy

#

T[]

#

done.

#

πŸ™‚

#

Make everything a very fast O(1) access and O(n) iteration and ur done

#

@digital scarab Is there an official word on when we'll be able to put collections on components btw?

#

I know the whole "you really shouldn't do this", etc. arguments ofc. But sometimes its just the best way to solve a problem

#

Yeah so there will never be any safety features around that?

#

I mean, like you know, I have my own collections anyway for now

#

So I will just keep using them

#

We're also adding fixed size list and hashmap to our stuff, that lives inside a component

#

how does FixedList work in 0.5?

#

okey, so same way we wrap them πŸ˜„

#

    [FieldOffset(12)]
    private fixed Byte _MyBuffTest_[36];

    public FixedArray<AssetRefMyBuff> MyBuffTest {
      get {
        fixed (byte* p = _MyBuffTest_) { return new FixedArray<AssetRefMyBuff>(p, 4, 9); }
      }
    }
#

old code here from last fall, dont have latest code base on laptop i realized

#

@digital scarab Not the same problem as i was having tho

frosty siren
#

If i'm in case when one entity must change little data (just one field) of another very rarely, will it be enough for performance to use ECB.SetComponent(targetEntity, data)? How u do it?
(i watched this video https://youtu.be/KuGRkC6wzMY)

low tangle
#

yeah looking forward to that

#

just made a massive terrain system with dots
would love to have floating origin

safe lintel
#

grr why isnt burst working in the editor

analog nymph
#

Hi Everyone! I'm trying to store an image in a Component (implements IComponentData) , but I've had not luck with Textures or Sprites as they aren't Blittable. Any thoughts?

safe lintel
#

if you use AddComponentObject you can have object components, but you wont be able to burst jobify it

analog nymph
#

hmmm could I store the image path in a string and just load it from a resource when I need it (I'm really only using the image in a GUI Canvas)?

#

otherwise @safe lintel 's solution sounds good. Thanks!

proud cape
#

Hello guys, I'm currently dealing with how to implement input, should I implement different systems for diferent group actions, for example:

Group A) character movement, this system is in charge of processing axis and actions related to the parent entity with the physics body.

Group B) (in my case there's one main attack and will be, probably a second or third attack) should I group them all? Or create a system for each one as they may spawn from different objects?

Or should I group all the input process in the same system and create different jobs inside the system with different Component targets per the input target action?

What do you think would be simpler and more msintenable? And also which one is just more practical.

Thanks in advance for your feedback

alpine sphinx
#

Hi, question for someone from unity working on dots, what's the plan with dots hybrid ecs in wasm/browsers? Right now that target doesn't work. I've already sent the bug reports, but when can I expect someone from unity to actually work on that target? Just so i know how to plan my project's timeline. Right now that target seems abandoned...

vagrant surge
#

i still keep a close eye on tiny

alpine sphinx
#

@digital scarab thanks, i tried project tiny and it's way too lackluster at the moment. You can actually build webgl dots hybrid players and they almost work, with a few crashes here and there, whoever implemented it implemented the ability to build it for web too in scriptable build pipeline. It's just some crashes here and there.
Since you can do non-ecs builds for web, there's no reason not to support the hybrid web platform. Each of them separately work on the web,

vagrant surge
#

i think its super interesting to have a toolset optimized for web

#

as normal webgl export was super slow. Instant load is a great selling point

alpine sphinx
#

but those of us that care more about having the features rather than the build size, need the hybrid platform. We can't afford to work in tiny because we have to reimplement too many systems from scratch, instead of delivering the game. We simply don't have the budget to do that

#

it's going to be years until the tools available now in unity will make their way to tiny. hybrid seems like a necessary compromise until then

#

having hybrid dots is already better than using just monobehaviours on the web simply due to the way dots manages and accesses memory. Even if we just do singlethreaded dots, which monobehaviours already were singlethreaded. And it also allows us to write code that can run on multithreaded dots platforms. My company wants to focus on writing game logic entirely in dots (with just peripherals like UI or input writen with monobehaviours, or any other glue code that we need to interact with third party libraries or the OOP packages in package manager, like Cinemachine). If we don't have hybrid available, targeting web would just force us to use classic unity and write monobehaviours for game logic, duplicating our work, or simply forcing us not to adopt dots, and stick with monobehaviours, even for platforms that do support dots

#

And another thing, it actually took me less effort to fix the crashes here and there in the entities package when targeting web, than it would take me to write all the missing systems tiny is missing. Hybrid for web seems to be almost there, just needs a bit of love from you guys. If hybrid for web comes with caveats, i'd rather work with those caveats than struggle with tiny's closed, limited set of libraries and doing everything from scratch.
Could you please bring these points up at your meetings, or bring them to whoever has the power to make hybrid for web a reality?

#

the beauty of DOTS is that it is its own little isolated World, pun intended. There's no reason for it not to work on every conceivable platform, even microwave or smart fridge processors

#

the thing is my hybrid build runs in the browser in URP for 5 seconds (including animation, shadows etc), then crashes with some memory issue, so it's pretty close to working

#

I don't even need it to be ready to publish yet, I just need it to not crash miserably so I can keep an eye on this platform, while i develop and debug it on pc

#

so rendering doesn't even need to be flawless, just need it to render things enough that I can see none of the gameplay is broken in webgl

#

and when it's ready it's ready, just need to know this platform will be available/worked on, that it will be a thing, and i'm not just backing myself into a corner, a dead end, here, by needlessly hoping hybrid on web will work one day

#

right, but it would be a great relief if I could know for certain someone's actually looking into this target. Because right now even the builds I manage to make, they only work with release target, they're not even debuggable. I couldn't find any official answer on the forum in the vein "it's safe to hope that you'll eventually be able to use hybrid dots in a wasm browser build, doesn't work right now, but we're working on fixing issues and making this platform work"

#

well the point would be that people can actually start developing on this platform, even if they can't release on the platform yet due to the renderer

#

like the way console manufacturers give people devkits ahead of the console release, so they can make their games

#

Alright, thank you!

vagrant surge
#

isnt the goal of the new tiny (3d) that it will be more compatible with desktop and stuff?

#

with target not being only webgl, but small scale mobile games

mighty whale
#

hello, suppose i'm making a system and I want to only query a component X of a specific group of entity, what is the usual way to flag them ? shall i create an empty component assigned to this group of entity that my system will query in addition to the component X ?

#

or is there a 'cleaner' way ?

coarse turtle
#

@mighty whale you could split them into chunks - although if its a small subset of entities this might be a bad idea (e.g. chunk has component X with a certain condition, while a different chunk does not)

#

if you're dealing with small subsets of entities you might want to consider tagging entities with component X

mighty whale
#

well in my case the subset might be of size 1 lol

coarse turtle
#

tagging would be better than splitting them off into their own separate chunks

mighty whale
#

yeah alright i'll tag them with a component

alpine sphinx
#

success! managed to get a hybrid dots build working in the browser with no memory crash. Trick is to avoid EntityCommandBuffer.Concurrent and use EntityCommandBuffer directly inside the jobs, and then force the jobs to Complete() on the main thread

#

wrote a wrapper to abstract this away depending on platform, and now I can target pc and web with dots hybrid. This was painful, but it's doable, in case anyone else wants to get this working to some degree.

proud cape
#

I want to repeat my question as I didn't got any answers yesterday I hope to have better luck today:

Hello guys, I'm currently dealing with how to implement input, should I implement different systems for diferent group actions, for example:

Group A) character movement, this system is in charge of processing axis and actions related to the parent entity with the physics body.

Group B) (in my case there's one main attack and will be, probably a second or third attack) should I group them all? Or create a system for each one as they may spawn from different objects?

Or should I group all the input process in the same system and create different jobs inside the system with different Component targets per the input target action?

What do you think would be simpler and more msintenable? And also which one is just more practical.

Thanks in advance for your feedback

alpine sphinx
#

I'd say make one system per attack. Generally I'd ask myself would I need all systems running, or can some systems run while others are disabled? If the answer is yes, then the code is independent and should sit in separate systems for better flexibility. I'd imagine you could create an attack that a player can perform, but also maybe an enemy

#

but maybe some enemies/characters can't perform some attacks

#

so having them in separate systems gives you better granularity and would help you decouple the code better, just my 2 cents

mighty whale
#

@proud cape i would advise listening for the inputs in one system

#

and putting them in a kind of globally accessible object (be it singleton or whatever) that will be used by all the other systems that relies on input

#

the main advantage of this is every systems that previously had inputs were forced to live in the main thread and this is will no longer be the case after that

#

and it will also be much easier to change the way inputs are taken if they are all gathered in a single system

#

but @alpine sphinx is still right, after storing the inputs in a globaly accessible object, you still have to make modulable systems that can run independently when it makes sense to do so

#

For example i got a system PlayerInput that does just that

namespace Systems {
    public class PlayerInput: ComponentSystem {
        protected override void OnUpdate() {
            PlayerAction.mouseX = Input.GetAxisRaw("Mouse X");
            PlayerAction.mouseY = Input.GetAxisRaw("Mouse Y");
            PlayerAction.attack = Input.GetMouseButtonDown(0);
            PlayerAction.use = Input.GetMouseButtonDown(1);
            PlayerAction.forward = Convert.ToInt32(Input.GetKey(Settings.bindings["forward"]));
            PlayerAction.backward = Convert.ToInt32(Input.GetKey(Settings.bindings["backward"]));
            PlayerAction.left = Convert.ToInt32(Input.GetKey(Settings.bindings["left"]));
            PlayerAction.right = Convert.ToInt32(Input.GetKey(Settings.bindings["right"]));
            PlayerAction.jumping = Convert.ToInt32(Input.GetKey(Settings.bindings["jumping"]));
            PlayerAction.crouching = Convert.ToInt32(Input.GetKey(Settings.bindings["crouching"]));
        }
    }
}```
#

(later on in developement it'll be a bit more complex but its job will remain the same: storing inputs)

#

and then for example i got another system, PlayerControll, that will use some of the values from here to do its job

namespace Systems {
    public class PlayerControl: JobComponentSystem {
        private struct PlayerControlJob : IJobForEach<PlayerCamera, Moving> {
            public void Execute(ref PlayerCamera playerCamera, ref Moving moving) {
                moving.heading = math.normalizesafe(new float3(
                    PlayerAction.right-PlayerAction.left,
                    0,
                    PlayerAction.forward-PlayerAction.backward
                ), float3.zero);
                moving.heading.y = PlayerAction.jumping;
                playerCamera.viewRotation += new Vector3(-PlayerAction.mouseY, PlayerAction.mouseX, 0);
                playerCamera.viewRotation.x = Mathf.Clamp(playerCamera.viewRotation.x, -89.9f, 89.9f);
                moving.lookingAt = math.normalizesafe(
                    Quaternion.Euler(playerCamera.viewRotation) * new Vector3(0, 0, 1),
                    Vector3.forward
                );
            }
        }
        
        protected override JobHandle OnUpdate(JobHandle inputDeps) {
            PlayerControlJob job = new PlayerControlJob();
            return job.Schedule(this, inputDeps);
        }
    }
}```
#

So my answer is

  1. make a system that stores all the input in one globally accessible object
  2. do multiple systems when it makes sense and call this globally accessible object instead of Input directly
proud cape
#

I see, this morning I was thinking about doing it similar to that, since I wanted later to add ECS multiplayer a single system to listen for input then send RpcCommands and individual systems listening for related inputs.

Thank you guys for your feedback will play with the ideas and see what I can get out of it

mighty whale
low tangle
#

input is just data and should be within the ecs world

#

have a single system the gathers your non ecs data (input.getaxis etc) and put it into a entity with said data. or it can stripe it across all instances of that component type

#

one step to bridge from outside to inside (entites world), and a single location to update whenever you have to adjust your inputs (often early on, then never later in game dev)

#

since its also within this single system, you can reason about when exactly in the frame your input is updated.
you can then also disable input by adding a conditional anywhere for any reason and gather and check that data within the same input polling system.

#

this also helps stick to single responsibility and keeps all of one type of action inside a single small system (kernel) that does one thing in a linear action

#

for my game, I have two of these systems: desktop, vr

#

from there up to 20 different systems might access that component produced (CoreInput, VRInput, DesktopInput) I'm currently in the process of updating and fragmenting them more

alpine sphinx
last lintel
#

can anyone recommend how best to draw a lot of quads with ECS? I've seen a lot of things like 'draw 4 million cubes' or whatever but the ECS RenderMeshV2 is getting real slow at around 60000 (256 * 256)

gusty comet
#

Are the materials all GPU instanced?

#

and what are the batch sizes?

#

and have you looked at the entity debugger to see where it is running slow?

last lintel
#

The materials are instanced and the batch sizes are low. In the entity debugger it's rendermeshv2 and if I keep adding quads it just keeps slowing down

zenith wyvern
#

Short answer is use Graphics.DrawMeshInstanced or DrawMeshInstancedIndirect

last lintel
#

Graphics.DrawMeshInstanced performs worse, if anything, Just drawing a 30x30 grid of quads puts my CPU at 60ms

#

I must be doing something wrong

#

it also says it's drawing 1.3M tris for ... 900 quads. weird

#

ah, I was indeed doing something wrong

gusty comet
#

@last lintel are you using instanced enabled materials?

last lintel
#

I was, it was something else, too long to explain haha

gusty comet
#

np keep coding!

wide fiber
#

Can I use ragdoll with pure ECS?

mystic mountain
#

I have this system which generates "error DC0035: Entities.WithDeallocateOnJobCompletion is called with an invalid argument entityList of unsupported type Unity.Collections.NativeList`1<Unity.Entities.Entity>. It can only be called with an argument that is marked with [NativeContainerSupportsDeallocateOnJobCompletionAttribute].", looking at examples I don't see what I'm missing.

[UpdateInGroup(typeof(ClientSimulationSystemGroup))]
[UpdateBefore(typeof(GhostSimulationSystemGroup))]
public class ResolveControlledEntitySystem : JobComponentSystem
{
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        NativeList<Entity> entityList = new NativeList<Entity>( Allocator.TempJob);
        NativeList<int> clientIdList = new NativeList<int>( Allocator.TempJob);

        inputDeps = Entities.WithNone<ControllingData>().ForEach((Entity entity, ref ClientIdData clientId) =>
        {
            entityList.Add(entity);
            clientIdList.Add(clientId.ClientID);
        }).Schedule(inputDeps);

        // Update PlayerState ref to controlledEntity
        inputDeps = Entities.ForEach((Entity e, ref ClientIdData clientId, ref ControllingData controllingData) => // TODO Check if we need ControllingData here later
        {
            int index = clientIdList.IndexOf(clientId.ClientID);
            if (index > -1)
                controllingData.controlledEntity = entityList[index];
            else
                controllingData.controlledEntity = Entity.Null;
            
        }).WithDeallocateOnJobCompletion(entityList).WithDeallocateOnJobCompletion(clientIdList).Schedule(inputDeps);
        
        
        return inputDeps;
    }
}
#

Follow up, how to ScheduleSingle from lambda?

#

Fixed my issue by using arrays instead

[UpdateInGroup(typeof(ClientSimulationSystemGroup))]
[UpdateBefore(typeof(GhostSimulationSystemGroup))]
public class ResolveControlledEntitySystem : JobComponentSystem
{
    private EntityQuery m_group;
    protected override void OnCreate()
    {
        base.OnCreate();
        m_group = GetEntityQuery(ComponentType.ReadOnly<ClientIdData>(), ComponentType.Exclude<ControllingData>());
    }

    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        int entityCount = m_group.CalculateEntityCount();
        NativeArray<Entity> entityArray = new NativeArray<Entity>( entityCount, Allocator.TempJob);
        NativeArray<int> clientIdArray = new NativeArray<int>(entityCount, Allocator.TempJob);

        inputDeps = Entities.WithNone<ControllingData>().WithStoreEntityQueryInField(ref m_group).ForEach((Entity entity, int entityInQueryIndex, in ClientIdData clientId) =>
        {
            entityArray[entityInQueryIndex] = entity;
            clientIdArray[entityInQueryIndex] = clientId.ClientID;
        }).Schedule(inputDeps);

        // Update PlayerState ref to controlledEntity
        inputDeps = Entities.ForEach((Entity e, int entityInQueryIndex, ref ControllingData controllingData, in ClientIdData clientId) => // TODO Check if we need ControllingData here later
        {
            int index = NativeArrayExtensions.IndexOf(clientIdArray, clientId.ClientID);
            if (index > -1)
                controllingData.controlledEntity = entityArray[index];
            else
                controllingData.controlledEntity = Entity.Null;
        }).WithDeallocateOnJobCompletion(entityArray).WithDeallocateOnJobCompletion(clientIdArray).Schedule(inputDeps);
        
        return inputDeps;
    }
}
flat talon
#

Are you by chance not up to date on the Collection package and running on 2019.3? I know the built-in native collections in 2019.3 support dispose jobs for example

solar ridge
#

yeah, they have had that for a while now, but usually if you want a list to deallocate after a job you will have to use list.Dispose(dependency)

rough moon
#

Is there any way to efficiently searching for a particular entity's component? Getting all entities by making a query and then perform the value-based search linearly might not be a good idea.

amber flicker
#

If you need frequent access you can obviously tag it with another component or similar. Otherwise it's worth considering whether the data needs to be with an entity or not.

rough moon
#

I'm familiar with tagging (or blank components), but sadly it's not the case. The component that I'm trying to perform the search is already very primitive (something like player.attackTarget in traditional OOP approach, but many entities have that).

#

To put in into a more clear problem, let's say: given that I have a AttackTarget component with only an Entity value inside, and I want to get all the entity that is trying to attack a particular one.

zenith wyvern
#

Your only option is to add another tag to further reduce your query or query all relevant entities and exit out when you find the right ones. There's a post about this here https://forum.unity.com/threads/query-a-value.801915/
But it doesn't seem like they're too interested in implementing it. I suggest you add your voice to that thread if you want something like this

amber flicker
#

@rough moon "I want to get all the entity that is trying to attack a particular one" - e.g. foreach() if(attackTarget.Value == target) allEntitiesAttackingTarget.add(entity) is the most efficient way within the ECS paradigm if there's no archetype difference. You can make the allEntitiesAttackingTarget container persistent, write to it in parallel and only update it when you change attack targets for example. Optimisations will be very specific to your task (for example, how/when does the attack target change and what is the data used for etc). I'll also just say that linear search through components is designed to be incredibly quick - so perhaps profile before overly worrying. If you're doing this very frequently, there will be ways to cache it or add additional structures to optimise. For example spatial hashmap e.g. boids. This is part of the pain of shifting to DOD way of thinking - there aren't many general rules about how to architect things as they're data-flow specific.

wide fiber
#

How can I use intellisense in VSCode for unity dots?

#

There is no autocompletition

coarse turtle
#

hmm probably the VSCode editor package for unity might've not generated the looks up for the physics package?

mighty whale
#

hi how can we create a new component by copy ?

#

like, i have to create a new entity, and one of its component must have the same values as the one passed to the function

#

i was thinking it would be easy but got no relevant results on google

coarse turtle
#

i'd say EntityManager.Instantiate(entity) but it sounds like you only want a specific component?

mighty whale
#

yep

#

i just want one component

wide fiber
#

hmm probably the VSCode editor package for unity might've not generated the looks up for the physics package?
@coarse turtle mmh..

coarse turtle
#
var entity = CmdBuffer.CreateEntity(withSomeArchetype);

CmdBuffer.SetComponent(entity, new T { });

Guess you will need to consume a "messaging entity" or some queue of data you have to set the data via the CommandBuffer

silver dragon
#

@mighty whale The component passed to the function is a copy, so you can just add it to your new entity.

mighty whale
#

thanks, i actually just realized that what i tried to add wasnt exactly a component lol

#

but it's solved

silver dragon
#

Great πŸ™‚

mighty whale
#

also is there a way to have a fixed size list in a component :/ ?

#

currently we use a DynamicBuffer, but this forces us to use IBufferElementData instead of IComponentData

coarse turtle
#

There's a fixed list that you can use in the collections package

#

you can place that into a struct : IComponentData

#

I haven't used it though

mighty whale
#
public static Entity create(DroppedItem item, int3 pos) {
  Entity entity = _entityManager.CreateEntity(_archetype);
  // ...
  _entityManager.SetComponentData(entity, item);
  return entity;
}
#

but i get an error 'Components.DroppedItem' must be non-nullable blablabla

#

how can i get around this ?

tawdry tree
#

@mighty whale Is DroppedItem a struct?

mighty whale
#

it is a IComponentData

#

let me grab the code

#

here

using Unity.Entities;

namespace Components {
    public class DroppedItem: IComponentData {
        public int amount;
        public int id;
    }
}```
#

@tawdry tree

#

also thanks for helping UnityChanSorry

tawdry tree
#

Well, components should be structs, like

public struct DroppedItem: IComponentData //...
#

That's the non nullable value type or whatever it's complaining about it not being

#

It would be easier if it just called it a struct, though...

mighty whale
#

shit im dumb sorry

#

i knew

#

but i forgot when i wrote it apparently

#

thanks πŸ‘

mighty whale
#

is there an easy way to rescale a RenderMesh or a mesh πŸ€” ?

autumn sleet
#

Nothing is easy with DOTS πŸ˜„

molten plume
#

Re. NativeArrays<int> - I'm chasing milliseconds and 8.4 ms are going to 1254 updates of the NativeArray. These 8.4ms are nearly 50% of the time spent in this specific function. I have enabled Burst compilation, disabled the safety checks. Is there something more I can do to reduce the time setting values in the array takes?

molten plume
#

No, not yet, mostly because Unity fails to build

north bay
#

Is there a way to enable Unity collections checks in a development build?

molten plume
#

@digital scarab ok, and that isn't disabled when safety checks are disabled in the editor menu?

#

oh, ok.

#

@digital scarab I've not yet found a solution for this problem so I can't profile a player build...

Unable to find player assembly: C:\code\World2\Temp\StagingArea\Data\Managed\Unity.PerformanceTesting.dll
UnityEngine.Debug:LogWarning(Object)
Unity.Burst.Editor.BurstAotCompiler:OnPostBuildPlayerScriptDLLsImpl(BuildReport) (at Library/PackageCache/com.unity.burst@1.1.2/Editor/BurstAotCompiler.cs:166)
Unity.Burst.Editor.BurstAotCompiler:OnPostBuildPlayerScriptDLLs(BuildReport) (at Library/PackageCache/com.unity.burst@1.1.2/Editor/BurstAotCompiler.cs:46)
UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()
tawdry tree
#

@mighty whale Do it in a model editor? Any of them should do, and if you don't want to download one, search for "rescale mesh online tool" or something.
If it has to be in code, iterate over all vertex positions and multiply each dimension (x,y,z) with the relevant factor. Sounds like something you could use a ParalellForJob for, though not sure if you'd gain anything.

molten plume
#

@digital scarab Argh, my bad. Copied the wrong message.

#

@digital scarab ```
BuildFailedException: Burst compiler (1.1.2) failed running

stdout:
Burst requires Visual Studio (installable via Add Component in the Unity Installer) or the C++ build tools for Visual Studio, along with the Windows 10 SDK in order to build a standalone player for Windows with X64_SSE4
Unable to retrieve windows 10 sdk base
stderr:

Unity.Burst.Editor.BurstAotCompiler+BclRunner.RunProgram (UnityEditor.Utils.Program p, System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, UnityEditor.Build.Reporting.BuildReport report) (at Library/PackageCache/com.unity.burst@1.1.2/Editor/BurstAotCompiler.cs:659)
Unity.Burst.Editor.BurstAotCompiler+BclRunner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, UnityEditor.Build.Reporting.BuildReport report) (at Library/PackageCache/com.unity.burst@1.1.2/Editor/BurstAotCompiler.cs:597)
Unity.Burst.Editor.BurstAotCompiler+BclRunner.RunManagedProgram (System.String exe, System.String args, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, UnityEditor.Build.Reporting.BuildReport report) (at Library/PackageCache/com.unity.burst@1.1.2/Editor/BurstAotCompiler.cs:571)
Unity.Burst.Editor.BurstAotCompiler.OnPostBuildPlayerScriptDLLsImpl (UnityEditor.Build.Reporting.BuildReport report) (at Library/PackageCache/com.unity.burst@1.1.2/Editor/BurstAotCompiler.cs:286)
Unity.Burst.Editor.BurstAotCompiler.OnPostBuildPlayerScriptDLLs (UnityEditor.Build.Reporting.BuildReport report) (at Library/PackageCache/com.unity.burst@1.1.2/Editor/BurstAotCompiler.cs:46)
UnityEditor.Build.BuildPipelineInterfaces.OnPostBuildPlayerScriptDLLs (UnityEditor.Build.Reporting.BuildReport report) (at <0a2a5ea3c8ab4e3394576dd407a984f6>:0)
UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()

#

I've already got VS installed, Unity did that for me

#

yep, all packages are up-to-date

#

hm, there's a Windows 10 SDK in the VS installer - will try to add that

#

Btw, is BurstCompile-attribute still needed?

#

oh, sweet. Installing the Win10 SDK manually fixed the build issue

dull copper
#

@molten plume the message is correct

#

you are missing c++ build tools for visual studio

molten plume
#

yeah, like I just wrote - installing the sdk fixed it

dull copper
#

ah, sorry I missed that

molten plume
#

is it possible to pause the profiler when profiling the player?

#

oh, found the record button πŸ™‚

#

huh, the player is more laggy that the editor :\

proud cape
#

Hello Guys.

I've having issues with a LifeTime component i created, it's fairly simple and made in a ComponentSystem to not have issues with Destroy

#

The issue is that i set the lifetime to be based on a maxAttackRange/Speed after debugging it the initial lienar speed for PhysicsBody is set to the correct values on creation, but the bullet always goes further than what maxAttackRange says it shoud be, like for about a half

#

Btw guys I have seen you share Code directly here, what is the syntax for it?

safe lintel
#

@mighty whale use a Scale or NonUniformScale component. the entities documentation has much more info on transform components that are probably easy to overlook.

mighty whale
#

Yep i used a Scale component it worked just fine thanks :)

proud cape
#

Hello Guys.

I've having issues with a LifeTime component i created, it's fairly simple and made in a ComponentSystem to not have issues with Destroy
@proud cape

safe lintel
#

hmm thought the first one did stuff too

proud cape
#

I made some tests and it looks like the ecs Pyshics is making the bullet move faster than the AngularVelocity vector implies, I made some custom move by speed and acceleration systems as tests, and they do work as expected but the objects with Physics body do move faster than what i inted

#

@safe lintel thanks

glass tiger
#

how do you perform a query on classic object components in a system when doing hybrid ecs?

proud cape
#

@glass tiger If im not mistaken as an ECS component just pass the GameObject component to the generics methods

glass tiger
#

hmm, I'll try it

#

I was trying to use ForEach but maybe that syntax doesn't work with it yet

#

I tried

Entities.WithoutBurst().ForEach<SpriteRenderer>((
    SpriteRenderer sprite
) => {
    Debug.Log(sprite);
});

but it gives Error CS0308 The non-generic method 'ForEachLambdaJobDescription.ForEach(Invalid_ForEach_Signature_See_ForEach_Documentation_For_Rules_And_Restrictions)' cannot be used with type arguments Assembly-CSharp

#

documentation on hybrid ecs seems to be scarce to come by

untold night
#

Did you end it with .Run()?

#

otherwise it'll still be trying to schedule a job with a managed parameter

glass tiger
#

I can append that but it doesn't change the error

#

it's a compilation error

untold night
#

hold on

glass tiger
#

wait, removing the generic stuff made it work, what on earth

untold night
#

Yeah I was about to check that

#

the IL Manipulation doesn't like you putting things in the generics, as I think it does some type wrapper stuff with them

glass tiger
#

finally got it working with GO components, ECS component refs and read-only

Entities.WithoutBurst().ForEach((
    SpriteRenderer renderer,
    ref Translation t,
    in PlayerMovementValues movementValues
) =>
{
    Debug.Log(renderer);
}).Run();
#

I spent so long trying to figure this out yesterday, apparently I just had the order of the args wrong before

#

it seems particular about the order you specify them

#

that's a relief

proud cape
#

The template for this if im not mistaken ask for classic components first then components thats why I think you had this issue

glass tiger
#

yup, that seems to be the case

#

I tried looking at the ForEach overloads but I wasn't able to comprehend them

#

and I'm still not sure what the generic versions are for lol

last lintel
#

is it possible to store materials and meshes in shared component data so they can be used in Jobs?

#

I tried putting an SCD together as a test but they were passed as reference types and obviously it didn't like that

#

(trying to remind myself how not to pass something as a reference type hahaha)

last lintel
#

I'm not sure I follow what's happening in that example. and isn't RenderMesh associated with the hybrid renderer? I'm trying to use Graphics.DrawMeshInstanced and that takes a Mesh

proud cape
#
entityManager.SetSharedComponentData(entity, displayMesh);

This can be done for Mesh too