#archived-dots
1 messages ยท Page 211 of 1
If i were going to load an "external 3D model" on my ECS system, would I need to instantiate a gameobject? would I use a prefab?
Typically you would author a traditional gameobject with your mesh attached then use the conversion system to convert it to an entity at runtime
how it's supposed to load ECS "visible objects" (so far to my understanding, i added typeof(RenderMesh) to my archetype
so, I need gameobjects to load 3D meshes into DOTS !?
You don't "need" to, but the expected workflow for dots is you author in the editor with traditional gameobjects/prefabs then the conversion system converts those into entities for runtime
ok....so the expected workflow (until DOTS supports otherwise) is to have gameobjects, prefabs and such things and convert them into entities at runtime.
Doing it that way is a lot easier than trying to manually add all the necessary components at runtime as well, in my experience
yes...it might be easier, but not "pure ecs". and, tbh, sounds quite "temporary"
so far, seems the mesh is my only component left
It is "pure" ecs at runtime. The point is to leverage the existing editor tools at edit time.
At runtime you would only be dealing with entities
I'm a total newbie, but for me something like Resources.Load() or Assets.Load would have made sense instead
And no, it isn't temporaey as far as I know
It's the expected way to make dots games
sounds weird to me, tbh
@zenith wyvern seems this is what i was looking for: Resources.GetBuiltinResource<Mesh>("Cube.fbx"); Going to test...
Is there a way to check if an Entity is still "alive" ?
Like when you store the entity struct somewhere and you wanna check later on if you can still "use" that entity ?
EntityManager.Exists
Ah great, thanks ^^
ok...so my entities are being created but aren't visible.
You'll want to use https://docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.11/api/Unity.Rendering.RenderMeshUtility.html @night venture
This utility adds all the necessary classes to hybrid rendered entities
@turbid sundial hello STAN. let me review that. stop moving your arms. im not going to buy you anything
do you have a working example by hand?
When does an entity query update ? Im currently having the issue that i "1. Create an entity, 2. Search that entity ( Same frame )" and it doesnt show up...
@stone osprey a scope issue perhaps?
I dont think its a scope issue... because i create that entity by the entitymanager and it wont vanish once out of scope
in which method do you create the entity? is the entity object at class-level or method level?
EntityManager.CreateEntity();
that returns an object
What ? ^^
which u have to store somewhere
Uhmm... i dont think so, because the ecs itself stores the entities
The struct is just an identifier
Like an id
...im not sure about what you say...but my entities doesn't dissapear xD
let me explain myself:
It doesnt dissappear...
var entity = manager.CreateEntity();
// Run query to get all entities
// its not there ?!
Thats what is happening...
So the query doesnt find it... YET... so im not sure if i need to wait one frame
or if it normally should update instant
try Entity e = manager.CreateEntity();
and, even more...
Entity e at top, at class level
let me write what works for me so far...
I just have the problem that my query does not update instantly... and i just wanna know if thats normal or not
Oh i found my problem... i was still using an entity command buffer... thats why it took one frame for the query to update
then, my code is useless xD
yes
learning dots rn
ive faced fps drop after instantiating ton of planets
will dots help
BTW is it possible to render a mesh with multiple materials in the hybrid renderer ?
So is it possible or not ? ^^
Btw... are there any docs on how exactly the hybrid renderer works ? I would assume it offers such a good performance because it "instances" all its drawn meshes. Like opengl does with "DrawMeshInstanced". Is this right ?
internally it still uses the srp batcher and URP, but as it has way better data layout. Gathering the data needed to send to the gpu each frame takes considerably less time. It is not a completely new rendering pipeline
@karmic pilot Thanks ! So it basically loops over all entities with a renderer each frame, gathers its data ( Transform, Rotation, Material, Shader ) and sends them to the GPU by either Opengl,Vulkan,DirectX and draws them instanced ? I just wonder how they exactly do that... because i saw examples of the hybrid renderer with 500K entities being drawn with nearly 60 fps... but in some pure c/c++ opengl examples 200K instanced objects are already lagging. So they are somehow more performant then pure opengl which makes me wonder why
comparing hybrid renderer to opengl is like comparing apples to stones ๐ the hybrid renderer cannot accelerate the underlying rendering backend (vulkan/dx/opengl), it can only improve the effort needed to prepare the data for them (render data + commands).
@karmic pilot Hmmm... but how its possible that its faster than a pure opengl instanced renderer ? :/ I read somewhere that it only sends the "changes" to the gpu. But as far as i know opengl/directX force you to send everything everyframe
a hybrid renderer with opengl backend faster than a pure opengl optimized solution?
Isnt this the case ? Atleast i recently saw an dots example where someone drew about 500k entities. But the official opengl "instanced" renderer with those asteroids is only able to draw about 200-300k. Everything higher lags
no idea which comparison you saw, but in general the hybrid renderer can improve performance by quite a bit compared to the old fashioned game object rendering due to more efficient queries on the data. It always depends on what your bottleneck is ... memory access, cpu computation, gpu bandwith, gpu computation... the hybrid renderer is no silver bullet
where it really fails horribly for example is using unique meshes... if you have 100k unique meshes, the hybrid renderer won't be able to save you (might even be far before that)
Alright, thanks ! Well thats understandable ^^ Its just possible to instance entities with the same mesh and material... and shader... Everything else is one more drawcall.
Has anyone here got a non-trivial dots project that when processing a low number of entities doesn't end up taking e.g. 1ms just to schedule jobs? I'm finding that I just can't get my main thread time down. The cost of scheduling (not doing work) is more than doing the same work in a traditional way on e.g. 500 gameobjects. I have to be running over more than 1000 entities before it's worthwhile. So far from performance by default. (I have many jobs and many components, this is all in a build, burst enabled even some ISystemBases where I can, reduced sync points, mostly unmanaged etc).
if you have a small amount of entities, just .Run() on the mainthread
scheduling has an overhead that is only negligible if you are working on a lot of entities across multiple jobs
Not an option as it has to scale to a larger number of entities. I do swap to .Run() dynamically based on number of chunks where I can but it still doesn't help that much.
are you jobs depending on results of previous jobs in the same frame ?
ehh tutorial stopped at this
Entities.ForEach()
```
yup - I think the dependency a chain is a large part of my frame time. e.g. if I profile around Dependency = job.Schedule(Dependency) it seems responsible for about 30% of time across jobs
does this necessarily have to happen in the same frame in order to work ?
since I don't know what you are doing, all I can do is randomly guess what might be the issue ๐
yea - it's a tween library so it all has to be frame accurate sadly
in general jobs for a small amount of entities has a larger scheduling overhead than the actual execution on the main thread, since as you saw you have to check for dependencies, it has to be wrapped into a job to be executed somewhere and then it has to be scheduled... this is a lot more work than a simple iteration on a handful of entities that might even fit into a single cache line alltogether
yes... what I didn't appreciate is how badly this scales for any non-trivial project.
they are working on that ๐
I also thought that burstable ISystemBases were supposed to improve things
but they don't unfortunately.. not yet anyway
do you know if that's because they haven't finished that or they're working on something else to help?
what if I want to add Class reference to componentData? https://i.imgur.com/qmafkvb.png
I'll end by saying that the claim of performance by default in ECS / DoD only applies to many entities is not a correct assumption. DoD has a higher impact when you process more than one thing, but the expectation is that it is faster in all cases. If you have one thing, OO might be only a little bit slower while when you have many things it is a lot slower.
The current issues with low entity counts, are simply performance bugs that are in the process of being fixed.
this was at the end of 2019, no idea how much better it is since then .. haven't started using dots before mid 2020
yea.. I've been working on this for the past 2 1/2 years - waiting for this to be improved... as far as I've seen communicated, ISB's were supposed to be a large part of the answer
I'm at the point where I think I need to pause dev until they actually do something about it
but with no comms, I'm not sure if this is really something they think they can do more about
like you say, almost 2 years and very little improvement
if you want to use managed data, you need to use managed components (which are horribly slow in comparison)
you can use a class ICD if that helps? e.g. public class myThing : IComponentData{ //managed stuff here }
and Timboc, did you profile with checks/debugger on or release built player?
il2cpp release - though it's not much difference to in editor tbh
does burst work with il2cpp? never tried
yup ๐
why am getting all these errors? :C https://i.imgur.com/fvHBDMk.png
I think you've got a bit confused - using the ForEach parameters in the OnUpdate of a System - would recommend checking out the examples pinned in this channel
oh ok xD
@gusty comet If you have the same problem as i had ( Boxed structs... structs casted to objects ) and you wanna add/set them... i wrote an extension for that ๐
Not horribly, just as slow as if you were using Monobehaviours
thats why I said "in comparison" ๐
why I can use .Schedule when ref Translation
but I have to use .WithoutBurst().Run(); when using my own componentdata?
AFAIK you can use ref with any IComponentData with Schedule() and with managed IComponentData, which you defining like class, you should use .WithoutBurst().Run()
OH so it had to be struct LMAO thanks
yea i didnt like that WithoutBurst cus i assumed it would be slower
yes, every .Run() will produce sync point which leads to all jobs will be forced to complete
oh ok
but i kinda wonder
what if your meshes are generated dynamically in monobehaviour script ?
maybe having one object with mesh generator, and he would supply the mesh dynamically to all the entities? (so mostly different meshes, eg 5 entities per mesh)
would that work
you can make mesh generation method static and then use it in system which will set MeshRenderer component. But you must assume that MeshRenderer is ISharedComponentData and every unique value will produce extra chunk, so DOTS built-in renderer is not the best solution for mesh generation for now.
the generation is done with monobehaviour, i just want to "pass" generated mesh to dots entities
you mean RenderMesh component?
yes
yea but so far I know that i can access entities from entitymanager
and then i would also need to know which entity i need to access
I need to store NativeHashMap somewhere and get access in systems. What may be better create static class and store NativeHashMap in it or it can be store in component like blob asset? Also this collection should be updated and use in system with burst parallel jobs.
you can store it in another system
How do you guys handle events with ECS? E.g. a mob has died and you need to react to that (run death animation, remove some components from the entity, drop loot, ...).
i see few variants
- Add to your entity some component and have a system that will react on it. Like DiedTag in your example. But every combination of components is one archetype and also archetype changing leads to memory copy.
- Create some event entity that will have components of "what happend" and "with what entity". And have a system that will react to this entity through link. But it's not really ecs, because you will need to access components not through query and not linearly
- Other clever approaches which i don't know about. Maybe you can search on forum. I saw some projects for dots event system.
Yea that's pretty much what I've been reading on the forums
Was hoping there'd be a better way ๐
@stone osprey did you ever figure out your serialized/deserialize?
But you must assume that MeshRenderer is ISharedComponentData and every unique value will produce extra chunk, so DOTS built-in renderer is not the best solution for mesh generation for now.
so you mean dots is best when values are the same (eg same mesh, same int value, same sound, etc) ?
is it useless when theyre not the same?
He is talking about the shared component specifically creating a new chunk for every unique value
like @sturdy rune has said it's only about ISharedComponentData. DOTS have no alternative for mesh rendering except shared MeshRenderer
@sturdy rune Yes kinda ^^ I actually just added a little feature to my deserializer. I call them events. And it kinda works like this, a deserializer receives a packet, deserializes it into a struct and passes it to the events. At this point we know the type and can use generics. If a event returns a certain value it wont box/return the deserialized struct. So i just hook in such a event, which basically enlists the deserialized struct into the ECB and now they arent generating anymore garbage. Which reduced the gc alloced memory from 20-40KB every few frames to about 1KB.
So there kinda like two branches for my deserializer. It either returns a list of objects... deserialized class/boxed structs... or it invokes its events to pass the deserialized structs straight to the ECB without returning and boxing them first
@iron jacinth WTF ?
with monobehaviors and coroutines i executed somewhat heavy code every 3 5 10 seconds, how would you achieve this in DOTS? since ONUPDATE executes every frame.
would it be OK to count time.deltatime and wait until it has passed eg 10 seconds? or thats slow
oh well theoretically I still can interact with entities via coroutine and entity manager
systems aren't that different to monobehaviours, they update every frame also
ah im still somewhat confused, but I guess its better to do 'occassional' stuff from monobehaviors, and stuff that executes every frame, from systembase OnUpdate
( theres no performance gain if something executes once per 5 seconds anyway)
I don't think you can use coroutines in Systems but you can do a simple timer which I doubt would be much performance difference than a coroutine
ah yeah i already made the timer, but the more i think of it the more i feel i need monobehaviours
i will still use dots for rendering, colliders and movement(as this is every frame), but other stuff from monobehaviours, by calling entity manager
yeah you can use both together just fine
btw, theres no fixed update for dots?
@gusty comet put systems into the fixedsimulationsystemgroup
not 100% ECS but here it goes:
I want my 2D board game to be static but large enough to consider using a file backend as the place to mark, for each [x,y] which tile components should I set.
For example: [3,0]is a sidewalk tile, while [4,0] it's a road tile...is this a BAD idea? would it be possible to write entity "components" within file to create them at runtime?
ie: .CreateArchetype(foreach_tile_types_defined_in_file)
what if Hybrid renderer v2 made my entities invisible?
Hoping someone can give me some optimization ideas here, https://gist.github.com/jamieshepherd/d9b6a93c907e6fea5cd0744e82a7abbb
This is the biggest bottleneck in my procgen terrain at the moment, putting all of my verts etc. into the world. If the world is really small it's acceptable, but becomes noticeable at any real scale. How can I reduce this bottleneck as much as possible? It looks like the main reason I can't use ecb as parallel is because I need to pass the RenderMeshDescription a Material, can I skip this step somehow and apply this later?
https://i.imgur.com/kFg0zNZ.png
This is the current profiler snapshot, 33ms every time I need to generate new chunks
@turbid sundial you can use MeshData structs which is faster to apply mesh data than new Mesh() and can be used in jobs + burst
examples: https://github.com/Unity-Technologies/MeshApiExamples
also if you're using ecb's you don't have to use .WithStructuralChanges()
in plain human, what is your code doing?
It seems like I do have to use .WithStructuralChanges because of the material passed in, at least on removal I get Entities.ForEach Lambda expression captures a non-value type 'baseMaterial'. This is only allowed with .WithoutBurst() and .Run()
I mention that in the first message ^
I did read up a little on the new mesh data api, but it seemed from the outside like it was more useful for editing existing meshes than instantiation of new ones, but I could be wrong
in plain human, what is your code doing?
it's also for new ones
i'd separate out the instantiation of new meshes into bursted jobs using mesh data and that should be decent speedup (main thread just to start with), in future you could look into separating the instantiation asynchronously, start applying meshes in 1 frame off main thread, apply them to components the next frame(s) on main thread
I'll read deeper! thanks for the tip
๐ฅบ
@night venture seems it is getting pregenerated mesh data and creating new meshes with them
im not sure in interested on that approach, but FOV/LOD/distance could help a lot on this kind of things
i mean, dont render everything, but only "closer to you" things
but, i guess those are my 2 cents xD
ok...here it goes: i have a 2D array of entities. each entity has several components
how can I save it to json?
can I JsonUtility.ToJson(entityArray)?
no
that wont work
you need to look at SerializationUtility
but it works from the World
...that means....?
so you may need to copy/move the entities to a new world then save that
why?...
oh....so move to a blank world to only save that, right?
it might work for a test, but ill need a blank world later probably
Hmmm... A item is an entity in my case, i want to list them in the players inventory. So basically each item has a icon, a list item/entry and a name. Therefore i have following structs... Item{ bool stackable, int amount, FixedString32 name }, Sprite{ short spriteInDatabaseID }, Mesh{ short meshInDatabaseID } Is this too detailed ? Does it make sense to split into three components, one for sprite and one for mesh ? I thought about reusing them ^^ What do you think ? Or should i just merge them all into the item struct ?
and...2 more questions, if u dont mind
@night venture You can also write an extension which returns you all structs/objects of an entity. Then you an write your own serializer
custom serializer?
i dont know what is an "extension", but probably out of my league
@night venture Yeah kinda ^^ Or you could use an existing json serializer... But you first need to write an extension that returns you all components as objects or whatever.
@night venture Look into extension, they allow you to write your own methods for existing structs and classes... without extending them
!extension xD
may I ask anyway about the other thing @ocean tundra suggested?
if using the world serialization utility
2 things left....creating/moving to a new world
it doesn't sound so complex
there are methods on the EntityManager for that
and...if my entites have multiple components, after saving them...will they be stored in json, in a human readable way, with all their components and so?
h sorry its binary
i need a text format ๐ฆ
the idea behind all this is to load my board/scenario from a file
Then a own serializer is your only way
each tile being a collection of components
@stone osprey you mean https://docs.unity3d.com/Manual/script-Serialization-Custom.html ?
@night venture No... i mean a custom serializer written by YOURSELF. You need to find a way to get all components of an entity as objects. Then you need to serialise them into json somehow.
that sounds wild...
ok...i'll ask another way. reflection is there, but if i can avoid it....
You can avoid reflection.... but it will cost you development time
You actually need to write huge switch statements or develop some sort of plugin system for all possibly components n stuff
I would actually go with reflection if such serialisation operation do not happen during the game
oh im working on that
a modding kit
will use code gen to create that switch statement
With json ? ^^
yup
Oh that sounds great ๐
as you sound quite skilled, let me ask:
consider the following scenario: a board is a set of tiles.
my board is stored on a json file similar to [0,0]={Component1, Component2}, [0,1]={Component1, Component3, Component4}....
is reflection the unique way to "create the board" in unity following that?
highly recommend code gen for DOTs
is that an answer for me?
If hes a beginner he should probably avoid code gen ^^
so many things in DOTS needs actual types, for speed
and writing massive switch statements sucks
Yep
what is code gen? link, please
An alternative to massive switch statements is a plugin system... where you plugin your switch cases... way cleaner, but still sucks
reflection?
i use https://github.com/scriban/scriban as a templating lanuage
so i write a system but with {{TEMPLATE}} stuff inside
templating
then from a scriptable object i call scriban and write out a cs file
i dont think that's the way....
the scriptable object is to pass in Unity values if i need it
there might be something simpler
yea probably
Then use reflection
reflection, in fact, is simpler
is easy
write the switch statment manually
we all know im not going to switch xD
but if you have a game not a tool kit
the things your adding/remoing from save/load is quite low
i wont use it on entities, but creating entities with those components and data...why it wouldn't work?
Because... you need to either use Object components... or still write manual switch cases
Theres no "SetComponent(entity, object)" method yet for boxed structs
no, but i have a manager and i can manager.AddComponentData(entity, component_name_from_file), isnt it?
@ocean tundra Yep... trust US, because WE wrote one ๐ well i wrote it, but the others helped debugging and saved my ass
@night venture Nope
Thats not working
How should it ? It cant read your json file :p
Furthermore the generics are missing
You NEED them
i read the file, got the name, cast to class/struct using reflection, and then use it there
yea sorry that wont work
Class is working, struct not
so
you will have your struct loaded from file, thats fine
BUT you will have it BOXED into a Interface or Object
^ Exactly... it actually makes me "happy" that im not the only one with that problem ๐
But... we have a working solution ^^
but having fought it as hard as you did
Not the best... but it works...
went code gen instead
@night venture Im no asshole... i had the same problem. My deserialiser returned boxed structs... so i wrote this here with a LOT of help from several other people in here ( Thanks again ) !
https://pastebin.com/siRZcDBi ( You need to use ASMRefs from unity to get acess to the internals of the ECS )
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
The code above provides methods for EntityManager and ECB to add boxed structs to entities
oh nice
you lose out on all dots goodness doing that
^
but im not using them...i just using them to reference struct
(altough i cant probably serialize a static)
so how would you add them to a entity?
Myclass.struct
...
I dont think that this works
You still need to use generics in that case
Or just use the class... but then, as roycon said, you will lose the advantage of the ecs
i feel like the class thing could work
i wont use the class
but its not too different from the switch
you will need to pass the EntityManger into the class
and it Adds the component
but the StaticClass.struct
BUT you will need 1 class per struct
so proberbly even more code then the switch
no...just adding a few lines on each component...
anyway, im sure u already tested everything and tried all the paths
the switch is like 3 lines per stuct
so at the end, ill have to go code gen
whatever, it will be tomorrow xD
@night venture Or to use the fancy extensions i posted above... wuuu
if your changing the serialization loads then hyes
@stone osprey already saved to my desktop xD
but honestly once your file format is set, and your components written, how often will you actually be changing it?
i need it in json at least once...
remember the objective: define the board in a file
at the end, ill define the board in the editor, using background image as reference
and save the world
but i dont want to surrender so soon!
i havent fought more than 2 hours
xD
Sooo... Sometimes i have the feeling that i design my components too atomic. A item is an entity in my case, i want to list them in the players inventory. So basically each item has a icon, a list item/entry and a name. Therefore i have following structs... Item{ bool stackable, int amount, FixedString32 name }, Sprite{ short spriteInDatabaseID }, Mesh{ short meshInDatabaseID } Is this too detailed ? Does it make sense to split into three components, one for sprite and one for mesh ? I thought about reusing them ^^ What do you think ? Or should i just merge them all into the item struct ? What do you guys think ? ^^
It's so much pain to try to use companions and SortingGroup component...
@stone osprey think about how you are going to use the data, like are you going to need to iterate through a single for maximum efficiency are you going to need to calculate some of it together
it doesn't really matter though you can easily change it later on as you figure things out and want to optimise
Hey, how far from usable/stable is the new deterministic physics system? And, is there a more mature fixed point physics solution (doesn't have to be DOTS, actually probably better if it's not)?
@safe coral it's not multi-platform deterministic yet, should be same-platform deterministic, but even unity devs are giving mixed responses on the forums about that so prob need to run your own tests
unity physics devs: it is deterministic on same platform and we have tests to ensure this
unity burst devs: burst is not guaranteed deterministic even on same platform
Okay, so completely useless to me
haha
I want cross-platform replays
Man, why are they working on a fixed point system if it's not cross-platform deterministic?
does DOTS have sprite sheet animations? If I have a sprite sheet animation object with a convert to entity script on it, will it run fast or still use the slow game object attached to an entity?
new dots physics isn't fixed point, it's all floats and they're hoping burst becomes deterministic enough
@odd ridge No it dosnt
@safe coral Yea new physics its not deterministic
and buest is confirmed NOT deterministic right now
which is very confusing as it has previously been said it was
Ah cool. Okay well that's disappointing. I was just thinking how great if would be if there was a generic number type in C# so you could parameterize the whole system (as you might in Rust for example)
Undoubtedly
Ah well, maybe I'l investigate a third party library or just drop this idea of cross-platform replays
my networking library will have cross platform replays
nice side effect
what sort of game you building tho?
Yeah, we use Photon Quantum for a multiplayer game, and it has its own FP physics engine.
But this game is single player, it's a "turn based bullet-hell roguelike"
https://rhys_vdw.itch.io/enter-the-chronosphere
Just scoping out options for how we might expand it
yea probably too "twich" based unfortuanly
for which?
sorry my networking library is aimed mostly at RTS/Management type games, if the game is too fast passed it probably wont work well
theres a ton of c# 2d physics library
I found this lib: https://github.com/christides11/2DFPhysics
could you grab one of those and implement that
Still WIP, but it might be enough.
It's just a question of whether i want to rely on something that isn't under active development for a polish feature like replays
are replays so important?
Thanks for clarification though @ocean tundra, I appreciate your time.
No, they're not, but if there was a stable physics lib that gave them for free then I'd take them.
ah yea makes sense
It actually would be very cool to have replays
Because the game turns are real time, but the gameplay input is turn based
So you could get a very cool unseen real-time replay of the action
can your entities contain arrays of other entities?
To multithread navmeshquery, I need to pass all of the data from main thread into the job, and then the job will give me a position or some other good info to apply in the main thread, right?
and is my main thread supposed to wait for the job while the job does its calculations?
An entity can have a DynamicBuffer<Entity> attached to it as a component. Entities don't "contain" anything for the record
can I set entities to be child of other entities (and so their position and rotation would be updated)
or do I need to manually update their position and rotation, and theres no parenting?
@gusty comet check the docs
There's a whole built in transform systems
And if you use the conversion flow you will get it all automatically
Definitely aim to use the conversion system, you can use prefabs and gameobjects for authoring
And unity have confirmed it's to be the recommended way to use DOTS
i have no need for prefabs i think
You can use dots via pure code
But I don't really think it's worth it
I don't know if there's a helper method yet for code based transforms
But it's all listed in the docs
You need a specific combination of components to get it working
The conversion system isn't specificly prefabs, look into subscenes. Basically pre optimized "scenes", very fast to load/unload
Hey guys, I want to do a project and utilize a little bit of ECS (and probably dots physics).
Can I access dots in the long term support Unity client or do I sadly have to download the beta instead?
@slim nebula thank you so much
yea my net is pretty slow; i was just worried i'm gonna waste time downloading a client that won't work
has anyone tried to use the serialization package low level API in jobs to deserialize a lot of strings containing json ?
How viable is a pure DOTS approach for procedural mesh generation right now? I remember people talking about it about a year ago and saying that there are more performant ways to go about it. Is that still the case?
I did see that the Mesh API now uses Jobs: https://docs.unity3d.com/2021.1/Documentation/ScriptReference/Mesh.MeshData.html
perhaps ask @turbid sundial
It works great for mesh generation. I've found uploading the data to the mesh is the bottleneck. That still has to be done on the main thread, even if you're using the job api
it makes sense to have component composition? (a component which causes entity to inherit/have 2 components)
eg: component cat, implies component animal, implies component livebeing ?
Okay thanks, I remember you being one of the people saying that it wasn't great a while back so I'm glad to hear things have changed ๐
@night venture You would normally do something like this : "Entity{ Cat, animal, livebeing}" each of them is its own component. But there many solutions... You can also have something like : "Entity{ Livebeing, Animal{ type:cat}"
It depends on what you want and how detailed ^^
Theres no right and false
As far as i know thats what archetypes are for... There no automatic including for other components yet... I think
ok. no component composition xD
btw @stone osprey do you remember i was struggling how to get the components of an entity and so? i achieved that (the easy part)
What you were describing wasn't composition, it was inheritence
@zenith wyvern not really, cause im not inheriting anything, but "adding a few subcomponents" whe adding one
anyway, ill add each one individually by now
going back to my try to serialize entities adventure...
eg: component cat, implies component animal, implies component livebeing ? You're describing an inheritance tree
Components are completely self contained from one another, their relationship is only described by the systems that operate on them
can i serialize NativeArray<ComponentType> ?
@night venture you might run into issues with serializing, im still waiting on this bug to be fixed and its from almost a year ago ๐ฅฒ https://issuetracker.unity3d.com/issues/trying-to-serialize-slash-deserialize-an-entities-world-a-second-time-fails-if-there-are-blob-assets
How to reproduce: 1. Open attached project "Unity Bugs.zip" and scene "SampleScene" 2. Enter Play mode 3. In Game view, click on the...
@safe lintel probably true...but i want to do it just once! xD
do you have a test working code to de/serialize NativeArray?
and...where's "Unity Bugs.zip" ?
i didnt try serializing native arrays, my experiment is here https://github.com/thelebaron/dots_serialization but i really dont remember what state I left it in
Roycon might know more, he gave me loads of helpful ideas on serialization ๐
that's using SerializeUtilityHybrid, which might be similar to SerializeUtility. both save the world
furthermore, i only want to deserialize xD
@zenith wyvern I saw in your blockworld repo that you end up creating gameobjects for each chunk - did you try doing this with hybrid renderer? How come you went in that direction?
Originally gameobject rendering was significantly faster than hybrid renderer for any kind of dynamic mesh, just due to the overhead of ECS managing the RenderMesh shared components for each unique mesh. When I profiled it recently hybrid renderer was at least on par with gameobjects for rendering large numbers of dynamic meshes. In my "version 2" branch I did try it with the hybrid renderer and it worked well. Was much simpler and didn't perform any worse than the gameobjects from what I could tell
I'm hitting a similar bottleneck to one you mentioned around the actual instantiation - using hybrid renderer - mainly because of the main thread
I almost want to be able to spread instantiation over frames (e.g. like the way coroutines work) because it's not immediately necessary
translation.Value = new float3(
Mathf.Cos(planetData.angle) * planetData.radius,
Mathf.Sin(planetData.angle) * planetData.radius,
0f) * localToWorld.Rotation;
that kinda doesnt work
oh the rotation is quaterninon
i need vector3 hm
There's no getting around it - uploading to a mesh is slow. The best you can do is offload all the actual mesh generation into jobs and then decide how to handle building the meshes. You could spread it over a few frames or use some kind of algorithm to combine meshes or at least combine same-block-type-faces in a single mesh
Greedy meshing or whatever it's called
Yeah I was looking into that as well
The less data you have to upload the faster it will be
Can you actually spread over frames in ECS?
Not in any fancy built in way like a coroutine, but you can track when your jobs are completed (jobHandle.IsComplete) and only upload so many meshes within one frame
It's a lot of work to build a framework to track all that but it's certainly possible
Got it- thanks for your thoughts ๐
wouldn't rejecting meshes not in view and etc also help wit that?
pre-culling rejection, might reduce number of meshes you actually are loading
but I am definitely a newb at this point, just learning megacity optimization
pure ECS is also pretty painfult og et started
as a fellow beginner, I learned some pure ecs, took a course, and then finished by reading through ECS documentation which enforces that authoring is the direction unity will go. tiny will be pure ecs
I think a lot of people are mixing pure dots up with the authoring workflow.
Even tiny uses gameObject based authoring and conversion.
The only time I saw unity mention the term pure dots was when referring to a project that doesn't make use of any systems outside the DOTS ecosystem.
oh i see yeah i heard the same, that authoring is the way to go
@zenith wyvern have you looked into the new mesh api? Wondering if there's any gains to be made there ๐ค
If you mean the "MeshDataArray" api I have messed with it. It is indeed faster to upload but because you need to "ApplyAndDispose" you then need to keep an extra copy of your data around and re-apply it all any time you need to make a change
That's interesting
I've found it easier to just stick with keeping your data as Native Arrays and uploading via the MeshData APIs which is an okay middle ground
So I was testing some performance stuff I was curious about with jobs, but found something unrelated to what I was looking, that I recall to have seen before in this channel, is it normal that the **overall ** time that a job takes to complete can be like x4 times higher when doing it in parallel than running it in a single thread?
Here's an example of how I do it in my roguelike. You can still use the Vertex/IndexBufferParams apis to upload data which seems to be a bit faster than just doing SetVertices. You can exactly describe how you want your mesh data layed out with VertexAttributeDescriptors so you know what you're looking for in your shader https://github.com/sarkahn/dots-roguelike/blob/master/Assets/Lib/Terminals/Runtime/Rendering/TerminalRenderMeshSystems.cs
Cool, thanks
@sharp flax there is some overhead to jobs - so it depends on the size of the work and number of jobs you have to iterate through to decide whether or not it's worth jobifying
Yeah can happen. Due to the scheduling overhead. Could mean you don't need to optimize that part (not enough entities to really bother). Could also mean you're doing it wrong ๐
But yeah also remember a forum thread where the additionnal cost of multithread was insanely unexpected
Not doing entities stuff, just isolated jobs testing. I just watched a talk from Scott Meyers talking about cache memory that was recommended by one of the Unity blogs somewhere and started to wonder "what would happen if...". Still don't know much about the most low lvl stuff but this has been revealing. I always knew that processing a few items wasn't worth to parallelize, but didn't expect such difference
It's not few elements either, like 250k but just adding numbers
is anyone else getting "A Hybrid Renderer V2 batch is using a pass from the shader "HDRP/Lit", which is not SRP batcher compatible. Only SRP batcher compatible passes are supported with the Hybrid Renderer."
ArgumentException: GetComponent requires that the requested component 'PlanetData' derives from MonoBehaviour or Component or is an interface.
PlanetData planetData = GetComponent<PlanetData>();
how do you kinda refer to the authred IDataComponent via code
@gusty comet you cant
the way its code generated makes it impossible to reference
make it manually instead
hey @ocean tundra do you have 5 minutes?
probably ๐
achieved to find NativeArray<ComponentType> types = manager.GetComponentTypes(tiles[i, j], Allocator.Temp);, so I can iterate trough components each tile has
can NativeArray<T> be serialized?
hmm you could always loop it and manually write it
ok but how do you reference it? is it not possible to have both authoring component, and reference that entity from code
but ive never tried any serialization librarys on native collections
i know i can do it in OnStart() but i wanted to do it in editor
and...once is written...how i would read it back to a NativeArray<T>?
@gusty comet rephrase what your trying to do and answer the following:
How are you converting your GOs? SubScenes? ConvertToEntity?
Why are you trying to access the Authoring Component?
and WHERE are you trying to do that? (System? Monobehaviour?)
@night venture Same but in reverse,
You could use the File API and manually construct the struct and then add to a native list
But that seams like a bit of a pain
I would gather your types, and convert into a managed List<T>, serialise/serialise that
- converttoentity
- i want to set values for many entities Data scripts in editor. to avoid loading it from monobehaviour during game Start() or from somewhere else also on start()
3.monobehaviour
i see so in editor nice
yes but not manually(by hands) it must be via code
yea so first you will need to manually make the authoring class, then you can either use a custom inspector or custom window using the normal editor tooling
you cannot access any entity stuff from that
as at that point its all still authoring
which is Monobehaviour
can you elaborate a bit more?...on one hand, im not an english native...on the other hand, im not a unity expert...:S
you mean to "copy" Native to List<IComponentData>, and serialize it...and reverse after reading the file?
jsonutility seem to suck (even more for 2d arrays)
how can custom inspector achieve it?
i have spent a few hours trying to do it
bunch of them, different for each tile
@gusty comet Custom inspector can be written to support multi editing, so you can have that enabled, and a button which does your code/data set
i need to set data from monobehaviour tho
@night venture oh thats harder, i would build a "Model" class, a root class containing all your lists/components, avoiding the serialization of Interfaces
@gusty comet inspectors operate on MonoBehaviours?
and you can still select a specific MB to edit it
@ocean tundra look what I got so far:
Debug.Log("L1:");
List<IComponentData> l = new List<IComponentData>();
l.Add(new Tile());
l.Add(new DriveLeftToRightComponent());
foreach (IComponentData c in l) {
Debug.Log(c.ToString());
}
Debug.Log("L2: " + JsonUtility.ToJson(l));
//otuputs
L1:
Tile
DriveLeftToRightComponent
L2: { }
but I was expecting something like { "Tile", "DriveLeftToRightComponent" }
your expected output wont be valid
more like
[{Tile: {TILEDATA}, {DriveLeftToRightComponent: {DATA}}]
but also unitys json sucks
so i dont think it will work with interfaces
it will DEFINITLY have no clue how to deserialize types
yea
theres a package somewhere for it
and make sure you configure typed serialization
no clue what you talking about...but let me ask, before goind down the rabbit hole
does it make sense what im trying to do? each tile is a set of components, i want to edit a json with tile[x,y]={types} and to load it at runtime to create the map/board
maybe...
๐
depends on your requirments
i want mods so im building simlar tools
i just want to edit a json for the map...
but you could use SerializeUtility and have a map editor in game
the advantage of a text format is its super easy for anyone to edit
binary format (that world serialize utilily) is much faster and probably easier to code
BUT you would need tooling in game to make the map
oh and text format you dont need to build the map tooling
can i use SerializeUtility to get a text format?
so, to sum up:
json.net to make json<->code conversion easier/better
and somehow, perhaps using json.net the serialization of nativelist would even work
well...at least native->list->json would work xD
yupp
the guy responsible for json in unity...is the boss son?
i mean...unity json sucks...
yea
they are migrating to json.net
hence the json package
@night venture WAIT
your going to have issues
the deserialized data will be Boxed
you wont be able to add it to a entity
๐
sorry
the boxing thing is super annoying and easy to forget
you can still get it to work
just more round about
some example Code:
IComponent test = new Translation(){SET POS}
so that is Boxing translation into IComponentData
when you try to use EntityManager.AddComponentData it wont let you
yup
add(manager, icomponent) ?
yea
make a interface all your serializable components use
that has a method like that
use that interface instead of IComponentData
sorry it will be Add(EntityManager)
you mean...struct a: Myinterface and IMyInterface : IComponentData?
why not?....and...beside that...are struct able to "inherit/implement a method"?
yea sturcts can
let me draft...
just personal preference
used asset store...
Multiple precompiled assemblies with the same name Newtonsoft.Json.dll included or the current platform. Only one assembly with the same name is allowed per platform. (C:/unity/Library/PackageCache/com.unity.nuget.newtonsoft-json@2.0.0-preview/Runtime/Newtonsoft.Json.dll)
new project?
it may be a dependancy of Entities somewhere
its a dependency, but i cant undo the mess
@ocean tundra fresh 2d project created xD
did u mean this?
using Unity.Entities;
[GenerateAuthoringComponent]
public struct Tile : ISerializableComponent {
public void addComponent(EntityManager manager, Entity e) {
manager.AddComponentData<IComponentData>(e, new Tile() { });
}
}
almost
manager.AddComponentData(e, this);
and entity manager might have to be passed via ref
not sure
ok...and that to make json work and store properly...right? xD
maybe
test it
make a Tile and box it into the interface
then call addcomponent
it should work
๐
current json+namehandling:
{
"$type": "System.Collections.Generic.List`1[[ISerializableComponent, Assembly-CSharp]], mscorlib",
"$values": [
{
"$type": "Tile, Assembly-CSharp"
}
]
}
lets see how it handles reading it back
Question:
What causes a converted Entity to get:
- a Scale component
- a Rotation component
< versus > - a CompositeScale component
- a CompositeRotation component?
And can I prevent them from getting either?
i didnt know there was a composite rotation
there is
somewhere in the transform conversion systems i guess
Yeah and I noticed that some of my entities have one or the other.
@warm panther if you are converting gameobjects, instead of creating them
the object has a few components "by default"
Seems like the root parent" entities have composite... SOMETIMES.
I want to know why they have one or the other.
depends of the object type
Such as?
cube->traslation+rotation
rendermesh, renderbounds
...
so i suggest, instead of converting, knowing what you are doing "manually", to better understand
eg:
manager.AddComponentData(myEntity, new Translation {
Value = new float3(i, 0f, j)
});
manager.AddComponentData(myEntity, new Rotation {
Value = quaternion.identity
});
Material material = new Material(Shader.Find("Standard"));
material.color = Color.white;
manager.AddSharedComponentData(myEntity, new RenderMesh {
mesh = mesh,
material = material
});
But how do I do that in a IConvertToEntity?
im not converting...you can ask for each object components
I really need visual editing so I want to base it off of a gameobject, but some of the intrinsic things it does are weird. I mean I could author as plain prefabs and then convert in my own conversion system.
but that feels like a huge drag at this stage of the project.
how does that affect you?
whats the issue with the composite ** types?
you want to select/filter only some of the entities? both?
The objects have multiple hierarchies and hierarchies of authoring components.
They are treated differently in TRSLocalToWorldSystem; I am writing my own LTW replacement system for a camera centric renderer, and they constitute a number of extra cases that got me curious.
This is my port of Unity's originalc ode.
And I want to clean it up. It could also be made branchless.
And because my system is rather specific, I would like to only deal with objects that I want to deal with, meaning - if I know what components they have, I can get rid of most of the branching even before it needs to be calculated.
sorry. out of my league :S
(but it could also be written branchless, and I wonder why they didn't do that - they have a todo in the code waiting for Function Pointers in Burst)
I noticed that some of my objects weren't being transformed as expected, and that's because they have unexpected scale and rotation components on them. ๐
i would just leave it as unitys code for now
they will come back to it at some point
and if you need the optmization later you can either copy theirs or write your own depending on if they are done
Yeah, right now the optimization is complexity.
@ocean tundra so...tiles was an entity[,]...i was able to iterate trough it and, for each tile get their components
IIRC, the idea was to add them to a List<Component> and then serialize as json. wasnt it?
after that, i should have a file containing aproximately
{
"$type": "System.Collections.Generic.List`1[[ISerializableComponent, Assembly-CSharp]], mscorlib",
"$values": [
{
"$type": "Tile, Assembly-CSharp"
}
]
}
yea
manager.GetComponentTypes returns NativeArray<ComponentType>...how to cast to List<ISerializableComponent> ?
Component Type is not the components
is the definition of a componet
ummm think of it as reflection metadata
but not for reflection
im not really sure how getComponentTypes will help with serialization
i guess you could take the compoennt type and build a entity query...
u mean to loop by myself
but then you need generics to get the ToComponentDataArray....
i dont think you can...
...all that time....? xD
the api is really not setup for untyped access
so...going back to basics...
json file describing tile [x,y]={list of components}
i want to read it and setup entities with those components
yea all the entityquery ToComponentArray methods are generic sorry
you can just make the entity querys yourself
like for your inital file creation couldnt you just manually write it?
...no...xD
i guess just manually write the json file then
but how?...i mean
or you could write some 1 off code to generate one
?? just use Visual studio and edit it
...dont know what "strings" have to write in order to deserialization understands what it has to do.
so easist way is to write some code to manully save
json file describing tile [x,y]={list of components}
i want to read it and setup entities with those components
which is one off
yea so you want a List of a model class (Tile)
X;
Y;
List<serilzedComponent> components
}```
then use 2 for loops for X and for Y to create your inital grid (5 by 5?)
and add them all into the list
then serialze that
i cant loop through entity[,] ?
boom you will have a nice 'template' json
if you serialzie a 2d array you will have to also serilze the width and height
im honestly not sure how json handles 2d arrays
?...sorry...im exhausted...
look, this is what i got when serializing 1 entity:
{
"$type": "Unity.Entities.Entity, Unity.Entities",
"Index": 42,
"Version": 1
}
in other words, nothing
yea no you cant serialzie a entity
sorry i think im missing what you want
end goal is a josn file defining your 'grid' of tiles?
yes, each tile being an entity
ok and you dont want to manually write that file
entity being a set of components
i can write it manually, since the moment i have a pattern
but, as im using entities, i dont have one
using oop (not ECS) that could be fine
but i want to save "an entity"
(and in json format, not binary) ๐
yea ignore dots/oop/data orientated. you just need to get saving/loading working
thats just adding complexity
ok...how i save an entity? xD
ok so you have a inital grid?
atm, made by hand, set of entity[10,10]
ok
so make a new system
and have some trigger (like input.getkeyup...
on that trigger
you want to have a entity query with all your CURRENT tile components in it
already
then for every tile component you want to call ToComponentArray
you now have many arrays of your components
ok...hold a sec.
next you need to loop x and y and construst a list of SerializedComponent
and grabbing out your tile compoents from those arrays and putting it into that new list
now your in memory data is close to your target json
and i 'think' you should be able to just feed that list into json.net and have your output
would Entities.WithAll<Tile> do the job?
personally i would resturcture it so your not serializing a 2d array, instead a single long list of tile (which has X Y and component)
no
thats for Entities.Foreach
you need to be manually creating entity queries for this
GetEntityQuery()
but a single query with just Tile will probably work
but why foreach wont do the job?
you could probably just use EntityManager.Has/Get component for all your other components
i guess you could... you will have to use run and without burst
its just it generates a ton of 'magic' behind the scenes, for this you dont really need any of it
yea sorry, this is one off code, we are not caring about performance
you dont need entity query or for each
just For X and Y of your entities[x,y] array
and use EntityManager.GetComponent or HasComponent
and built the 'per tile' output lists of serialziedcomponents
you mean manager.GetComponentData?
sorry my default for dots is to try follow best pratcices and write for performance ๐
yea
and HasComponent if you have optional components (components only on some entities)
so sudo code:
you are running too fast for my asleep mind.
for y //Loop over your entitys
entity = array[x,y]
maintilecomponent = EntityManager.GetComponentData<Tile>(entity)
AdditionalComponet1 = EntityManager.GetComponentData<AdditionalComponent1>(entity)
serizlaedtypesList = getListFor(x,y) //get the list for this entity/tile position
serizlaedtypesList.Add(maintilecomponent)
serizlaedtypesList.Add(AdditionalComponet1)
//a optional component
if (entityManager.HasCompoinent<Optional1>(entity)
serizlaedtypesList.Add( EntityManager.GetComponentData<Optional1>(entity))
sorry does that make more sense?
manager.GetComponentData is typed, hence it will return only one component. inst it?
yea sorry, missed some generices
so the only way of getting all components would be manager.GetComponentTypes ?
honestly forget about that
you dont need it
how many components do you currently have?
5? 10? 20?
some tiles 4, others 8
we have been dealing with this for a while...
your only using it to generate your inital json file
oooh, ok
after that you edit/copy your json file for everything
hold a sec
your requirement was for deserialization (loading) more then serialalization (saving)
this will give you the inital template and patterns and then you use that instead of this
it may help to generate a few different sizes initially
quick interjection: what is the appropriate job type for looping over elements in a list, e.g. NativeArray or hopefully NativeHashSet?
thought IJobForEach but it's obsolete now?
i think that was for entities...
Oh yes indeed
so??
Get component data can not be called with a zero sized component.
and just add a new Tile?
for y //Loop over your entitys
entity = array[x,y]
maintilecomponent = EntityManager.GetComponentData<Tile>(entity)
AdditionalComponet1 = EntityManager.GetComponentData<AdditionalComponent1>(entity)
serizlaedtypesList = getListFor(x,y) //get the list for this entity/tile position
serizlaedtypesList.Add(maintilecomponent)
serizlaedtypesList.Add(AdditionalComponet1)
//a optional component
if (entityManager.HasCompoinent<Optional1>(entity)
serizlaedtypesList.Add( EntityManager.GetComponentData<Optional1>(entity))
//for tags
if (entityManager.HasCompoinent<Tag1>(entity)
serizlaedtypesList.Add( new Tag1())
heres some updated sudo code
๐
you should probably write at least 1 component that contains data
so you have it in your template
all manual serialzation is terriable atm
unity are very strict about what they open on the entity manager, they DO NOT want us to have any methods that are 'slow'
ok...first thing i notice is it seem its not properly serialized
lets see some code and json output?
List<ISerializableComponent> l = new List<ISerializableComponent>();
for (int i = 0; i < tiles.GetLength(0); i++) {
for (int j = 0; j < tiles.GetLength(1); j++) {
if (manager.HasComponent<Tile>(tiles[i, j])) {
l.Add(new Tile());
}
if (manager.HasComponent<RoadComponent>(tiles[i, j])){
l.Add(new RoadComponent());
}
}
}
Debug.Log(JsonConvert.SerializeObject(l, Formatting.Indented, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }));
results in:
{
"$type": "System.Collections.Generic.List`1[[ISerializableComponent, Assembly-CSharp]], mscorlib",
"$values": [
{
"$type": "Tile, Assembly-CSharp"
},
{
"$type": "Tile, Assembly-CSharp"
},
{
"$type": "Tile, Assembly-CSharp"
},
...
]
}
yea ok
so yor first line List<ISerializableComponent> l = new List<ISerializableComponent>();
you need to make a new one of these PER tile
so its actually
List<ISerializableComponent>[,]
other then that looks right
you could probably play with TypeNameHandling setting
you may be able to remove the highest level one (the list) but keep all the others
another tip i would recommend is to have a containing model class instead of a direct list
thats mainly a webdev json rule
too many suggestions per paragraph xD
but its helpfull if you want to add a 'top' level setting of some sort
ok, so looking at the json, seems its working
yea you just need to break apart the serilzedtype list to be per tile instead of a single massive one
simplified using handling=objects:
[
[
[
{
"$type": "Tile, Assembly-CSharp"
}
],
[
{
"$type": "Tile, Assembly-CSharp"
},
{
"$type": "RoadComponent, Assembly-CSharp"
}
],
...
nice
๐
you should just be able to do the reverse
json.net wise i mean
then you will need to loop x and y
and do the following steps:
1 EntityManager.CreateEntity()
2. Loop over every component
2a. call component.AddComponent(Entitymanager, newEntity)
hmmm...like this? :
string txt = JsonConvert.SerializeObject(l, Formatting.Indented, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Objects });
List<ISerializableComponent>[,] l2 =JsonConvert.DeserializeObject<List<ISerializableComponent>[,]>(txt, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Objects });
for (int i = 0; i < l2.GetLength(0); i++) {
for (int j = 0; j < l2.GetLength(1); j++) {
tiles[i, j] = manager.CreateEntity(archetype);
foreach (ISerializableComponent c in l2[i, j]) {
c.addComponent(manager, tiles[i, j]);
}
}
}
yea that looks right
today u deserved a beer, coke or whatever
it works?
haven't tried yet, but looks promising
(and furthermore when undesrtanding what it does) ๐
yup
ArgumentException: Unknown Type:Unity.Entities.IComponentData All ComponentType must be known at compile time. For generic components, each concrete type must be registered with [RegisterGenericComponentType].
implement IComponentData directly on your structs?
probably at c.addComponent(manager, tiles2[i, j]);
not via a parent interface
but then, how it know it has to implement addComponent?
ok, i forgot xD
and can you show me the code for your addComponent
using Unity.Entities;
[GenerateAuthoringComponent]
public struct Tile : ISerializableComponent, IComponentData {
public void addComponent(EntityManager manager, Entity e) {
manager.AddComponentData<IComponentData>(e, this);
}
}
yea thats wrong
xD
manager.AddComponentData(e, this);
should work
but also this is a tag component...
you may have to use manager.AddComponent<Tile>(e) instead
but for non tags i think its right
....so....? xD
so
try this first manager.AddComponentData(e, this);
if that dosnt work
then try this manager.AddComponent<Tile>(e);
on my way
if that still dosnt work then no clue ๐
should ISerializableComponent implement IComponentData ?
seems it works
nice
atm, im about to doubt it ๐
2am in the morning here...
im hoping it brings a whole slew of updates to every other package too.
also want an easier to use dots audio package
and navigation
I have been keeping away from dots audio so far
is it usable?
or should I keep away a while longer ๐
is there an alternative to using .Equals on structs? I keep getting a Burst error saying my IBufferElementData does not contain IEquatable<object> even though I do have it implemented.
Burst error BC1002: Unable to find interface method `System.IEquatable`1<object>.Equals(!0)` from type `DotsPhysics.PhysicsHitBuffer`
can you show the component code?
public struct PhysicsHitBuffer : IBufferElementData, IEquatable<object>
{
public FixedString64 name;
public PhysicsPositionData positionData;
public PhysicsHitData hitData;
public PhysicsDebugData debugData;
}
i wonder if .equals is doing some sort of boxing
oh of course
its to object
also shouldnt there be a equals method?
I tried doing my own Equals as well and still got the burst error
IEquatable<object> change object to the actual type
objects = class which wont work in burst
and im pretty sure you need to implement the interface
lol thanks no idea why its workign now but it is. I swear i tried this before
thanks again @ocean tundra
all good
I must of had some other burst error junk before
If I do
Dependency = Job1.Schecule(Dependency);
Dependency = Job2.Schecule(Dependency);
Will job2 always run after job1, or only if there is actually something in job1 that job2 reads/writes?
yea job 2 will be after job1
I'm trying to schedule these two to run at the same time
yea ok
but it keeps hating me when I try lol
var initialDependency = Dependency;
var job1D = Job1.Schedule(initialDependency );
var job2D = Job2.Schedule(initialDependency );
Dependency = JobHandel.Combine(initialDependency , job1D , job2D );
JobHandle handle1 = new Job1().Schedule(count1, Dependency);
JobHandle handle2 = new Job2().Schedule(count2, Dependency);
JobHandle.CombineDependencies(Dependency, handle1);
JobHandle.CombineDependencies(Dependency, handle2);
Ok so this produces error:
InvalidOperationException: The system System1 reads DynamicBuffer1 via System1.Job1 but that type was not assigned to the Dependency property. To ensure correct behavior of other systems, the job or a dependency must be assigned to the Dependency property before returning from the OnUpdate method.
so I thought, I must do
Dependency = Job1.Schedule...
no at the end
where you combine
you need to assign back to Dependency
**Dependency = **JobHandle.CombineDependencies(Dependency, handle2);
sigh lol
I'm still not used to dependency management really
been doing it for ages but it still catches me
yea me too
ctrl f on CombineDependencies to check all usage lol
ok good I did get it right in other places haha
Hi guys, is there a way we can manual control culling in ecs/ hybrid rederer? I have some object have shader that changes position, find the current culling system doesn't work on that
@frigid quarry im not sure which system(s) control it
but you should be able to find them. copy them into your project
and disable the original systems
is this tutorial still relevant?
https://www.youtube.com/watch?v=BNMrevfB6Q0
having some trouble replicating the behavior shown ๐ค
more specifically, it seems like their bullets are converted to entities, but still use the update function... am I missing something here, or is this tutorial just skipping crucial parts of information?
In this video, learn about what's involved in migrating existing game code to the new Data-Oriented Technology Stack (DOTS), which comprises the C# Job System, the Entity Component System (ECS), and the Burst Compiler. You'll also gain an understanding of the performance benefits you can expect from these systems. Finally, you'll learn when it m...
havnt seen it
but at a guess no
oh i was at that session
๐
definitely not relevant
the ideas and concepts will still apply
but any code will be long obsolete
got it. got any recommended tutorials to follow? been pulling my hair out over this for the past few days...
umm just the offical docs really
i dont know any up to date tutorials
i think unity learn has something
but not sure its for the latest
the problem is its still very work in process
so not much offical unity focus on docs
and anything the community makes gets out of date fast
right, definitely seems that way after the tonne of tutorials ive been trying to follow ๐
the core concepts should all be the same
and then look up the same 'thing' in the entities doc
and see the current way of doing it
EG any tutorial that has you writing a job manually to loop over your entities
you should use Entities.Foreach for that
and theres a massive doc page on that
and feel free to ask here, most people are happy to help
any chance you could link me to said entities docs? ๐ค
ah, sweet. Thanks ๐
WARNING
Do not use the Build and Run menu "File > Build and Run" to build DOTS projects. It might work in some cases but this approach is not supported. You must build your project using the Build or Build and Run buttons at the top of the Build Configuration Asset Inspector window.In particular, entity subscenes are not included in builds made via the Build and Run menu and will fail to load with the following error message showing up in a development build: "Could not open <path>/<guid>.entityheader for read".)
what exactly does this mean? i cant find any "Build Configuration" inspector window...
its another package
Standalone Builds
Making standalone builds of DOTS projects requires installing the corresponding platform package for each of your target platforms:com.unity.platforms.android
com.unity.platforms.ios
com.unity.platforms.linux
com.unity.platforms.macos
com.unity.platforms.web
com.unity.platforms.windows
After installing the platform packages you need, create a "Classic Build Configuration" asset for each platform (via the "Assets > Create > Build" menu). The properties of that asset will contain a "Scene List", which is the only way of adding subscenes to a standalone project. Make sure you add at least one scene or that the "Build Current Scene" checkbox is toggled on.
speaking for this?
yea those
aight, ive got an error when installing those packages... will reinstall and post here
Library\PackageCache\com.unity.entities@0.16.0-preview.21\Unity.Entities.Editor\LiveLink\StartLiveLinkWindow.cs(370,39): error CS0104: 'Platform' is an ambiguous reference between 'Unity.Build.Platform' and 'Bee.Core.Platform'
so i should rename the "Platform" that these errors are referencing
to "Bee.Core.Platform"?
what no
'Bee.Core.Platform' is the wrong one
never heard of that
name that something else
it must be something you added in your project
the only packages ive installed, with ... 5-6 small scripts?
none of which have the namespace "Bee"
whats your code namespace?
DotsTest
weird