#archived-dots
1 messages ยท Page 31 of 1
welp doesn't look like i can use ECS 1.0.0 with 2D right now
tilemaps and afew things are broken in 2022.2
even if i fix the package bug in 2d animations
@robust scaffold did you get tilemaps working for you in 1.0?
tilemaps just didn't work with 2022.2
so couldn't even test 1.0.0
gonna just stick with 0.51 for now
The normal unity tilemaps?
oh wow ECS uses a totally different position system
anyway to convert from world position to whatever LocalToWorld is?
ltw IS world position
not sure what that means guess i'll just go google unless you want to explain how to set position of an entity when i instantiate it
but i only have a vector3 unfortunately not sure how to convert that
Vector3 kek = new float3(0,0,0);
just like that
Hybrid tilemaps rendering worked with the assembly ref hack. Physics did not.
@deft pilot
would need physics as well unfortunately - thanks thou
i'm okay waiting for further support
Do I mean GetComponent and GetBuffer API is cached by default at 1.0?
SystemAPI.GetComponent, and SystemAPI.GetBuffer indeed is cached, all of systemapi is :3
What would be a way to make system start running with a certain types of components and conitnue running with another?
๐ Oh nice. Is there any performance difference if I'm not using using SystemAPI to GetComponent and GetBuffer at both ISystem and SystemBase?
you should just look at codegened system
under the hood it's all just as simple as storing queries/component type handles in fields
Sometimes Rider can't view the codegen properly. Any setting to fix it?
since GetSingleton always expects an entity to exist with the query you are going for
is there something that is similar to SingleOrDefault
or do i have to do something like
var entities = this.newEnemyPathQuery.ToEntityArray(Allocator.Temp);
if (entities.Length == 0)
{
return;
}
or should i just Entities Foreach this?
cause i'm not sure if you can nest that
Entities.Foreach((in Component1 c1) =>
{
Entities.Foreach((in Component2 c2) =>
{
}
}```
You can use HasSingleton or TryGetSingleton
Also Entities.ForEach doesn't support nesting, and will be deprecated in the future.
Yes, it's been replaced with jobs and the query API
are you allowed to TryGetSingleton<DynamicBuffer<T>>()?
cause the standard one has a fit when you try to do that
Plz, SystemAPI for GetComponentHandle<>().
Why not just fetch it from the state? But ideally it would be in the api. I guess it could be a pain porting the old this.GetComponentHandle from SystemBase
Unity now throws a warning for handle creation inside OnUpdate()
There's a difference between the old this.GetComponentHandle and a potential SystemAPI version in that, the sysapi version would also cache and .update for you
Yeah, so just call Update on them?
Yea. That would be glorious
Yep. Except now you need to write the whole process for every handle manually. Pain.
Ah, you want to use SystemAPI.GetComponentHandle in the update method and have it codegen for you to call update there
Yep
Yep, I agree, that would be cool ๐
so i am following this tutorial https://www.youtube.com/watch?v=1bO1FdEThnU&t=389s ,and i am wondering,is it possible to make it so that the origin of the grid is changeable?,i currently want to generate a small grid around my player which he can walk around,any idea how?
โ
Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=1bO1FdEThnU
Let's implement Pathfinding in Unity DOTS, we're going to write everything in a Data Oriented way (Structs) in order to benefit from massive performance!
Here's the follow up video covering Pathfinding in Unity ECS
https://www.youtube.com/watch?v=ubUPVu...
i can also send the finished script i made if anybody needs it
Are ICleanupSharedComponentData broken somehow? It seems they can't be added by a Baker
the normal ISharedComponent appears in the subscene, but an ICleanupSharedComponentData does not
Using 2022.2.0, Entities 1.0. I noticed that during play mode, if I move ECS objects in the scene view, when I exit play mode, their transform state persists. Is there a flag for disabling this feature? Or is this a bug?
Cleanup components can not be added during baking. Only runtime
New feature. It's something to do with the yellow dot circle thing
I feel like that should throw some kind of error
Yeah, which I like that dot thing. It's awesome. But I tried moving it while putting the dot in authoring, mixed, and runtime mode. Result is the same.
You'd think. Except systemstate was the same situation and yet, no error.
Although I tried it with the dot in the Inspector. I didn't see one in the Scene window.
No clue but it's a new setting with dots 1.0. It was mentioned in the DOTS Workflow Preview presentation and it was some sort of setting.
๐ค hmm. alright I'll dig around.
they never were able to get past conversion in subscene
state components were also removed during conversion
That doesn't mean that can't throw an error
A simple check for the correct interface would suffice
why should they?
Because it's not clear?
I can do AddComponent with a cleanup component and it won't appear in the subscene
I still think Baker should support cleanup component.
Yes, I want them on the runtime object once the scene is loaded
Yes, and I'd like to skip that step with baking
think of them as a flag that smth needs to be disposed, nothing else
then just use normal component?
I need it to force the destroyed entity into a specific chunk to read shared data
If I understand correctly, it's just like regular component that will need to move to another new chunk when adding cleanup component which is slow
cleanup components are meant for their name
to clean things up
They can just as well store data
But that explains why netcode stores all the ghost type data twice since they can't bake the cleanup component
And the data will be missing once the entity is destroyed
That's what baking would be useful for
And purposely need to write a system just to add cleanup component also really annoying
^
Any help?
๐ Why I need to do tat if I can bake it?
think you guys using it for a wrong purpose ๐
The purpose is up to the developer
And like I mentioned, sometimes it forces you to store data twice, which is just bad
You'd need to replace the baked component with a cleanup component at runtime, which seems like an even worse workaround
Look, we probably can but this is something ya need to learn yourself. Or wait until DOTS is out of experimental and with a lot of tutorials to learn with.
It is pain.
Yep
๐ Not really. If I'm not wrong, when u destory entity, the entity will only left cleanup component for u to do final cleanup. But it doesn't stop me to add cleanup component at Baker.
Just put a flag on AddComponent in the baker if you want to keep the component or not
well, that does stop you cause they are only runtime
๐
well the thing is,if i was using a custom grid made system,i would have probably had it done,but the thing is this is made a with NativeArray so i have no idea how to make a custom origin point for a native array
I use cleanup comp to store pointer to allocated instance of sound event in FMOD engine
so when Entity gets removed, system also disposes that sound event
Yes, that's what they are for
But sometimes you require some data that was baked to cleanup the entity
then you probably should create a destruction pipeline
Well yes, but that's more work than just being able to bake the component
For me I just want to avoid entity to keep moving to new chunk at runtime since currently u have been forced to add cleanup component at runtime only
In 2022, did they remove Prefab editor context modes?
if it's just a tag
you can simply add component to whole query
which will from what I believe - change archetype to all existing chunks
You'd usually need some information to identify whatever you want to clean up though...
but don't quote me on that
just the fact that you need to dispose of smth that is not even created yet says you are doing smth wrong ๐
I can't use tat. I need to put unique cleanup component data to each entity.
Why? I want the instantiated entity from a prefab to just have a component to cleanup. The prefab doesn't do anything at runtime
well you can still do that
Adding it manually at runtime is just an unneeded extra step that requires boilerplate
You could do that in 0.17. The point is that we are requesting / asking why certain things aren't yet possible
Also I hate the fact that you sometimes need to double store data (or remove the originally baked component at runtime after instantiating the prefab entity)
well can you give me a hint or something?
If you're having issues with computing relative index of neighboring nodes, the CalculateIndex would instead return (x - originX) + (y - originY) * gridWidth
oof
anyone tweaked around graphics?
looks like RenderMesh is legacy
meanwhile everything is RenderMeshArray
- settings with indices
I'm guessing
RenderMesh is gone for good?
๐ค
Also looking for the RenderMesh replacement
I see :0
hmm
Have NativeContainer inside NativeContainer restriction has been lifted since they are unmanaged now?
I don't think so, there was something about that in the docs
You still need to use an UnsafeContainer wrapping the NativeContainer iirc
๐ค
While you should generally prefer using the Native- collections over their Unsafe- equivalents, Native- collections cannot contain other Native- collections (owing to the implementation of their safety checks). So if, say, you want a list of lists, you can have a NativeList<UnsafeList<T>> or an UnsafeList<UnsafeList<T>>, but you cannot have a NativeList<NativeList<T>>.
but safety checks were made unmanaged now
This is from the newest documentation, 2.1.0
with which thing GenerateAuthoringComponent was replaced in 1.0.0
Try it out and see I guess ๐คท
Nothing, you need to do it manually
Huh, this works:
Or wait until they add a replacement
any example? its that bakery thing
Yes, it's the bakery
huh
it worked
no errors
var kek = new NativeArray<NativeArray<int>>(5, Allocator.Temp);
for (int i = 0; i < kek.Length; i++)
{
kek[i] = new NativeArray<int>(5, Allocator.Temp);
}
I think you replied to the wrong message ๐
I'm just going off the docs mind you, I haven't tried it
NA is special. Try NL<NL<>>
Yes, NativeArray isn't even part of collections
var kek = new NativeArray<NativeArray<int>>(5, Allocator.Temp);
for (int i = 0; i < kek.Length; i++)
{
kek[i] = new NativeArray<int>(5, Allocator.Temp);
for (int j = 0; j < kek[i].Length; j++)
{
var lul = kek[i];
lul[j] = 5;
}
}
for sake of more testing tried this
looks like
all guchi now
var test = new NativeList<NativeList<int>>(WorldUpdateAllocator); Huh, no errors
yeah
Maybe the docs haven't been updated
probably
The netcode documentation is wrong like 50% of the time
I mean you could do all that with unsafe collections before, but I guess knowing unity will let you know if you forget to get rid of it is nice
I never had any issues with it ๐คท just replacing the unsafe stuff with the normal collections now is nice though
with Entities 1.0 - I'm taking a look at the ECBSingletons and i'm curious as to how the ECBSingleton tracks the dependencies for write operations. With EntityCommandBufferSystem - the AddJobHandleForProducer still exists and the ECBSingleton is just an Entity with a component pointing to the pendingBuffers.
Am I missing something with dependency tracking with ECBs in ISystem? ๐ค
wdym?
you are acessing singletons only on main thread
so that's pretty much the only time you create ECB
sure but i imagine you want to wait for other threads to finish adding the cmds the CommandBuffer before the EntityCommandBufferSystem performs its playback
Don't you add job handle?
with ecbsingletons - i dont see where you could
๐ค
public unsafe struct Singleton : IComponentData, IECBSingleton
{
internal UnsafeList<EntityCommandBuffer>* pendingBuffers;
internal Allocator allocator;
public EntityCommandBuffer CreateCommandBuffer(WorldUnmanaged world)
{
return EntityCommandBufferSystem.CreateCommandBuffer(ref *pendingBuffers, allocator, world);
}
public void SetPendingBufferList(ref UnsafeList<EntityCommandBuffer> buffers)
{
pendingBuffers = (UnsafeList<EntityCommandBuffer>*)UnsafeUtility.AddressOf(ref buffers);
}
public void SetAllocator(Allocator allocatorIn)
{
allocator = allocatorIn;
}
}```
does ECB itself contain dependency?
havent seen it
The ECB system has a write handle on the singleton, meaning it forces all reading systems to complete their dependency
You don't need AddJobHandleForProducer anymore
oh - where do they store this write handle? Or is this implicit via registering the singleton?
hold up
meaning when you get ECB singleton query
it actually forces all systems with that query cached to be complete?
No, since all of your systems should only have a read permission on it
oh right - that makes a lot of sense now - cool thnx
I assume it does force the ECB system to complete though, if it hasn't already
(this is just me guesstimating btw, I haven't looked into it extensively)
ah lol - no worries
im trying to create a different kind of command buffer
but i also want it to be isystem friendly
You can use the normal ones in an ISystem
oh by different - it's separate from actual entities
it's for my audio system internally
I'd take a look at how they manage the buffers internally
I think each ECB just stores a pointer to the data, and the ECB system has an unsafe list of all of those structs holding the pointers
the Singleton.CreateCommandBuffer method just registers the buffer to the system
Yea my previous with 0.51 is done similarly
so I think I can likely just create my own component and alias a pointer to the component
What does the audio system do out of curiosity? You write to the buffer to create audio effects?
yea pretty much - if you want to do some audio processing you just write a bitflag
i just do the playback in c++
so i process all the bitflags and then load them through miniaudio
4 hours of work and I finally kinda recreated CGOs.
too complicated for me ๐ but sounds interesting
lol - eventually i'll release it, but not anytime soon - i haven't really tested it in production yet ๐
any ideas how i can get a ptr from this? ref readonly var refComp = ref lookup.GetRefRO(fixedEntity).ValueRO; due to the ref readonly no UnsafeUtility method works
just ptr casting also doesn't work :/
I guess AddressOf is causing a potential write with ref readonly var
What are you trying to do with it?
it's a byte array that has different data types sequentially, so i need the byte ptr and lots of casting ๐
i see that would work ```ref readonly var refComp = ref lookup.GetRefRO(fixedEntity).ValueRO;
fixed (byte* ptr2 = &refComp)
{
}``` i just hate fixed -.-
and i'm trying if i can ditch my UnsafeCDFE in favor of ComponentLookup
but with the special handholding. i guess not ๐คท
int i = 0;
ref readonly int t = ref i;
fixed(int* ptr = &t) {
}
This looks kind of cursed (oh just saw you posted the same thing up there ๐ )
it does ๐
Yea, the fixed looks like the only option.
{
readonly unsafe byte* _Data;
#if ENABLE_UNITY_COLLECTIONS_CHECKS
readonly AtomicSafetyHandle _Safety;
#endif``` why is _Data not internal?
because people like us are touching parts of Entities that unity doesnt want touched
i can touch it regardless. the only question is, do they make it difficult or not ๐
Exposed copies are pain to make though
yeah but worth it. i'd hate to have all those dumb fixed statements around my code
They're not that bad...
i'm working in unmanaged code. fixing is only for the c# compiler
try UnsafeUtilityExtensions.AddressOf()
i don't like the fixed context being necessary. just take this for example ```byte* stats = null;
if (spellData.Effect_Main.Value.snapShotStats)
stats = statsAccessor[i].Value;
else
{
ref readonly var tmp = ref StatBuffer_Final_Lookup.GetRefRO(spellOwner.source).ValueRO;
stats = tmp.Value;
}```
Is the readonly required?
if it was handled like we can handle using statements i'd be okay
yeah, ref doesn't work and otherwise it gets copied
Oh, eww
if i use GetRefRW i make a version bump. can't do that either
unity hasn't thought this through. very plain and simple
If you use GetRefRW(false), it doesnt look like it'll bump version
Yea, it's odd.
I have no clue why there's a RO version of RW while there's also a RefRO.
haha, noice! ๐ then i just use GetRefRW with readOnly ... that's some really shitty code
no, fk that
Maybe RefRO returns copies whereas RefRW returns pointer and the RO version of RefRW doesnt bump version.
thanks though, i have a solution.
@viral sonnet just do: UnsafeUtilityExtensions.AddressOf(in refComp)
It is a special "overload" that does not take ref, but in instead
sorry that doesn't work
I guess "ref readonly" is sort of same as "in" but it would be confusing to have an "in" variable as output
Is the pointer valid?
i'll test now. also need to see what burst does with it
probably why they went with ref readonly
i don't understand the address access much but it turned into a fine pointer
does this get some special treatment? i never found the answer why we can't write the same thing in code internal static class ILSupport { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe void* AddressOf<T>(in T thing) where T : struct => (void*) ref thing;
It's not valid c#
Out of interest if you tab back into unity for it compile?
i.e. It compile fine just your ide didn't like it
unity reports the same error
Ok that's interesting to me
there's no safety with a ref anymore. i can say readOnly and still modify it ^^
but that's also not unitys job imo
i would also be okay with some unsafe/advanced methods behind a compiler directive. sometimes they used it.
when it comes to ptrs and reference values, safety gets muddy
That's what is so great about these ref readonly
true, makes for good explicit code
i have my doubts though with this line ๐ var ptr = (byte*) UnsafeUtilityExtensions.AddressOf(in lookup.GetRefRO(fixedEntity).ValueRO);
just return a void* ... jeeeesus ๐
i can get a pointer from any entities data i can think of. yet here we are with ComponentLookups
Does it make more sense to stick singleton entities from baking all on one entity or to split them up?
most of my settings files are all on 1 entity, realistically though unless you have crazy amounts it won't really matter - 16KB per unique archetype
What's the difference between TranslateWorld and TranslateLocal?
new translation system in entities?
haven't used it yet but I assume it's just local vs world space
so i would think transform.localposition vs transform.position
I see. Translating the localPosition would just move, say, the child GO of a parent GO, while translating the worldPosition would move the child AND parent GO? Is this reasonable behavior?
no, i assume both would only move the child (again haven't looked at method)
say you have an entity with position 10,0,0
and a child with a LocalPosition of 1,0,0, it's world position is 11,0,0
if you set local position to 2,0,0, it's world position is now 12,0,0
if you set its world position to 2,0,0, it's local position will now be -8,0,0
Why can't I read and write from something on a component lookup if I use Schedule for an IJE?
It tells me it's declared as write only
InvalidOperationException: The Unity.Collections.NativeParallelHashMap`2[Unity.Mathematics.int2,System.Int32] has been declared as [WriteOnly] in the job, but you are reading from it.
that usually means you've embedded it within another container
It's inside a component
oh yeah that's another container (with the container being the whole chunk)
safety doesn't work like that
So I guess I need to make it unsafe then
Gotcha, you set one of local/world, the other one gets adjusted to compensate
Can I selectively ignore the safety restriction for just this job?
e.g. [NativeDisableParallelForRestriction]
you can disable safety on the entire job - but that's about it
Nope, I guess not
How do I do that?
Also this should be safe right? Since only a single thread will be writing to this component type if I don't use ScheduleParallel
no, because the inner container is not patched, because the job system doesn't know about the inner container. we know about it and we're exploring possible fixes
i disagree with doing it, but [BurstCompile(DisableSafety=true)]
something like that
it isn't safe because the main thread could also be writing to it
Yeah ideally I'd like to not turn off safety but I'm not sure how to go about it
i'd be interesting to see if you can find a fix for it
because it would imply you could also do nested containers then
unless it was something very specific to components with like typemanager metadata
I basically have a lot of entities that "belong" to a single entity, and this entity contains some collections that need to be written to by the entities it "contains". Previously I did this by iterating over the list of containing entities (there aren't that many), but I guessed it would be better this way due to the scheduling overhead
is this a singleton entity?
No, there could be 5 containing entities, with 50 entities per "container"
I still have no idea how big the scheduling overhead is so maybe the way I'm doing it atm is fine
The issue is also that I need to schedule them in a chain since otherwise the safety system will also tell me there are multiple writers. The entities in the container have a sharedcomponent that puts them on the same chunk, so that could be multithreaded
I'm guessing this is also only possible by disabling safety
e.g. if I have a shared component that contains an entity value that contains additional information, I'd need a component lookup, but that isn't "safe" in the eyes of the safety system
I guess it isn't safe in actuality either with schedule parallel
How big of an issue was it previously?
179/frame - Median 1.23ms, Mean 1.24ms, Min 1.02ms, Max 1.41ms
m_DependencyManager->AddDependency
171/frame - Median 0.20ms, Mean 0.24ms, Min 0.17ms, Max 0.48ms
JobHandle.ScheduleBatchedJobs
171/frame - Median 0.62ms, Mean 0.61ms, Min 0.47ms, Max 0.69ms```
were my results from work
dependency was a bigger problem for us
i believe both of these should be significantly improved in 2022 but as I have suggested against us upgrading at work i can't compare
I guess I'll just leave it like it is for now and optimize it if it becomes an issue
'Assets/Resources/SceneDependencyCache/6f5a7786b470eced84ed53b5a3e78fe1.sceneWithBuildSettings' (current owner)```
somehow managed to generate 2 subscene caches with same guid - that's a new one
What happens if you need to pass a jobhandle to an isystem? Save it on a component?
I don't like it either
I need to call multiple IJobParallelFor that depend on the contents of a native collections
They aren't fixed
or physics
There could be 5 or 10
EndSimulationCommandBufferSystem holds X number of commandbuffers
So lets say I have 5 entities with components on them that contains native collections
I iterate over those entities, and then want to schedule an IJPF based on their length
How do I get the length? Since I can't fetch the component anymore
so you need to sync point to schedule this job?
I need to call complete on a single jobhandle (the system writing the collections)
booo
don't do it
Then how do I schedule the jobs?
With job handle?
How does that answer the question
I don't get why you can't use jobhandle as dependency
What length am I passing to the IJPF
Schedule(List.Length)
how does jobhanlde help that
Hm
that said you use IJobParallelForDeferred
Yeah, but then I'd need to cache either the list or a pointer to the length field
And then I still kind of have inter system dependencies, which I don't want
to me everything you're doing seems wrong here
I don't mind changing it, but I don't know how
Why not do it in a single system in the first place
^ was my first thought
but without knowing why you're doing something it's hard to suggest an alternative
the singleton method that was suggested before would create a sync point. hardly a good solution
?
Basically I have "world" entities, that can be a place where an actor can be, e.g. a planet, or underground, or somewhere else.
In the case of a continent, a job collects all the chunks that any actor is near to, and then a second system runs on all collected chunks per world that have been added, and creates the objects on the chunks.
The actual world entity count is low, but since a lot of chunks could be created per frame, I use IJPF to distribute that across threads
oh unless you don't use GetSingletonRW in the update. well nvm me then ๐คฃ
In the case of a continent, a job collects all the chunks that any actor is near to, and then a second system runs on all collected chunks per world that have been added, and creates the objects on the chunks.
what's the reasoning for multiple systems when it seems like 1 responsibility?
Sounds like all should be single system
I thought about putting it in 1 system, but in theory some other systems may need to fetch the chunks that have been added this frame. For example, to generate a navmesh
I guess I could also put that in the same system, but then eventually that system will be huge
ok so that's fine keep them separate
but why can't you store all chunks on a single component?
How would that work around the dependency issue?
This is what the component looks like:
var list = SytemAPI.GetSingleton<YourComponent>().YourList;
there are more than 1 of these right?
Yes
private readonly UnsafeList<ActiveChunkTrackingCleanupComponent>* drawers;
basically just copy the SimulationCommandBufferSystemPattern
well hmm
I still don't understand how I then schedule my IJPFD
at what point do you know how many activechunktrackingcleanupcomponents there are
and what component determines the length of your ijpfd
AddedChunksThisFramePerWorld determines the length of the IJPFD per world entity
(also activechunktrackingcleanupcomponents is a mouthful)
So fi there are 5 worlds, 5 jobs needs to be scheduled based on their length
It very rarely changes, so I can check on the main thread as long as I don't have any jobs scheduled writing to this component
Sounds expensive
That's why I'd like to change it
i'm just wondering if it'd be populated before you get to it
but you can always simply do the 'maths' approach
if you don't want to rewrite huge chunks of it
Another alternative would be to make each created chunk an entity, but that would probably not be a good idea
just schedule an IJobFor with length of JobsUtility.JobWorkerCount
and pass all the data in
and each thread can work out itself what it should work on
I'd still need to cache the lists in that case though right? Since otherwise I'd need to call complete to get them
im confused why you need to call complete to get them?
My bad, I was still thinking about the scheduling part (for the IJPFD)
it's not ideal, but it works without redoing everything
I guess that could work
I'm still not happy with the way it works though. Ideally I'd like to just schedule a single job that handles all "worlds"
or just don't change anything
and just stick with SystemBase
and share them between systems
Can you not store a JobHandle in a component?
you probably could
It's just a struct after all
never heard it being done before though
I'll mess around a bit with it. I don't have a massive amount of entities so I don't really need to make this super optimized
Thanks for all the tips and help
I love when something works with burst off but doesn't with burst on ๐ฌ
hmm what's the issue?
i recently noticed if you turn burst during play mode after making a change it uses the old version before your change
I stopped and started again
and doesn't fix itself even leaving/restarting play mode
I don't think I've ever change the burst toggle during gameplay
Would clearing the burst folder fix that?
I mean I never toggle it while the game is running ๐
(and a new file change probably would as well)
i often enter game and realize oops burst is off
let's turn it back on because i'm lagging at 5fps
regarding this, this is the behavior with burst off:
This is basically the system I was describing earlier
The squares are the chunks, and the numbers in the chunk is how many entities are "activating" that chunk
If I turn burst on it breaks, without any error messages
the chunk positions are stored as int2
and then multiplied with chunksize (16) to get the world position
hmm not sure, the only thing i know that really changes is float precision
the other issue is just timing
you're doing something unsafe but mono is too slow to break
and turning burst on breaks it
I seem to have broken something when moving the collections to the component, the commit before that one works ๐คท
The [WithAll] etc components go on top of the struct right? I couldn't find any documentation about it
yes
What do I do if burst throws an exception, but turning burst off makes the exception not get thrown? ๐
attach a native debugger while burst is on
how did you determine this
it would imply you've done something quite unsafe
and are modifying entity world while scheduling
i.e. safety missing somewhere
System.NullReferenceException: Object reference not set to an instance of an object This Exception was thrown from a job compiled with Burst, which has limited exception support. 0x00007ffacea9dbe7 (7856fbb6b4dbffaaada80d2c18c6557) [IJobChunk.cs:367]
Maybe the exception is just wrong because it's bursted? ๐คท
I'm not doing anything crazy
This job broke it, seems pretty simple:
not even burst compiled?
Nope, I keep forgetting ๐
so how is it creating a burst compile issue
I have no idea. Maybe something broke somewhere
I already restarted unity, that didn't help
SystemBase
so how do you know it's this job
I just replaced the old entities foreach with a call to this job
The execute code is identical
I'll attach a debugger and see what's happening
how are you creating this job in your system
Is it normal that the generated file in the Temp folder doesn't match an exception?
The generated id is different
What do you mean?
you can break point in burst code in 2022+
Setting a breakpoint in an attached managed debugger (Rider/VS Unity Debugger...) on a method that is burst compiled, will switch off the burst code path for that method, allowing it to be debugged as normal.
i find it odd you are not permanently on debug
Yeah I swapped earlier
i'm still super torn how to handle menu in a multiplayer (netcode) game
i've been having it so a client always exists and the menu runs in that world
but it just seems a tad wrong to me
Why not use the default world?
because then i have to duplicate random number of systems
imagine i want my menu to play a mini simulation of the game in the background for example
Ah, for UI stuff?
but yeah also UI stuff
to do nice transitions between menu game
but also maybe i want to re-use options from menu in game as well
just use the same option panel
this is why i've been using client world
I think it's fine to run it in the client world then. Since all of the relevant systems won't do anything until you connect
and it works even better in 1.0
because it actually ticks properly
but it's just like, gut feeling says it's off
I'm just using the default world currently, but I also don't plan to do anything fancy there
Yeah, I originally used it for reconnects, since I wanted to completely reset the client world. Back then you couldn't migrate the network driver
Maybe I'll also switch to using the client world eventually
oh i still completely delete client world on disconnect
and creating it again basically just loads the menu by default
as that's the default state
only thing that exists outside of it then is basically a load screen to hide it quickly
I used the default world to store a component about the gameplay endpoint for the reconnect, which would then recreate the client and connect it
But it's probably overkill
hmm whats your use case of reconnecting after destroying client?
is it for a game with multiple servers?
and you move between them
I think I originally had it for loading or something, but I need to rewrite my save state system so I haven't used it in a long time
The client would disconnect, the server world would be destroyed, loaded from a save file, and the client would attempt to reconnect
I also used the default world for storing the data on which save file to recreate the server world with
Swapped to debug and unity crashed on run 
I switched to debug and now I don't get the exception anymore, even without changing any code 
fixed
maybe it was burst cache vodoo going on
I'm probably getting some new hardware soon, I really hope my iteration time goes down
they could rename isReadOnly from GetRefRW to bumpVersion.
(would it not be donotbumpversion or do you mean also invert it)
but i agree otherwise it's a bit confusing
it's a nice exposure point though
yeah, would be inverted then. it's a nice side effect of GetRefRW
and version bumping (or not) isn't exposed a lot
makes one think about it ๐
i have rolled my own UnsafeComponentLookup (again)
Woah. RenderMesh is now gone. Can someone give me some easy to understand info on how to control rendering of an entity? Say I want to disable rendering and enable rendering (instead of destroying/instantiating and entity)
but can you use SystemAPI?!
if not ๐ down with boilerplate
finally getting close to systems with nothing but jobs!
well, it's great if your only concern is less lines of code. this exists because _Data in RefRO/W is private. nothing i can do about it
i'm personally going through and removing huge amounts of my pointers
it's great
can finally have a library i'm not worried about other people breaking
how do you expect them in breaking it? it's not that internal library jobs and data are that exposed
it's not about public people
it's about colleagues
someone who has a task to fix a bug or implement a feature
someone who might not have intricate understanding of a system and what they can/can't do
i need to write code in a way that some intern in 5 years won't touch and break unexpectantly
are you aware that IJE codegen creates ptr access instead of chunk.GetNativeArray?
vaguely
i still only have 1 IJE
so i've barely touched it yet
i still have EFE to convert to it (they still work so haven't bothered with it yet while i work on other stuff)
i mean, it says a lot about how unity sees this all under the hood.
yeah but no dev is touching that
writing code for the lowest denominator is odd
it's not about lowest denominator
what makes you think an intern doesn't change a RefRO access to RefRW because he needs to modify it NOW?
you could give me your code base and i guarantee i'll miss something and cause a bug without knowing about it
because i don't have intricate knowledge of what's going on with all your timings, pointers and access
safety is extremely important, this above anything else is the most important feature of entities imo
and the 1 promise that to me is really important for studios
i get that, yet not everything can be coded in safe space. i feel like we are talking about 2 different things
it'd break because it was marked readonly
so he removes readonly ๐
then it'd break because it needs marked to be readonly
how can you make sure of that?
because not having readonly in parallel jobs on containers
triggers safety fail
and if it's not triggering safety
then it's safe
and it doesn't matter and was totally fine to do
and if you say he puts a [Disablesafety blah blah]
then it's going to trigger analysis and be highlighted in a review
if you don't want to setup the git actions for this, an easy way to do this is simply making
[NativeDisableContainerSafetyRestriction]
a compile error and require a justification for disabling the error
yep, that's all great. you have thought this through. i'm not sure why we are talking about it ๐
my original point was just
it makes me sad you'll have to Get, Store, Update over SystemAPI ๐ฆ
you should add a codegen extension to handle it automatically!
none of the methods i have can modify readOnly marked components
actually wait
can you implicit cast the Safe to Unsafe versions?
then it'd work fine
you just want a private field right
in essence yes, the ptr from RefRO/RW would help a lot
yeah, i guess i can make an unsafe version of them
but then they are really unsafe. unlike the UnsafeComponentLookup now
can't you just do something like
public implicit operator UnsafeComponentLookup<T>(ComponentLookup<T> lookup)
or does your memory layout not match
it does match
then yeah you should be able to do that! and then just use systemapi
there'd be no difference
that'd actually be sweet then
all the benefits you want, no drawback
yeah, that'd be cool. i'll try that. just need to find a way around to get some private fields for the implicit cast
or i try just casting ๐
yeah just memory remap!
at least it compiles public static implicit operator UnsafeComponentLookup<T>(ComponentLookup<T> lookup) { return UnsafeUtility.As<ComponentLookup<T>, UnsafeComponentLookup<T>>(ref lookup); }
yeah i think that should be fine
yeah nice idea. thanks!
as long as your memory layouts match
yep, all fine. also won't change
that's a really nice solution i must say
always good talking to you ๐
well outside the times i'm being combative ๐
i'm all about the workflow though!
i'm so excited by SystemAPI removing all this boilerplate (when handle version is added)
and even though i make it seem as i have knack for unsafe stuff, i really care about safety. there's nothing worse if things go wrong with it.
yeah SystemAPI was a really good idea
what i haven't quite figured out. systemA has a RO on a singleton. systemB has a RW and systemC has a RO again. is the dependency chain or sequence defined by the order the systems are updated?
otherwise, how would the job scheduler know that A has to run first, then wait for B and C has to wait for B
i believe system order matters
there are still cases you'd want to use GetSingletonEntity<T> and access it in a job
to avoid syncs
i'll have to test this at some point. i have an annoying dependency on a NativeList that gets shared around different systems with jobHandles. :/ pretty ugly, hope singletons can help me making this better and safer.
now i'm also missing SystemAPI.GetComponentTypeHandle
odd we get the ComponentLookup treatment first ๐
makes sense
since it's used for IJE which is being pushed
with IJE you need like no boilerplate anymore
query is handled for your, SystemAPI handles lookups
you lost GetComponent/HasComponent etc from EFE so kind of needed to replace that convivence
How come I can't access EntityManager from a static reference cache?
Throws me unsafe errors
why would you need that when there's access through World?
Just making things neat, but non static reference is alright
I usually initialize all manager refs in a static reference cache
Just wondering why this is not allowed
well, it's a struct. you are asking for trouble ๐
I see ๐
World.DefaultGameObjectInjectionWorld.EntityManager to get from anywhere. MB I guess, systems have EM anyway
being a struct is not really the reason but making a EM struct static is. caching a normal EM somewhere is fine.
also wouldn't play nice with domain reload disabled
Thanks for this, got everything working well :)
How to get list of systems that includes ones with [DisableAutoCreation]?
var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.All);
This skipped over them.
Found a solution, I just create an interface and loop through everything that implements it.
Is there docs on SystemAPI? And also touching the subject of Source Gen, say if I wrote an interface that will implement source gen code, is there a way to โtagโ it so source gen picks it up?
The source code - it's well documented
Ok thx Iโll read it over.
Not yet, but the general rule is SystemAPI is your high-level entry to the entities world. It can be thought of in four parts SystemAPI.Query which is our iteration solution. SystemAPI.QueryBuilder, which lets you easily write your query anywhere and it will be cached in OnCreate for you. SystemAPI.SomeSingletonFunction which will give you back what's essentially a cached query with .GetSingleWithoutSyncing. and lastly we have access function like SystemAPI.GetComponent, SetComponent, GetBuffer etc. which also cache their corresponding Lookups in OnCreate :3
Hmm very interesting. So instead of creating hooks to trigger these actions from within a system, I can do this from MB classes as well?
SystemAPI is currently only supported in Systems and partly EntitiesForEach (ironically)
Inside a System it will latch to the world that the corresponding system is within. That's the general rule and the reason it's called SystemAPI
Ah i see, hence source gen.
Indeed :3
Well, more wiggle room nonetheless
Any ETA to make SystemAPI able to use outside System? Mostly to use it at MonoBehavior.
No, not yet, tho we do ask, why you use MonoBehavoiur in the first place? Instead of doing .AddComponentObject on an entity and then working with all your monobehaviour intercom in systems :3
Coz we dun have dots UI solution so still need to use MonoBehavior
ahem
UI Toolkit
it's not dots
I try to use system to bridge UI but ends up really suck code ๐ฅฒ
but you don't have to use mono
UIToolkits, only dependency on Mono is the use of the canvas, but that can easiliy be put on an entity and accesed on systems! :3
The code is much clearer to just write it directly at MonoBehavior
UI toolkit let's have even cleaner solution
without monobehs
the only downside - UI won't be as clear, as uGui
UI toolkit debugger sucks
Which UI system are you using? 
The old one I can imagine why you would think it. But that's where a static singleton mb's come in:
class UIHandler : Monobehaviour {
public static UIHandler Instance => _inst;
static UIHandler _inst;
void Awake() => _inst = _inst == null ? this : _inst;
public Button MyStartBtn;
}
Then systems can easily access, use and add behavoiur like:
partial struct SomeSystem : ISystem, ISystemStartStop {
//...
public void OnStartRunning(ref SystemState state){
UIHandler.Instance.MyStartBtn.OnActivated += () => { Debug.Log("Button Pressed"); };
}
}
That's a rough sketch likely some of the names are wrong ๐
there's a bit of trouble with even that due to world's getting created before scene
OnStartRunning :3
that's the worst
if (field is null) field = value;
I hate it with all my heart xD
So I implemented special callbacks on scene load for world boot
Currently is using Unity UI. Plan to use ui toolkit runtime in future.
๐ Wow. I thought can't put managed thingy at ISystem?
not in a field
execution itself can be managedd
True but it's been the standard for ages, cause you might end in a scene with a new one, or something just loaded weird and you ended with two, so it should handle the case ๐
but you might want it only on OnCreate or OnStartRunning
Yup, managed code is completly fine (as long as you don't have managed fields and accept that managed code in your function means that function is now no longer a burst candidate)
Here's my solution to systems creation
private void SceneManagerOnSceneLoaded(Scene arg0, LoadSceneMode arg1)
{
SceneManager.sceneLoaded -= SceneManagerOnSceneLoaded;
_bootExtensionManager.SceneLoaded();
foreach (var system in _world.Systems)
{
try
{
if (system is ISceneLoaded post)
{
post.OnSceneLoaded();
}
}
catch (Exception e)
{
Debug.LogException(e);
}
}
}
i personally found this pretty gross ๐
At 0.51, when I use ISystem without putting [BurstCompile] tag I will just get crash at player runtime build. Not sure whether it's still the case at 1.0.0-exp.8?
it is, but what can you do
just make you world created after scene load if you need something in oncreate
I tried that
it sucked
hard
unless you're monobehaviours are referencing entity world
public class BetterWorldInit : ICustomBootstrap
{
private World _world;
private BootExtensionManager _bootExtensionManager;
public bool Initialize(string defaultWorldName)
{
SceneManager.sceneLoaded += SceneManagerOnSceneLoaded;
Debug.Log("Creating world");
_world = new World(defaultWorldName);
World.DefaultGameObjectInjectionWorld = _world;
_bootExtensionManager = new BootExtensionManager(_world);
var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);
_bootExtensionManager.Create();
DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(_world, systems);
foreach (var system in _world.Systems)
{
try
{
if (system is IPostCreate post)
{
post.OnPostCreate();
}
}
catch (Exception e)
{
Debug.LogException(e);
}
}
_bootExtensionManager.PostCreate();
#if !UNITY_DOTSRUNTIME
ScriptBehaviourUpdateOrder.AppendWorldToCurrentPlayerLoop(_world);
#endif
return true;
}
private void SceneManagerOnSceneLoaded(Scene arg0, LoadSceneMode arg1)
{
SceneManager.sceneLoaded -= SceneManagerOnSceneLoaded;
_bootExtensionManager.SceneLoaded();
foreach (var system in _world.Systems)
{
try
{
if (system is ISceneLoaded post)
{
post.OnSceneLoaded();
}
}
catch (Exception e)
{
Debug.LogException(e);
}
}
}
}
here's the full way it works now
in which case you are beyond hope ๐
Oh. You mean write managed function is still ok. Just don't put any managed component?
it did
but it wasn't exactly it
anyway's it works now, and I'm glad I can keep working
Managed Components are managed code, managed code is fine, so by the transitive property so is Managed Comps
Just don't expect to have Burst in managed functions, a function is managed when it contains any managed code.
ISystem itself can't be managed:
partial struct MySystem : ISystem {
string myField;
}
member functions can
(which I love you created a static analyzer for - so many times i accidently made it a class wasted time trying to figure out why it wouldn't work)
Haha, yyuppp... ๐
๐ I see. Just can't put any managed data directly into ISystem
But you should be using Singletons for that anyways :3
๐ง Then actually I can migrate all my SystemBase to ISystem to get better performance even can't BurstCompile still can get quite good performance than SystemBase?
yeah, they are lightweight
it's like comparing GameObject and Entity
kek
foreach (var (rma, mmiVARIABLE) in SystemAPI.Query<RenderMeshArray, RefRO<MaterialMeshInfo>>())
{
}
Is that correct way to query over shared comp?
I had the same issue, I have no idea. I instead just used and entityquery ๐คท
you know what hasn't had enough credit yet? unmanaged shared components
i used to have like duplicate components
Yeah I still kind of have one kind of duplicate component, but it has a use to force entities into the same chunk for some stuff
But if I can I plan to remove it
oh god
yes? ๐
oh is it? i had some huge issues in editor for a while
until i realized it was conflicting with unitys own solution so i removed it
i haven't tried at runtime though
I'm trying to figure how to bring back mesh chunk gathering
oh because rendermesh doesn't exist?
yeah
ah yeah that's a bit of a pain to redo
I'm still not sure how to deal with collections not being writable and readable inside a component from a lookup. I guess unsafe for now and see if unity can add the safety system for that in the future? ๐คท
wdym not being able?
components are effectively containers (chunk)
and safety doesn't work nested containers
ah
It's what I mentioned yesterday, the safety system will complain telling you that it's write only (I wasn't being entirely clear in the first message)
so you can't inject safety handles while scheduling a job so it always errors with this is write only
I think you can write to it but you can't also read from it
native containers on components only usable at system level
good for sharing between systems though
So I guess make them unsafe for now? It would be cool if that last bit could be added to the safety system, it sounds tricky though
and you can pass them in from the system
If it was just lists I would replace them with DBs, but I have some other stuff in there too
and it'll work fine, it just breaks if you access the component itself in the job
Yeah if it was a single one I'd do that, but I have a few of them. If the container is unsafe this is completely ignored right?
yeah there's no safety on them
And I'd still have dependencies at least from the read / write permissions on the component
yes
So just be careful when defining those
anyway to specify do something every second in a system?
like i could store the last delta total and action it when its over 1f
but thats prone to error
or should i just work off framerates?
ie/every 60/120 frames do x
well, that's how it works though
there's built in RateManager btw
FixedStep group uses it
i'll take a google of that thanks
is a buffer FIFO?
aka if i add 100 elements the first element is always going to be index 0 when i get the buffer assuming no changes
and 100th element is always gonna be 99th index
yes, it works like a list
alright making sure there isn't any weirdness under the hood
just realized a problem
with using tilemaps and ECS
since i have no way to call TileMap's methods
how am i suppose to get the world center of a tile?
i'm guessing the answer is something like
just store every tile in a buffer along with the position
I mean you could just calculate it, if you know the size of the grid and the size of each tile?
is there no HasBuffer() method I thought there was ๐
SystemAPI.HasBuffer ๐
is it possible to use Hybrid approach now? In some cases I have GO which doesn't destroy and then im control it from ECS. Also Im using AR module which stroing in shared component and manage it in system. So i did it through convertation. If i now move all AR monobehaviours from main secne to subscene will it break AR module? Will the monobehaviours logic work in Subscene?
There's lots of ways of using GameObjects not just with subscenes
I highly doubt the monobehaviours logic will work, its only the data that is converted, and its only the data that Unity knows about and or is explicitly created
Any ETA on being able to add an initially disabled component in a Baker?
Right now as we know, it's forced to be enabled by default
Actually, would a temporary workaround be implementing a BakingSystem that disables the desired components? This would require that BakingSystem only runs once for each component during conversion/baking
Why not disable the gameObject in the subscene? It adds a disable tag.
I only want to disable certain components
oh sorry I misread
youre good
@rotund token Have u get dots netcode working at hello world project? Seems like it's broken that until now I can't get a working player runtime build yet
there are a bunch of build problems currently. even without netcode. what error do you have? cant compile or crash?
I was just testing this and I don't think it is possible with bakers or baking systems. Setting the enabled bit in a baking system does not seem to carryover to runtime.
@viral sonnet I believe you mentioned that you were unable to set enable bits on prefabs using an ECB. I just tried it seems to work fine, despite what the docs say. ComponentLookup.SetComponentEnabled also works for disabling compoennts. And entities instantiated from the prefab have the same enabled bit as whatever prefab they came from.
But this is all at runtime. Couldn't get anything working in a baking system, just like you were saying.
No, tried a bunch of things and no luck so far.
but you can change a prefab enabled state and then the instantiated are also correct?
Yeah exactly
Luckily, all my objects that I was planning to use disabled components on are instantiated from prefabs, so I'm just going to disable the components on the prefabs in the first frame
As a workaround for now
ok, i'm gonna wait this out and just set the flag on in the instantiation
That's good to know. I'll just ignore component enabling/disabling until I really need it
Also, does Baking only work in Subscenes for now?
Yes
Are Subscenes the way to go from now on?
Yeah, they removed runtime conversion/baking so subscenes are the only way to bake entity data.
But there are some cases where you need to create entities from a mono behaviour for some hybrid setup. For that, you need instantiate the entity and add components manually. This is similar to how runtime conversion worked, but all manual. You can't just add the ConvertToEntity component to your game object any more.
Thanks!
Am I understanding this correctly? If I use SystemAPI.QueryBuilder within the OnUpdate scope in order to pass it into a job.Schedule(query, deps), the Source Gen will move that query builder to OnCreate and cache it there, so even by calling it every frame, I'm actually always receiving the cached version right? It's not building it from scratch each frame?
๐ค
you can quickly check source tbh
just compile it
and then take a look at source of codegen
pretty much
the description are pretty good for this
Calling this method should allow for construction of EntityQueries with almost no run-time performance overhead."```
yeah that's how I understood it from description, just wanted to make sure I understood it correctly cause that's an awesome feature.
that's basically SystemAPI in a nutshell
hmm
if it does caching under the hood
then you can save so much space
in files
pog
yes
the only thing systemapi is missing is Handle versions
and you can basically remove OnCreate from most systems
and if you already use IJE you already can
because the GetComponentLookup etc are all cached/auto updated for you
oh man
I wish to fix this stuped entity selection faster
so I can start reworking systems
I even consider moving rendering to single thread due to complexity of lookups
I mean
to non-instanced version
You guys have been so great and the tutorial that you gave me 5 days ago was a dream... this one... is there a good tutorial for DOTS 1.0 collision? (link that you gave me:https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/DOTS_Guide/ecs_tutorial/README.md )
downloading the actual physics samples
https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/PhysicsSamples
is probably the best
you can see on that page how many different samples they have
Do those still work in 1.0?
Thank you Turtle
Is it always better to use WorldUpdateAllocator rather than Allocation.Temp whenever possible?
they are kind of do different things
i think for the most part you should replace TempJob with WorldUpdateAllocator
WorldUpdateAllocator can be rewinded, right? but not Allocator.Temp?
temp is rewound every frame
kind of
it's a fixed pre-allocated chunk of memory per thread
so what is WorldUpdateAllocator then?
there are 2 WorldUpdateAllocator that swap every frame
but there is only 1 set of of them on main thread, none in worker threads
i.e. it cant be used in jobs
it's resizable but reclaims it's memory back if it hasn't been used recently
right
so doing a 1 off giant allocation won't bust it
because it will release it soon
so if you have a pretty consistent per frame memory usage for it, it won't actually need to allocate/deallocate much
it's rewound every 2nd frame (because there are 2 of them they alternate usages) allowing jobs to not be force synced end of frame and can flow through into next
sorry i shouldn't say every 2nd frame
i should say, every 2nd update
thats one of the big difference to tempjob which was tied to frame rate, every 4 frames
rewind allocator you use them yourself (for example ECBS have their own) rewind on demand
so you might have a very slow ticking once a second system that can allocate out memory to other systems
with its own rewind allocator
and you only rewind it every second or so, very useful
(though this is off topic and not specifically WorldUpdateAllocator but this is what it uses)
WorldUpdateAllocator rewind functionality is hidden for us then I suspect?
it's also moved from 0.51 where the rewinding happens
but you can see how it works
RewindableAllocator
in Unity.Collections
and if you want to add your own EntityCommandBufferSystem has a good example of using one
OK, thanks for sharing such useful knowledge, this should be pinned.
So as far as I can see, there is no benefit of using Allocator.TempJob, when we have WorldUpdateAllocator, correct?
i'm unsure of a reason to use it
but i don't want to blatantly say it should never be used
at the very least, unsafeutility.malloc does not seem to support custom allocators
Oh I see, we can access the actual allocator via the World, and rewind from there, if we want to do it manually.
Thought we just had access to the label for a sec
i don't think you should ever be rewinding the world allocator yourself
that is going to cause some serious issues
good chance a job is currently using memory from it
You think so? It looks like it keeps track of used/unused memory blocks. Still I probably won't do it since it automatically happens every 2nd update like you said.
nvm, I think you are right
I don't get, what's the use case for that world allocator?
Afaik it seems like better than Allocator.Temp/TempJob when allocating on main thread.
I know Temp can get full, but I don't think WorldUpdateAllocator can.
i'm guilty of not having switched to world allocator. I'm still using Allocator.Temp/Job mostly. Rewindable World allocator works like a double buffered memory. the memory isn't allocated from thin air but already allocated and swapped each update. at least, that's as far as I understood it
๐ค
so i see the usage, for memory that you need per frame which is pretty big. i don't have any idea what the limits are. like, can it reach 2gbs or something
line 266
huh, that warning only comes up in ISystems? [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS"), Conditional("UNITY_DOTS_DEBUG")] void CheckOnUpdate_Handle() { #if ENABLE_UNITY_COLLECTIONS_CHECKS || UNITY_DOTS_DEBUG if (Burst.CompilerServices.Hint.Unlikely((m_Flags & (kIsExecutingISystemOnUpdate | kDidWarnIsExecutingISystemOnUpdate)) == kIsExecutingISystemOnUpdate)) { Unity.Debug.LogWarning($"'{new FixedString512Bytes(m_DebugName)}' creates a type handle during OnUpdate. Please create the type handle in OnCreate instead and use type `_MyHandle.Update(ref systemState);` in OnUpdate to keep it up to date instead. This is significantly faster."); m_Flags |= kDidWarnIsExecutingISystemOnUpdate; } #endif }
it has no limit
it'll resize to whatever you want
it also has the beautiful benefit of not having to dispose it
so you don't need to schedule another job after your job to dispose your tempjob memory
so am i right in the assumption that if you allocate 100Mb per frame, with the rewindable memory it'll actually be double, 200Mb?
if you do it every frame
it wont have to allocate anything
after the first allocation it'll just re-use it
but yes it would cause 200MB of memory
ok
huh, this seems to mostly work for fixed allocations then. can a NativeList also be allocated with rewindable memory?
do you know how this will react when the memory grows? will it take rewindable memory also? i can't see this working out of the box honestly
but if it does, i would actually not need persistent lists for performance reasons
why not?
but the cap would start at the init cap. 0/1 or whatever
when the list grows during the frame it'll also resize several times (possibly)
i guess i'm mixing 2 things ๐
but still, the rewindable memory must be tracked and resized also then
pretty cool then
i'm mixing up a persistent native list that doesn't need to resize anymore.
public struct AllocatorHandle : IAllocator
{
internal ref TableEntry TableEntry => ref SharedStatics.TableEntry.Ref.Data.ElementAt(Index);
internal bool IsInstalled => ((SharedStatics.IsInstalled.Ref.Data.ElementAt(Index>>6) >> (Index&63)) & 1) != 0;```
this is what is passed now and stored in the container
and there's AllocatorManager
which does most of the lifting
i don't really see the benefit of replacing a persistent container though
as long as it doesn't have hugely spikes of memory
in which case rewind has the benefit of cleaning it up and not sticking around
Can a Baker remove components? I'd like to create a Baker that completely removes all Transform-related components in order to reduce chunk usage per entity
true dat. i'll evaluate those persistent lists, some Capacity can be calculated so that would make it possible for rewindable memory
no, only a bakingsystem that uses ECB
Gotcha. Guess I'll rely on StaticOptimizeEntity then
Oh wait, sure! I'll try that
if it's just transform there are solutions
GetEntity(authoring, TransformUsageFlags.ManualOverride);
Does that remove the components?
it doesn't even add them
i use this to get rid of them. works fine
or var additionalEntity = baker.CreateAdditionalEntity(TransformUsageFlags.None);
if you create child entities
the sticking around and process of resizing is bit annoying to handle. good benefit then
Thank you for the info. I should have specified though that I want the current entity that the Baker is processing to lose all of its Transform components
Kind of like this:
public sealed class Positionless : MonoBehaviour
{
}
public sealed class PositionlessBaker : Baker<Positionless>
{
public override void Bake(Positionless authoring)
{
}
}
if you want no transform components just do
GetEntity(authoring, TransformUsageFlags.ManualOverride);
as enzi said
Gotcha. Thanks!
GetEntityTypeHandle got the .Update treatment. nice ๐
now, should i rewrite all this or wait for SystemAPI? ๐
i'm really not in the mood to rewrite all this ๐คฃ
i made the mistake of redoing all this before i realized the power of systemapi
that said, really wasn't that time consuming
do you know how netcode handles tick? is it in a singleton?
oh damn ๐ server tick
clients can tick multiple partial frames
it's super simple for me. maybe i just need to use SharedStatic. I had a static uint in a SystemBase. Now ISystem and Burst doesn't like static of course.
in 1.0
NetcodeServerRateManager
they used to have custom system groups and stuff but got rid of them in 1.0
and switched to ratemanagers which they just add to the default SimulationSystemGroups etc
imo best approach - what they're designed for
NetcodeServerRateManager is a systemGroup, right?
no
