#archived-dots
1 messages ยท Page 262 of 1
yaaay, it finally works
how convenient is it!
it will link your own new assemblies together as well
(dont judge the ui code too harshly, literally first thing i ever wrote in ui elements. was my learning case)
ok, normal renderpass works
now how to use it with collision texture
hm
Ok, I got it
was simpler than I expected kek
ok, it really is seems pretty simple
now, how do I get a color of pixel
of chosen viewport point?
your texture size should match the dimensions of your resolution
I don't want it to be relevant
I do have a viewport point
upon clicking
I kind of want to just get that pixel disregarding what size texture is, based of viewport
i don't really understand what your saying
your output texture neds to match screen resolution to have the right colors
does the tutorial not discuss the concept behind this?
I successfully have .50 dots installed and my FPS issue is gone
That FPS issue crept in one of the september-nov unity upgrades
I wonder how I can make Material to have colour based off entity id
I saw this a number of times now but I don't remember where. Certainly in the forum. I think a google search can lead you there.
any tip on keywords?
I have been looking for this info for hour already
best I got: source of RenderObject feature kek
keywords: "hybrid renderer color per entitiy" - hope you find what you're looking for
I've also read something about MaterialBlocks
nnnah, I'm not sure that's what I'm looking for
here's the thing
I need 2 renderers
1 for actual rendering
the other for collision rendering
where I render object's opaque basically
and then by reading pixel I determine what id of entity is inside that pixel
and I need to render 2nd without affecting first
Potentially maybe I just need another MeshRenderer for this
oh well, you can't add 2 MeshRenderers on same object
@rotund token is every folder inside that scripts folder also given an asmdef?
Hello everyone, I'm currently starting using DOTS and I cannot figure out how to create a Character Controller.
Can somebody give me a good example of what it can be ? (nb : it's for a FPS)
Here one. But it's broken by new version and pretty out dated
https://github.com/ssell/UnityDotsCharacterController
Thank you so much
Here my take on it without old struct jobs
but it's also outdated
haven't touched it since 0.50 release
https://github.com/JonasDeM/EntitySelection.git does something similar for entity picking. maybe a good starting point
but it's for runtime, not for scene view
oj
oh
I see
it uses shader
Might be actually good, thanks
np
Getting a character controller right is a big pain so: https://assetstore.unity.com/packages/tools/physics/rival-dots-character-controller-195567
yep, that's actually seems like a real solution
My sincere appreciation, sir.
how can I use generics in job decryption/entity query?
i.e. I have interface with method .Evaluate() and 4 components that implements it
can I make generic job with <T> where T:Interface?
how to query for that?
what's generic? the job or the data?
job, data just inherits interface
huh, wasn't sure if it would work to just build an interface deriving from IJob or others.seems like someone already did the work https://nagachiang.github.io/unity-dots-creating-generic-systems-with-generic-jobs/#
but it uses generic system also so there is still one system per component
I would like to do something like this:
var GenericQuery = GetEntityQuery(ComponentType.ReadOnly<IMyInterface>());
hm, maybe the polymorphic struct from PhilSA can help?
then phils solution will help. although it will source gen a switch
Yes
I like to keep my library / game very modular and reusable
Heavy use of asmdef ensures no circular dependencies
This works fine what's the problem?
it will?
Sure why not?
You can use generics just not with entities.foreach/ijobentity (no code gen)
@rotund token have you seen the post from dreaming in the events thread?
Write key-value pairs to blocklists (NativeStream or similar) in parallel.
Copy the blocklist to a NativeList.
Sort the NativeList.
Allocate a second NativeList and store start offset and count pairs for matching keys
Iterate by key in parallel.
found that approach interesting
that's what he does in his animation package
certainly interesting when sorted by chunks especially
well obviously now you need to implement it and compare ๐
yeah ... ๐คฃ
I don't think it's that fast though. Too many steps involved. Kind of the overhead when you need determinism
I'm gonna take the interesting parts out of it. Namely, getting rid of the NMHM, utilizing a NativeStream/UnsafeParallelBlockList for fast writes, transform into a NativeList in single thread (no add problem) sort by chunk ptr (if possible) or indexInChunk. building the start offset and counts this can be parallelized. could be noiiice ๐
Is the default NativeList.Sort any good? Sorting 500k takes 8ms
for a sort that sounds reasonably fast
Well ... then case closed ๐คฃ
shame though, sounded interesting without NMHM. maybe sorting by entity is a problem. The compare could certainly be written in a faster way
you can pass in your own compare
but entity compare is already setup to only cmopare the index
{
return Index - other.Index;
}
so not sure how you could make it faster since it already skips version so it's just an int compare
ah thought it might compare version. never checked
I'm just barely scratching the 60fps with using the new method of just writing to the NMHM key/values array
Pretty cool when this started with race conditions and Interlocked with 20ms. (Interlocked was the fast part, rest was slow)
Anybody knows whats the state with reflection probes with URP and hybrid renderer v2? The reflection probes stop working when they are in a subscene
If I want to store a pointer to a struct on the managed heap, I would need to use GCHandle.Alloc(struct, GCHandleType.Pinned) first, then get the struct* or IntPtr to the struct, and dispose of the GCHandle when I don't need the pointer to the struct anymore. Is that right?
yes
Is it possible to even get a pointer to the type of the struct (so for example Vector2*) outside of a fixed block?
Or do you need to use IntPtr
from e.g. GCHandle.AddrOfPinnedObject
I guess stackalloc is another way of getting a pointer although it's only on the stack
Interesting, I've never seen that keyword. I assume this would let you create a stack array and manipulate it with a span without ever putting something on the heap?
yea
You can also use UnsafeUtility to convert a struct to a pointer and back. It will free you from writing everything inside a fixed block and disposing of GCHandle before leaving the scope. You can store it as either void* or IntPtr, it doesn't affect performance. Just use whatever seems cleaner for you (void* requires to write a lot of 'unsafe' keywords, storing IntPtr requires converting it to void* before passing to methods).
https://docs.unity3d.com/ScriptReference/Unity.Collections.LowLevel.Unsafe.UnsafeUtility.html
Basic question but does anyone know if dots physics is simple and robust enough even for an idiot like me to use currently
There's a bit of a learning curve and it depends on your workflow. If you use subscenes and Hybrid Renderer it's quite easy to setup
just looking at the physics example helped me quite a lot to understand how it's working
Ok thanks I guess I'll give it a try
why do you need subscenes for physics?
Are there any restrictions on using generic structs inside components?
faster and easier conversion. it's not needed really but much of the setup is handled that way more conveniently
should ComponentTypeHandle be used with IJobEntityBatch? (i'm still on 0.17)
is GetComponentTypeHandle<>() or batchInChunk.GetNativeArray(); heavy or something?
do I make less allocations with this compared to entityQuery.ToComponentDataArray<>()?
Yes. When you do ArchetypeChunk.GetNativeArray(ComponentTypeHandle<T>) - Unity internally takes the pointer where the component data is and assigns it to the NativeArray's pointer (so its actually aliasing the pointer)
so is this preferable way to iterate entities/entityqueries?
I think with ToComponentDataArray, there is a memcpy involved somewhere in the function chain, but I forget exactly where
yea - I'd imagine so
thanks!
is new NativeMultiHashMap<Entity, NativeArray<float>>() good or will it bite me later?
personally I use this var translations = (Translation*) batchInChunk.GetComponentDataPtrRW(ref Translation_ReadHandle);
makes it possible to use a ref then ref var position = ref translations[i];
There's not much difference apart from the small overhead of checks Unity is doing in GetNativeArray. I just like it more that way.
reason why I started this was that burst has a much easier time to vectorize pointers
don't ask me why
some methods I just could not get it to work even though the code did 100% the same thing
Uhm, I'm pretty sure NativeArray in a NMHM doesn't even compile
there's also no reason NativeMultiHashMap<Entity, float>() will have a float[] for every key entity. That's what the multi implies
https://www.youtube.com/watch?v=xSAbPPFINlM
fun little rollback test. save system wasn't designed for this but handles it pretty well.
0.5ms to serialize, 0.4ms to deserialize
it compiled that's why i'm asking ๐
did it run though?
nope
sry my bad ๐
nice!
Very nice indeed. How much data does this need?
im only saving translation/rotation/physicsvelocity in this particular demo
let me see what size it was
is every frame saved or how does this work?
yeah i was saving every frame for this
you could do whatever you want
for a 10min demo every frame is just easiest to implement
EntityManager.CreateEntity(typeof(Save));
is literally all you do to save a frame
cost of 24 frames in data
first frames clearly compressed better
probably a lot of 0 velocity
and all rotations would have been identical
so yeah im only compressing per component atm
if i do a final compression pass on the entire data it reduces size by another 20-25%
but im also only use lz4 so you could compress even better with something else
originally i compressed over whole set but thats 1 thread large time
cool, maybe you can use the netcode delta compression.
doing it per component means i can compress each component in parallel was much faster
well i have no interest in taking this further
this is a save library not a rollback library
just thought i'd see how it did
makes an interesting/fun demo
hehe, yeah. don't overdo it ๐
although, if you ever want to take it further that would be a sick feature
what are you planning with the save library? i.e asset store or not
saving? ๐
oh you edited
not sure
it's pretty done i think
i'm just integrating with my demo game atm
to see pain points
the only thing i'm not sure about for usability is the prefab registration
if you're just saving subscenes / existing entities you don't need prefabs, it just gives everything a unique id and maps to it
but if you instantiate at runtime the system needs to find the prefab for it
which is handled, it searches for a matching prefab in the world
but how to uniquely ID these could be a bit awkward for a user
like if you have a prefab in 2 separate subscenes
they appear as the same thing
now personally in my project i have a single subscene with all my prefabs
then use weak asset references to avoid having duplicate prefabs
but do i want to ship or even enforce this on others
(it is how unity builds their demos as well though)
prefab per subscene is really bad memory use so its a preferred pattern i think though
didn't unity add cross scene linking now?
cross scene linking isn't so much the issue, it's if you link a prefab
each subscene gets its own SceneSectionData
which ties it to the subscene
hm, yeah, I'd enforce saved entities in one subscene
maybe there's a good solution for it. I don't know but it sounds like quite the hassle
i know my solution works really well but it requires users to use it
i was hoping to make this completely non-invasive
which apart from this it is
can drop it in any project and it should just work
that's pretty awesome and honestly something I'd expect from a dots asset
(well it'll just work saving translation, rotation, physics velocity)
if you want to save your own component need to add [Saved] to it
which is the point, it shouldn't save everything
oh wow 0/10 too much work! /s
sounds all great, looking forward to it
I wrote a non-generic save system in 2019 (18?) and even though that was quite easy, lots of code was involved to add new comps and then instantiation. I would rather use something like this
yeah this is the 3rd save system i've worked on
does it use source gen?
Very nice! Is this still using the 3rd approach you mentioned?
yes
no
no code gen
i just use dynamictypehandle
with typeindex
oh, and with that you get attributes?
How are you liking this approach compared to the second one? Since I also need to move away from SerializeWorld eventually ๐ข
or is this reflection based?
no reflection except to get the attribute at the start
ah okay, was wondering how that would work
{
if (type.TypeIndex == 0)
{
continue;
}
if (type.Category == TypeManager.TypeCategory.ComponentData)
{
if (type.Type.GetCustomAttribute(typeof(SaveAttribute)) != null)
{
this.AddComponentSaver(builder, type.TypeIndex);
}
}
else if (type.Category == TypeManager.TypeCategory.BufferData)
{
if (type.Type.GetCustomAttribute(typeof(SaveAttribute)) != null)
{
this.AddBufferSaver(builder, type.TypeIndex);
}
}
}```
{
var stableTypeHash = TypeManager.GetTypeInfo(typeIndex).StableTypeHash;
var saver = new ComponentDataSave(builder, stableTypeHash);
this.savers.Add(saver.Key, saver);
}```
just gets all components with the attribute from the typemanager
then from there it just uses dynamictypehandle to write out the data
went over it a bit more on the forums
And you migrate if any type hashes change?
damn, sometimes burst needs like over a minute to compile -.-
not sure what that's about. it's sooo annoying that safety checks defaults to enabled and I have to turn it off every time
yeah
I guess I will be going with something similar once I get around to it, this approach seems really solid
its really cool
i wrote a couple of migrations depending on how comfortable user is with pointers (high performance) and just easy
it seems like its much simpler to do something like this in dots than monobehaviour
public class TestComponentForMigrationMigrator : ComponentDataMigrate<TestComponentForMigrationMigrator.Before, TestComponentForMigrationMigrator.After>
{
public override ulong From => 1392796844747678277;
public override ulong To => 17841778420484547873;
protected override void Migrate(ref After newComponent, in Before oldComponent)
{
newComponent.Value = oldComponent.value;
newComponent.NewValue = 5;
}
public struct Before { public int value; }
public struct After { public int Value; public int NewValue; }
}```
is like the easy version for users
i wrote a typedatabase to record old types
so you can get info easily
so you can find your old components rather than just seeing a magic number
Awesome. Let me know if you ever make it public or anything, I'd happily pay for something like this
the data oriented approach is what makes it easier really
yeah just having to add saved to the data is just ridiculously easy on the users end
it is and while this could be done with monobehaviours, the strict DOD limitations are hardly followed in OOP approaches so it all gets kind of messy
it kind of amazes dots hasn't taken off years ago
dots seems way simpler and more logical to me than oop
oop is to big in the industry
outside of game developement
to be used in broader context here
or I should say was
kind of crazy, creating spellCreateData and directly executing the spell calculations -> 11.2ms writing the spellCreateData and then calculating it. 8.0ms + 6.85ms. for some reason one thread is completely idle. nativeThreadIndex is weird...
I know there is a few obscure devs that use it though
it's easier for companies to find someone with experience with oop than dod
so oop is economically more viable
I dunno, we used MVC around 2008 for web development and that was already 100 times better. With long running engines you have the problem of technical debt so moving away from OOP is hard
And I also don't know what makes someone "good" in OOP. The spaghettis I've seen ... /shudder I consider someone good when he doesn't write endless amounts of spaghetti code. If he's capable of that, he's also capable of DOD
but let's face it. most programmers suck and should do something else
yeah from what I've seen most oop code is about obfuscating data and making things look more complicated than they are
to their defense, corporate loves OOP. it's like the dream came true. have 100 people work on 100 different things and it all comes together. but yeah, that's what it is. a dream. the reality is that you have people just dedicated to clean up the mess.
when you can throw 100s of people at something management just doesn't care much. they rather see progress
I bet progress would be faster if they used something like dots though
and progress can be pretty great in OOP. just code something. others will figure it out or write endless amounts of wrappers around it
I think having 100 people work on 100 separate things and having it come together at the end is hard no matter what you do
exactly, it's impossible in my opinion. a few core people have to work on the core. when that's solid, and this takes time it gets more manageable
I think it depends very much on the type of application. With people moving away from monolithic applications in spaces like web development cooperation becomes easier as long as your interfaces are well defined
tbh enterprise code today is pretty solid. it's not the mess that it was years ago
I think you will have very different experiences based on the company ๐
DI and proper patterns that proofed solid have streamlined the process somewhat
that's for sure ๐
enterprise code as in, coding style.
the nativelist block reserve is really one of the sickest optimizations I've done. Can't thank you enough @rotund token ๐ It even blows NativeStream and UnsafeParallelBlockList out of the water. As it's pre allocated it has nearly 0 impact
yep
if you know your upper limit and code can handle allocating in chunks its about as fast as it can get
I still have to figure out how I can handle the capacity in a better way. Right now I'm allocating much more than I need. I've casters, triggers and buffs that potentially calculate spells but all are unknown until it happens.
although this is much more of a problem in the stress tests I'm doing. In real scenarios it shouldn't be possible to hit the limit
uhm ScheduleParallel(testList.Length, 64, Dependency) how does this work in an IJobFor? There's only public void Execute(int index) - no inner loop count
guess I'm looking for IJobParallelForBatch
inner is how the the scheduler works
it'll work on 64 elements per thread before trying to find a new range
its purely an optimization value
6.04ms -> spellcastjob + write to list
7.32ms -> calc from list
instant calc method:
5.27ms -> spellcastjob
11.14ms -> spellcastjob + calc -> 5,87ms for calc``` this confuses me right now
calculating from the list is 1.45ms slower. I'd have expected it to be on par, maybe somewhat slower but not that much
aha! my block reserve size was too small. 4.58ms now. faster than the previous. noiiiice
i love when i lose some time but gain more ๐
I have been trying to find this but don't see it anywhere is there a way to say have a system with a group that have all the entities that have had a particular component added since last run. I don't know if I said this well or not...
Anyone have any ideas about this?
you could add a tag to all the newly created and remove the tag afterwards
can jobs read data from static lists/arrays assuming it is only allow to read from them and not write ?
or do they also have to be native containers
only static readonly
burst supports something like
public static readonly int[] Indices = new int[] {1,2,34,5};
which unity version is stable for the dots and some child packages not appering in 2021 i decided to learn dots which version should i use ?
actually, what if the array has a reference type will that still work ?
probably not
2020.3
So there is no built in way to do it then?
no. why would there
there is no entitites packages in 2020.3 doesnt appear in package manager how can i install them
you have to add it manually
thanks in some videos i see in unity registery so i confues i will add on git thanks
hmm thats a pain since i need to do jobs on a graph of nodes
๐ฆ
well yeah that wont work in a job
you saying i should use structs for them ?
need to build it from structs and pointers
pointers ? so ill have to use unsafe c# to setup my graph data?
'unsafe'
yes the context unsafe ๐
what version of vs
2022
think i saw a few of these when i upgraded (in rider)
had to clear library to get rid of them
haven't come back though
just wait for the release instead of fiddling with the code yourself tbh
release of what?
entities
if you're waiting for 1.0 that's going to be a while...
any this issue happens just in the default packages folder nothing to do with changing the package
a few more weeks for 0.51 for 2021 ....and 1 year for 1.0 2022
not use 2022
uhm
ohhh
yeah
Can someone explain to my why this job can't be vectorized?
Remark: ChunkDataUtility.cs:65:0: loop not vectorized: loop control flow is not understood by vectorizer
Remark: ChunkDataUtility.cs:65:0: loop not vectorized: loop control flow is not understood by vectorizer
Remark: ChunkDataUtility.cs:65:0: loop not vectorized: loop control flow is not understood by vectorizer
Remark: ChunkDataUtility.cs:65:0: loop not vectorized: loop control flow is not understood by vectorizer
Remark: EntityQueryManager.cs:752:0: loop not vectorized: loop control flow is not understood by vectorizer
[BurstCompile]
public struct EvaluateAxisQuadratic : IJobEntityBatch
{
public ComponentTypeHandle<Axis> AxisTypeHandle;
public void Execute(ArchetypeChunk batchInChunk, int batchIndex)
{
var axes = batchInChunk.GetNativeArray(AxisTypeHandle);
for (var i = 0; i < batchInChunk.Count; i++)
{
var axis = axes[i];
axis.value = (axis.m * math.pow(axis.input - axis.c, axis.k)) + axis.b;
axes[i] = axis;
}
}
}
is this because of floats? (all fields of Axis are of float type)
what does the burst code look like
to start with
batchInChunk.Count
try use axes.Length
ArchetypeChunk .cs
public int Count => math.select(m_BatchEntityCount, m_Chunk->Count, m_BatchEntityCount == kUseChunkCount && m_Chunk != null);
also this doesn't look like your actual look. it looks like the chunk code outside the job. if you go look at the burst inspector you'll see like 2500 lines of the code are not your job
bruh, this error remains
I can't use debugging because of it
since VS can't build it
I even tried 2019 VS
you shouldn't have to build to attach a debugger
Try rei stalling entities
do you have a custom version of entities in your packages folder?
or is this in the package cache
did you delete your library or just do reimport all
all installed through dependency on hybrid renderer
just reimport all
Just create a new project and move your assets over
yeah dont bother with that just delete the library
all right
that change added one Remark: ChunkDataUtility.cs:65:0: loop not vectorized: loop control flow is not understood by vectorizer
yeah this has nothing to do with your loop
i have 15 of these for a job with 1 loop ^_^"
honestly the llvm ir optimisation diagnostics tab is pretty useless
i never use it
so it's because of IJobEntityBatch per se not because of my code? should I even bother with IJobEntityBatch then (i'm still on Entities 0.17)
get array outside and use IJobParallelFor instead
Why are you not upgrading?
for what benefit?
nnnnope, deleting library didn't help
i'm bound to 2021 with my animations
You should be using mecanim
so are you saying that those lines in optimisation diagnostic are useless?
Otherwise you won't even be able to upgrade with 1.0
as long as unity doesn't provide anything remotely good I don't care, I'm using HR only because I don't want to write renderer for static objects right now
Even 0.50 is already a lot better than 0.17
i can wait until 0.51
this is what your actual job code looks like
{
public float m;
public float c;
public float k;
public float b;
public Unity.Mathematics.float3 input;
public Unity.Mathematics.float3 value;
}```
assuming this was your struct
not sure if they were float or float3
Any other ideas how can I fix it?
and when 1.0 hits I will rewrite my gpu animation instancer with this: https://forum.unity.com/threads/new-batchrenderergroup-api-for-2022-1.1230669/
edit -> preferences -> external tools -> regenerate project files
otherwise download rider ๐
Ok
everything is a singular float
it seems to vectorise? ๐
not really it's all scalar
I guess I'll try rider xD
not anymore, kek
no sneaky email hanging around?! ๐ฆ
managed to use mine for like an extra 3 years after i finished uni
this was quite a while ago now though
(not for rider didnt exist)
any idea why and how to change it?
no email in my uni at all xD
dont think it likes pow
breaking it down
a quick google seems to imply yes it doesn't exist
if you konw your x,y are both positive you can use
exp(y*log(x))
doing this definitely simds the whole thing
like seriously the entire thing
ties all the way back into the schedule job code
but I don't have y?
pow(x,y)
what assembly shows when it vectorize?
you want to see lots of purple!
ps for wide
ss for scalar
go watch the burst talk on it
anyway enough optimising someone else code, need to optimise my own
cant do everything wide
also
if a loop has to be vectorized
you can use
Loop.ExpectVectorized()
UNITY_BURST_EXPERIMENTAL_LOOP_INTRINSICS
and it'll be a compile error if a loop isn't vectorized
very handy if you vectorize something to protect it from breaking in future
ok thanks a lot!
it's a bit finicky though
there is also possibility to manually vectorise this with float4 everywhere
often the only way to reliable get this to work
but I wonder if I can easily reinterpret Axis to Axis4
you know what, it's time to test IEnableableComponent, see what's broken
when i was looking at burst for your code it was doing a proper check for this
Unity is apparently renaming the hybrid renderer to com.unity.entities.graphics
We're renaming com.unity.rendering.hybrid package into com.unity.entities.graphics for Entities 1.0 release. ( more details in this document: https://docs.google.com/document/d/1rQj9_ukauyB...
I do welcome this change as it's now more obvious what it's for
I updated dots related packages to the newest versions(0.50.1 entities etc) - everything works except mathematics 1.2.6 which should stay the old version (1.2.5 works for me)
I just checked the changelog and it doesnt say anything about increasing the version of dependencies. But yea, if it compiles, it should work fine.
Yea, nothing changed with 1.2.6 so you'll be fine
"upgrade" to 2022.2 alpha... and burst crashes. FUUUUUUCK
thats what I get for trying to use Unity's automated upgrader. pain
or.. maybe not use alpha
is current dots even compatible with it?
(haven't followed this part)
burst itself should work though
Not using dots, just just base burst - jobs - collections
having burst itself installed on latest alpha doesn't crash things here... so much be some script on your end that triggers it
why do you assume it's the auto-upgrader that messed it up? it's supposed to just adjust things for the changed API so things wouldn't break
if it straight up crashes, I'd try wiping the library folder in case there's some cached stuff from previous version that's incompatible (this wouldn't be the first time).. and then start looking at the scripts using Burst that might break it so you can pinpoint the source of the issue
Yep yep, going through the process now. Happens every update yet I keep thinking the upgrader would work and the major update would work instantly upon launching.
I can't say I've had similar experience on my end, never had issues with the autoupgrade scripts myself. of course this doesn't mean it wouldn't break for others.. maybe you've been just very unlucky for it to break on specific things you use it for
Fuck. I think I narrowed down the crashing to somewhere in my shader stack. This is gonna be pain.
What is the best way to do an array in a ComponentData struct?
I'm saying scew it and just making int a1;int a2;int a3; etc for now
I think I had this question for close to a year now... No one here or on the forums had a good answer that worked. Kinda silly, but its starting to hit my core architecture's foundation.
If I don't get help now, its going to be a costly refactor in the future.
I can get my game working, but I'm a fan of eloquent and beautiful looking code especially when it impacts functionality.
Do you need it to be in an IComponentData struct? If not, dynamic buffer is the recommended approach for having an "array" associated with an entity.
why cant jobs use reference types but regular threading can, whats the difference between jobs and threads?
Thanks Graviton, I think you helped me, it's not pretty, but better than nothing.
I think you can technically put a FixedList* in an ICD, but you would need to have some guarantees about the number of elements and how many bytes each element requires.
Another option is to use a blob if the arrays are static and set up at conversion time
But dynamic buffers are definitely the easiest/cleanest of the 3 to use.
many ways actually. Pointer and manual allocation/deallocattion. BlobAsset reference. DynamicBuffers. NativeMultiHashMap with entity as key.
anyone know much about IJobBurstSchedulable
and any reason you wouldn't use this over IJob?
as far as I can tell it's IJob that can be schedule from burst code (ISystem)
which leads me to the question of there must be a difference otherwise why not just rewrite the IJob scheduler to support burst
what information do we have about it? I just read it's removed in 0.50.
scheduling jobs from jobs was on my wish list. never heard of it before
haha, Unity is calling it 0.5 ... whoops ๐
well i was not expecting it to be faster for me to write 10mill elements to a hashmap in single thread vs 24 threads
that locking kills it
in other news, wrote a new container NativeLookup which is basically just an alternate NativeMultiHashMap without the ability to remove elements and all my high performance batch operations built in
CollisionFilter Filter = new CollisionFilter
{
BelongsTo = 0xffffffff,
CollidesWith = 1u << 3 | 1u << 5, // collide with terrain and world bounds
GroupIndex = 0
};
var pointDistanceInput = new PointDistanceInput
{
Position = localToWorlds[i].Position,
MaxDistance = 20f,
Filter = Filter
};
// this should get the closest hit
if (world.CalculateDistance(pointDistanceInput, out closestHit))
{
//...
}
I cant seem to get my collision filter to collide with a layer 3 physics shape. It can get a distance hit with a simple cube just fine, but a complex mesh it never seems to trigger.
the "Belongs To" is mixed because I put it on both layer 3 and 5 out of frustration but didnt work
both the mesh object and the simple cube physics shape object have convert to entity with inject
I figured out the problem but not sure why. If you do calculate distance from within a mesh collider box, other colliders dont seem to register until you are out of the bounds of that collider
I want my objects to stay within the box but also avoid other things that are also in the box.
not sure if related but from memory there is 1 big difference between unity regular physics (physx) and unity.physics and that is how collisions or at least raycasts work if you're within a collider
1 of them raycasts hit the other doesn't
thanks to your tips, guys, I am having a good progress
this is entityIdColor screenshot
certain problem tho is that it's not precise for some reason
entities are indeed rendered correctly, but left entity won't be calculated correctly
Oh that's looking promising
If you're lookup is wrong from memory one issue is linear vs gamma
Hmm
and also it gets ruined if I move my camera
I do recalculate camera matrix and etc
on each snapshot
hhhhmmm
I think I got the reason
I mixed colour bytes
and I can see jpeg like distortion
wait a secon
lol
this is so funny
I think I am reading pixel upside down
๐คก
Of yeah that's a common issue
Yeah usually just flip the y
Where'd you end up injecting this?
I pretty much copied that tool that other guy sent
But yeah it's a great technique
overall looks like this
It's also nice how accurate the picking is vs colliders
I guess the only problem
it doesn't render sprites
since they don't have RenderMesh component
Can add them in a separate loop though?
Probably
Nice ๐
Can you test if an entity has an IBufferElementData attached?
I'm able to use them, but if I try and access it form an entity that does not have one attached, it errors out: ArgumentException: A component with type:TriggerIgnoreBufferElement [Buffer] has not been added to the entity.
My code: DynamicBuffer<TriggerIgnoreBufferElement> beA = World.DefaultGameObjectInjectionWorld.EntityManager.GetBufferfrome <TriggerIgnoreBufferElement>(entityA);
you can use has component
oh thanks tert
you rool
Worked like a charm, now I can use arrays properly with some semblance of a solid architecture.
What am I looking at, default HashMap vs your lookup implemenatation?
yeah pretty much
just interesting that single thread is faster than multi thread
for normal hash map
dat interlocked stall. same problem with nativeList
too many threads and interlock destroys me
that said, i'm still using interlocked for my implementation
do you convert the keys/values from the hashmap to a list and reserve?
[NoAlias] this NativeHashMap<TKey, TValue>.ParallelWriter hashMap,
[NoAlias] TKey* keys,
[NoAlias] TValue* values,
int length)
where TKey : unmanaged, IEquatable<TKey>
where TValue : unmanaged
{
var writer = hashMap.m_Writer;
var data = writer.m_Buffer;
var newLength = Interlocked.Add(ref data->allocatedIndexLength, length);
var oldLength = newLength - length;
var keyPtr = ((TKey*)data->keys) + oldLength;
var valuePtr = ((TValue*)data->values) + oldLength;
UnsafeUtility.MemCpy(keyPtr, keys, length * UnsafeUtility.SizeOf<TKey>());
UnsafeUtility.MemCpy(valuePtr, values, length * UnsafeUtility.SizeOf<TValue>());
var buckets = (int*)data->buckets;
var nextPtrs = ((int*)data->next) + oldLength;
for (var idx = 0; idx < length; idx++)
{
var hash = keys[idx].GetHashCode() & data->bucketCapacityMask;
var index = oldLength + idx;
var next = Interlocked.Exchange(ref UnsafeUtility.ArrayElementAsRef<int>(buckets, hash), index);
nextPtrs[idx] = next;
}
}```
i added an AddBatch method for ParallelWriter
which is pretty much what my above NativeLookup is using
mh, interesting. you can get rid of the memcpy with the method I suggested a few days ago
i don't want to get rid of the memcpy though
why not? ๐
because the memory i'm writing from is not safe to keep a reference to
because chunks can change while my jobs are running
i mean, it would be another extension method. this one is perfectly fine. what's the data type for the keys/values you use? temp allocated nativeList?
keys/values is a pointer to <entity,components> in chunks
i'm just direct copying entity data in
per chunk
ah I see, ok, now I got you why you are not doing it ๐
that's clever ๐
yeah, seems like the most convenient way and fastest way to index chunk data. pretty cool
Inspired me to turn his into a scene view entity picking option again
I used to have this a few years ago and I missed it so finally adding it back is good
I can now just select entities with most, such a nice simple concept
Can anyone remind me how to get component data so I can use it in ForEach loop?
You can use EntityManager.GetComponentData() before the foreach.
what's nice about it, is that it doesn't need physics, colliders or raycasts.
ive implemented this technique a few times since i first saw the medium post in 2017.
that particular repo does a DrawMesh per entity though so kind of falls apart at high counts
you always go one step beyond ๐
any idea to write better profileMarker code? I hate this
i always use Auto personally - having to do an end is horrid
but i never use that many markers
1 per method max
what i mean by this is use DrawMeshInstanced instead
Something like
{
var mesh = chunk.GetSharedComponentData(renderMeshType, this.EntityManager);
var entities = chunk.GetNativeArray(entityType);
var localToWorlds = chunk.GetNativeArray(localToWorldType);
this.matrices.Clear();
this.colors.Clear();
propertyBlock.Clear();
foreach (var entity in entities)
{
var color = IndexToColor(entity.Index);
map.Add(color, entity);
this.colors.Add(color);
}
propertyBlock.SetVectorArray(colorID, this.colors);
this.matrices.AddRange(localToWorlds.Reinterpret<Matrix4x4>());
var matrixArray = NoAllocHelpers.ExtractArrayFromListT(this.matrices);
cmd.DrawMeshInstanced(mesh.mesh, mesh.subMesh, mat, 0, matrixArray, this.matrices.Count, propertyBlock);
}```
yep, I'm using Auto now too. Much cleaner now.
I'm always amazed how much broad changes you can make in DOD. Like enabling multiple code paths for one feature just because the paths already exist. In OOP that was hardly doable.
so with dots everything has to be value type not reference type but what if you need a struct with an array of points like a polygon shape with vertices
since arrays are reference types how can i represent it in a struct
plus i need an array of each polygon so i need up with array of polygons which have array of vertices
so how can i setup the data like that using structs ๐ค
first of all, no, not everything has to be a value type. it can be pointer too. second, where do you want to store this data?
i need to keep a persistent list of all my polygons
but im doing jobs on all the data
so i cant use classes
You can keep that data in a NativeList/NativeArray in one of your systems then
i dont seem to have native list in my options only native array
is it in a separate package ?
it's all in Unity.Collections
Do you have this package installed? https://docs.unity3d.com/Packages/com.unity.collections@1.2/manual/collection-types.html
let me double check - should have since native array has worked fine
ah okay so native array is built in the rest is in a package
that explains it
if you don't have burst installed, also add that ๐
so its allowed to have native lists in a struct then
does that mean when you pass a native list (or array) in methods the whole collection is copied ?
so i need to use ref every time
while you can use ref, the only thing that is copied is the pointer, length and capacity + some safety checks
oh
the actual data is in unmanaged memory
native containers wrap a pointer so effectively behave like a class not a struct
unsafe containers don't do this though and act like a struct
i see. interesting new way to think about code design compared to my old oop ways
start with some easy burst examples and enjoy the speed ๐
got back from shops, did 1 more quick pass on this entity selection bursting the setup
@rustic rain if performance is something you need have a look at this - bursted setup + mesh instancing
you won't have access to like half the extensions though by default ๐คฃ
e.g. AddRangeNative, NoAllocHelpers.ExtractArrayFromListT, AddBatchUnsafe
wait it seems i cannot use my struct it says cannot use non nullable in native list ... is that because my struct has a native array in it ?
you can't store a native container inside another native container
you can store unsafe containers inside native containers just know by default burst will always compile this the 'slow' way (still fast)
oh jeez this is getting complicated quickly
also there are Fixed* containers where you don't have to worry about memory
FixedList64Bytes<> for example
which is really just a chunk of fixed memory that behaves like a list
why wont they allow a container of structs with containers =/
what's your code? I thought you just have a struct with a NativeList/Array inside it? that should be fine
public readonly struct Area
{
private readonly NativeArray<float2> vertices;
public readonly NativeArray<float2> Vertices => vertices;
public Area(in NativeArray<float2> vertices)
{
this.vertices = vertices;
}
}
private NativeList<Area> _areas = new NativeList<Area>(); // denied
ah, yeah that won't work
what would be the right way to setup my data for this ?
the quickest I could think of is with pointers and manual allocation/deallocation. another is to flatten the whole struct or use 3 flat arrays and get rid of the area struct alltogether
need to know what your actual problem is
my goal is to check if areas overlap another area
planning to use parallelfor job for it
some could have 1000+
yeah ok if so large/variable you probably need unsafe container or pointers
i.e. just change your NativeArray<float2> vertices to UnsafeList<float2>
just remember unsafelist behaviours like a struct and needs write back
what do you mean by write back
private NativeList<int> verticesLengths``` one way to flatten. you'd have a linear list of all the areas and their vertices and another array that has the length of each area
{
var nativeList = new NativeList<int>(0, Allocator.Temp);
var unsafeList = new UnsafeList<int>(0, Allocator.Temp);
Add(nativeList);
Add(unsafeList);
Debug.Log(nativeList.Length); // 1
Debug.Log(unsafeList.Length); // 0
}
private void Add(UnsafeList<int> list)
{
list.Add(1);
}
private void Add(NativeList<int> list)
{
list.Add(1);
}```
i was about to suggest this actually
i'd even consider vertices instead being 2 values, start + length
why does that give 0 ? ๐ค
{
var i = 0;
Add(i);
Debug.Log(i); // 0
}
public void Add(int i)
{
i += 1;
}
i might opt for that though if unsafelist works it does make the code slightly cleaner
for the same reason this is 0
so then how do you actually add to an unsafe list if .Add(1) doesn't actually add to its length
or return it in the method but ref is better
so just do list.Add(ref number)
oh so unsafe containers do not get passed like references like native containers do
aka they dont wrap a pointer to it
var list = lists[0];
list.Add(1);
lists[0] = list;```
just remember this as well
usually i wouldn't even bring up pointers/unsafe containers for someone newish to dots unless they had a solid c/c++ background
and i would seriously consider this solution instead if your polygons are reasonably stable once created/destroyed
got to learn it eventually ๐
not really
i'd say only 20% of our devs know anything about low level code at work
if you're into engine development then yes 100%
but if you're just a gameplay dev not really
well for unity sure but if you use c++ it would be nice to learn
obviously if you're solo and have to do everything then yeah it'll probably creep in at some point
as you don't have anyone else to come in to optimize it
i am indeed solo
-_-
var list = lists[0];
list.Add(1);
lists[0] = list;
why can't we do:
lists[0].Add(1);?
lists[0] doesn't return by ref
it's a local copy
you can add a ref return method
where T : struct
{
return ref UnsafeUtility.ArrayElementAsRef<T>(array.GetUnsafePtr(), index);
}```
ok so i need to think of it like a struct
then you could do
lists.ElementAt(0).Add(1)
i might add some extension methods
to make my life easier
would be nice if unity did that so noobs can use them without having to think about all this too ๐
i think unity's preference is users don't need to touch unsafe code
btw though they do have some of these
like dynamicbuffer has elementat method built in
just nativearray is missing it
true but even my case is a simple one that many people might need to do
with the other suggestion i could just opt for 1 array with [size][0]..[n][size][0]..[n] i guess
InvalidOperationException: The Unity.Entities.EntityCommandBuffer has been declared as [ReadOnly] in the job, but you are writing to it. How odd is that? I never had any issues with it and the command buffer isn't read only. Yet Unity is complaining all of a sudden. hm
are you passing it in a weird way
where its hidden from the scheduler so the safety system can't inject into it
i.e. passing it in via a pointer or something
indeed I was ๐ was located in a struct that I accidentally marked ReadOnly
I've made such drastic changes today. I hope not everything comes crashing down lol
if it works out I've streamlined the shit out of the spell system ๐
aw man, I've changed duration from ushort to float and now all my authoring data is gone. Yet I was pretty sure as long as the name stays the same the data in the monoBehaviour persists
you cant interpret ushort to float
if you had changed ushort to int
it would have kept
huh? why is the cast not possible? float has enough range?
lazy unity ... ๐ yeah, the serialized file is 1:1 with ushort or float. glad I had a backup
must be some oversight. there's no technical reason I can think of
some legacy UnityJS code ๐คฃ
that said, i just converted an int to a float field
and it works fine
data still there
yep, I did that pretty often over the years. either it's special for ushort or something else tripped up
was it a list/array of ushorts?
nope
Does anyone know if there is an extension or something to access the hit child collider of a compound collider in a collision query?
I'm just working off the advanced collider parade demo which has everything I need but I can't help but feel that this is obvious functionality that has some extension hiding somewhere.
I do this, let me check
if (collisionWorld.CastRay(raycastInput, out RaycastHit hit) &&
!(projectile.Owner == hit.Entity && elspsedTime - birth.Time < 0.1f) &&
!projectile.Destroyed)
{
projectile.Destroyed = true;
collisionWorld.Bodies[hit.RigidBodyIndex].Collider.Value.GetLeaf(hit.ColliderKey, out ChildCollider childCol);
Collider* childColPtr = childCol.Collider;
Collider projCol = *col.ColliderPtr;
If there is an obvious extension lying around let me know but otherwise... make an extension? ๐
I'm not aware of an easier way at the moment
Thanks @minor sapphire! I did stumble across your posts on the forums discussing this topic.
I'm implementing a destructible object system too.
are you by any chance generating voxels?
Do you also have crazy cool lights?!
No voxels or crazy cool lights for me.
I'm just using Rayfire to generate some high detail destructible walls.. its the one over the top ECS thing I want to do lol.
I've been spending a stupid amount of time trying to optimise the CompoundCollider.Create call
made my own version of it, removing as many allocations and memcpy as I can, doing the BoundingVolumeHierechy generation upfront so I can pre allocate the blob memory and write directly to that lol
im getting this error:
Allocator Unity.Collections.AllocatorManager+AllocatorHandle must not be None or Invalid
not sure why though
theres no way to set a allocator to unsafe list from what i can tell
oh wait
i found it
You still need to allocate and deallocate all unsafe containers
The difference is they are unsafe so they don't have safety to tell you
I'm actually doing something similar
if they persist for lifetime of the game do you still need to dispose when you exit the game or will that dispose auto ?
Yes you need to dispose
okay
i wonder if any one has released a nice wrapper around unsafe collections that handles some of the pains of dealing with them
Oh neat!
I'm just doing the fractures at authoring time using the Shatter script.
Would be neat to have the Unyielding feature though, I really liked how you could build something that was somewhat structurally sound.
That's literally the native collections
They wrap an unsafe collection
yeh but cant have them in a struct that goes in a native collection
I.e nativelist has a pointer to unsafelist
if thats all they are im surprised they wont allow collections that have structs containing collections
unless its on their roadmap to allow it some how
Btw even when they finish removing dispose handle they won't allow nested native containers
what's going on here? I have to complete the combined handles. otherwise unity complains about it, yet newHandle is a dependency for the job? anything obvious I'm missing here?
They will have static analysis to prevent it
i dont know what you mean by that
i know you cant have NativeList<NativeList<>> but NativeList<MyStruct> which has a NativeList i feel like that should be possible if i can do it with an unsafe list and Native Lists are just wrappers
You can't have them nested because dispose handle is a class
They are removing this
In theory this means they can be nested
However they will add a static analysis to prevent it
I.e make it a compile error
why would they prevent it - seems like a nice idea to allow it surely?
What's the actual error
Because it's super costly to scan pointers of pointers of pointers to inject the safety handle
You could have 1000 lists inside each other
is it not costly to use an unsafe list like im doing though ?
InvalidOperationException: The previously scheduled job UpdateCombatEffectsJob writes to the Unity.Collections.NativeList`1[NZSpellCasting.CreateBasicSpellDataComplex] UpdateCombatEffectsJob.JobData.casterCalulateSpellsList. You must call JobHandle.Complete() on the job UpdateCombatEffectsJob, before you can read from the Unity.Collections.NativeList`1[NZSpellCasting.CreateBasicSpellDataComplex] safely.
There's no safety in unsafe
oh so the safety is what made it slower
the system in question is handle3
I'd need to see the full source but what is caster calculate spells list
Is it a native list
yes
ah, good catch!
If this is the issue you probably just need deferred job
Hard from me to be certain standing in a crowded tram with limited source code =D
Back in a bit
excuses ๐
seems like there is no defer job for IJobParallelForBatch :/
eh, completing at this stage is okay. was just wondering why that happens. sometimes the job dependency system still trips me up completely ๐
Think it has batch option built in
It hasn't been update for new standards
Still used schedule for parallel
just index ๐ฆ
Everything will be ok T_T
Nope, better start refactor 71 enzi
that phrase should be slogan for all of DOTS ๐
it is a bit of a pain though ๐ just one that's worth it haha
Then can do the basics
I rather deal with pain than the Mono brick wall ๐
thanks for your help tertle! have a good night all o/
๐ฅฒ
i would like my game complete before then lol
nice joke
It's the same humour I use every day
Why release when there are still optimisations to be had!
lol so true
i think this is where im getting an error:
public void Add(in Vector2 vertex)
{
float2 v = new float2(vertex.x, vertex.y);
vertices.Add(v);
}
ObjectDisposedException: The UNKNOWN_OBJECT_TYPE has been deallocated, it is not allowed to access it Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckWriteAndBumpSecondaryVersion (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <823fb226a3f9439cb41fdcb61f9c86a1>:0)
but am not sure how to fix it
very hard to decipher the error's origin
vertices?
vertices is an unsafe list
check IsCreated
hmm strange maybe thats not the function causing it then
ok it might be when im adding to my native list:private NativeList<Polygon> _areas = new NativeList<Polygon>();
but that is also created
oh actually its not created ๐ค
so i can't declare a new native list as a class level field ?
can they only be created within functions
hm it works if i create the native list in a function but not if its declared as a class field
so...
I assume there is no graphic solutions in DOTS yet, so in order to draw some lines and etc, I need to use GameObjects?
i have my own draw library but cant share it atm unfortunately
but there's one in the store that's even better https://assetstore.unity.com/packages/tools/gui/aline-162772
highly recommend something like this (grab it on sale)
I've used that its pretty good, although it does bog down your framerate if you try and render over 100,000 cubes or so
yeah, sadly I'm not really in position to purchase anything
Is there any free drawing library?
I mean its not that hard to use gameobject stuff instead
Well, that would require quite some sacrifices
yeah I guess it depends on what you want to use it for, if its just for debug purposes then it shouldn't matter surely
Is there any way I can find the problem why my capsule doesn't render after I set up my new project? I'm using URP with Entities cause I found it will render nothing at all if I don't use URP or HDRP (According to the Unity forum).
Not sure if there is something wrong with my capsule or something, I recreated one and it's still not rendered. the chunk I checked is normal to me but I'm new to ECS so don't know is there something missing.
are you sure its not fallen through the floor or flying off somewhere
It stays in the position in the scene view when play mode is on.
And when I tried another cube I removed the collider, didn't add the RigidBody, so it will not fall I guess.
have you set it up exactly like in here https://docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.50/manual/creating-a-new-hybrid-renderer-project.html
Problem solved. I did what I miss in the guide, then created a material to solve the shader error, and the capsule rendered as I expected. Thx for the help!
How to do it correctly?
Basically, I need to access CompanionLink component of entity after it was added only once in order to add some other component.
Do I just create simple system where I target query which doesn't have yet the component I want to add?
I dont know your exact usecase but you should probably use managed IComponentData on the entity instead of modifying the companion if all you need is to use managed Data for the entity
If you really need to access the Companion you can as you suggested query it. but i dont think you can query self added components directly on the companion. keep track of which companions are already processed by adding a tag to their entity which you can then exclude in the query.
I use companion in order to avoid having another companion game object system
I simple just add my other game object as child
and do whatever I want with it through my own component with reference to GO component I need
LineRenderer in this case
it's all irrelevant though
All I need is to somehow add component to entity only once, and just asking whether there is intended way for it
since I need to add it only after CompanionLink component is added
i see. Just have a system that queries for CompanionLink and exclude the component with the reference to your own gameobject. Once your system did the processing and added your own "Companion" component it will never run again. You could use IsystemStateComponents for that to make cleanup easier
@robust scaffold how's the source generator coming along? i'm curious
bit of an issue with my data source files. I'm now overhauling the entire system
(basically I accidentally overwrote the data files, and now I have no clue how to get it back. So ive gotta figure out what I did a loooong time ago and get my data files remade)
Data files?
And literally get the files back from your version control if you've accidentally overwritten them
damn, your reminding me I'm need to sort out some kind of source/version control I've had something similar happen 
Too many files and copyrighted by another company. They aren't my data source files. I'm just... borrowing them for this hobby project.
And what kind of data source is it? Couldn't be code
Just text files and large pngs
the PNGs are the main problem. Big 16k map textures
How'd you break that with a source generator though?
I have the original file, I did some sort of remapping in order to change the coordinate system.
Nah, this was another thing I did. That I fucked up badly
Ahhh. Ok
Yea, this was my own stupidity without backing it up.
Version control system......
Yea... next time eh?
XD
I'm getting this error but don't know how to fix it:
_result is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing. Please use a more suitable container type.
I have it marked as write only because thats intentional:
private NativeList<int2> _result;```
in the execute function i have:
if (result[0])
{
var writer = _result.AsParallelWriter();
writer.AddNoResize(new int2(index, i));
}
i was told this is how you are meant to write to a native list in parallel jobs yet it wont work
Not really DOTS related but for some reason my active scenes aren't saved in the editor when I save and close. It always gives me a default scene when I load my project back up.
This isn't normal right?
It's not a big deal, my scenes are still saved, they just aren't active in the hierarchy and I have to reload them. Just seems wrong..
you can declare which one is default but yeh its not dots related at all
How do I do this for the editor? I have done this for my play mode scene.
#๐ปโunity-talk ask in the right place
just replied on forums but you can't schedule jobs from jobs
yeh i was just about to reply. wish the error would say that because the error is not helpful lol
isn't it also that all imported nativearrays will come up with that error ๐ค
yeah if its local to the onupdate
the error is useful actual
_result.AsParallelWriter();
whats wrong with that line?
i read on the forum that you had to use that to write to a list in parallel jobs
a single array into a parrallel job is liable to have problems
this is true
thats why i was confused i had to declare it read only
because i wanted to write to it
note that you can't increase capacity in parallel
you have to pre-allocate the capacity
not in parallel
i guess that makes sense
resizing requires reallocating to a new pointer
yeh i can imagine a race condition in that situation
ill have to keep that first job on the main thread and only do vertex overlap test on a job then
as each thread can get its own stream
how did you figure all this out - its tricky enough as it is with the current documentation details
personally I started this when there was literally almost no docs
I don't even know how I got anywhere with it
that would've frustrated me no end lol
pretty much haven't ready any documentation
mostly I learned from the few tutorials that existed and help from the forums and this discord
i have read probably the entire source code though
i would never have thought native stream existed to look for such a thing
yeah that's a bit beyond me 
they should hire you to write the docs you'd probably be good at explaining it all ๐
I do sometimes look through the scripting api as well
some of the stuff doesn't even have vague descriptions of what they do though
or even if they do, theres no how to use them so its a lot of trial and error
i would never had known about parallel writer if it wasnt for searching the forums for a particular error that some one else had already had
yeah there's probably(definitely) a lot I still don't know about dots
but there's no need to learn everything at once
but the more i think about it, my approach wouldn't work due to race conditions anyway
if you keep to the safety systems then there shouldn't be much of a problem
how come a nativestream can be resized. but a native list cannot even though lists are known to be resizeable.
in parallel context anyway
because each thread gets their own unique nativestream
oh so you get a collection of streams at the end
rather than all bundled into one collection like a list would be
yeah I'm not sure how it works to be honest, is it all collected into one single array at the end perhaps
nope
you can read it back in parallel
or you can merge it into a single stream/list if you want
ideally you don't need to do that though
ok that makes sense
btw NativeQueue.ParallelWriter can also resize in parallel
NativeQueue is really the only container I haven't used much. From my limited test it wasn't that great but now I'm reading the source, it doesn't look too bad. Do you have more experience with it?
it's /fine/
much faster than default nativelist for example
honestly it's a great first container for most people
solves a lot of thread issues etc
while performing well
i don't use it much anymore but it still has its uses for convenience
I can't remember what the issue was. Seems there's no parallel reader
Guess that was it, from source reading seems limited
it's a queue it's meant to be ordered
yeah, good point ๐
some weird inconsistencies with their collections the hash set Count is a method yet in list its a property
tell me more ๐
i have skin meshed renders in the world but dont show up in hierarchy
when you select them in scene view they select the enitty
(i.e. i added skinned mesh renderers into the entity picking stuff)
for normal workflow you can legit not tell they are gameobjects
it just feels pure
the whole setup is automatic
simply add a
hybrid component authoring script to an entity
They changed it to be a method some time ago to clearly indicate that it has to compute the count
with the gameobject/any components
they cant keep track when adding ?
and then my setup automatically adds component references i need
sounds great. anything to share? your comp certainly has the same logic as mine
what i mean
yeah i'll probably share this whole thing soon~
it's very simple actual
should have turned off gizmos before i recorded this ๐
This is what I'm doing for hybrid
oh i dont have anything like this
I've written this some time ago. Could be simplified I guess. I was never too sure how to handle subscenes/normal scenes and conversion vs. no conversion
i instantiate at runtime
{
var entity = this.GetPrimaryEntity(hybrid);
this.DstEntityManager.AddComponentData(entity, new HybridComponent { Prefab = hybrid.Prefab });
switch (hybrid.CopyMode)
{
case HybridComponentAuthoring.CopyModes.None:
break;
case HybridComponentAuthoring.CopyModes.CopyTransformToGameObject:
this.DstEntityManager.AddComponent<CopyTransformToGameObject>(entity);
break;
case HybridComponentAuthoring.CopyModes.CopyTransformFromGameObject:
this.DstEntityManager.AddComponent<CopyTransformFromGameObject>(entity);
break;
default:
throw new ArgumentOutOfRangeException();
}
});```
my entire authoring
all my authoring scripts exist in editor asmdef
to strictly disallow runtime authoring
does this run in Convert?
the code you posted. not a system, right?
oh
sorry
{
protected override void OnUpdate()
{
this.Entities.ForEach((HybridComponentAuthoring hybrid) =>
{
var entity = this.GetPrimaryEntity(hybrid);
this.DstEntityManager.AddComponentData(entity, new HybridComponent { Prefab = hybrid.Prefab });
switch (hybrid.CopyMode)
{
case HybridComponentAuthoring.CopyModes.None:
break;
case HybridComponentAuthoring.CopyModes.CopyTransformToGameObject:
this.DstEntityManager.AddComponent<CopyTransformToGameObject>(entity);
break;
case HybridComponentAuthoring.CopyModes.CopyTransformFromGameObject:
this.DstEntityManager.AddComponent<CopyTransformFromGameObject>(entity);
break;
default:
throw new ArgumentOutOfRangeException();
}
});
}
}```
it's just a GameObjectConversionSystem
originally i had a bunch of other logic
which is why it's a system
but i should probably move it to a IConvertGameObjectToEntity now that it's not required
ah, I see. I remember having some trouble with getting the correct entity index. either there was some bug or limitation but I had a weird way of working around it