#archived-dots

1 messages ยท Page 31 of 1

deft pilot
#

@rotund token is there some conflict between the job system 0.70.0 and 2d animation package version 9.0.0?

deft pilot
#

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

rustic rain
deft pilot
#

tilemaps just didn't work with 2022.2

#

so couldn't even test 1.0.0

#

gonna just stick with 0.51 for now

misty wedge
deft pilot
#

oh wow ECS uses a totally different position system

#

anyway to convert from world position to whatever LocalToWorld is?

rustic rain
deft pilot
#

isn't it a float3?

#

or am i crazy

rustic rain
#

ltw is 4x4

#

which includes position, rotation and scale

deft pilot
#

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

rustic rain
#

just like that

deft pilot
#

yeah googled it already

#

thanks anyway

robust scaffold
rustic rain
#

@deft pilot

deft pilot
#

would need physics as well unfortunately - thanks thou

#

i'm okay waiting for further support

brave field
#

Do I mean GetComponent and GetBuffer API is cached by default at 1.0?

proud jackal
rustic rain
#

What would be a way to make system start running with a certain types of components and conitnue running with another?

brave field
rustic rain
#

under the hood it's all just as simple as storing queries/component type handles in fields

brave field
rustic rain
#

idk

#

I just look at it

#

by pressing ctrl and then clicking on class name

deft pilot
#

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) =>
  {
  }
}```
misty wedge
#

Also Entities.ForEach doesn't support nesting, and will be deprecated in the future.

deft pilot
#

yeah i didn't think it did

#

and i have read that its dead/dying in 1.0.0

misty wedge
#

Yes, it's been replaced with jobs and the query API

deft pilot
#

cause the standard one has a fit when you try to do that

misty wedge
#

I have a TryGetSingletonBuffer method

#

Not sure if that's in 0.51

deft pilot
#

nope

#

all good

robust scaffold
misty wedge
#

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

robust scaffold
proud jackal
#

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

misty wedge
robust scaffold
robust scaffold
misty wedge
#

Ah, you want to use SystemAPI.GetComponentHandle in the update method and have it codegen for you to call update there

robust scaffold
#

Yep

misty wedge
#

Yep, I agree, that would be cool ๐Ÿ‘

sage kestrel
#

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...

โ–ถ Play video
#

i can also send the finished script i made if anybody needs it

misty wedge
#

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

drowsy pagoda
#

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?

robust scaffold
robust scaffold
misty wedge
#

I feel like that should throw some kind of error

drowsy pagoda
#

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.

robust scaffold
drowsy pagoda
#

Although I tried it with the dot in the Inspector. I didn't see one in the Scene window.

robust scaffold
drowsy pagoda
#

๐Ÿค” hmm. alright I'll dig around.

rustic rain
#

state components were also removed during conversion

misty wedge
#

A simple check for the correct interface would suffice

rustic rain
#

why should they?

misty wedge
#

Because it's not clear?

rustic rain
#

but they literally use them too

#

for conversion

#

kek

misty wedge
#

I can do AddComponent with a cleanup component and it won't appear in the subscene

rustic rain
#

it is added to Entity though

#

it's just up to you how you will use it during bkaing

brave field
#

I still think Baker should support cleanup component.

misty wedge
#

^

#

Why doesn't it?

rustic rain
#

why should they?

#

they are meant for runtime only

misty wedge
#

Yes, I want them on the runtime object once the scene is loaded

rustic rain
#

then you need system which uses them

#

and adds them to entity

misty wedge
#

Yes, and I'd like to skip that step with baking

rustic rain
#

think of them as a flag that smth needs to be disposed, nothing else

rustic rain
misty wedge
#

I need it to force the destroyed entity into a specific chunk to read shared data

brave field
#

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

rustic rain
#

to clean things up

misty wedge
#

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

brave field
#

And purposely need to write a system just to add cleanup component also really annoying

misty wedge
#

^

brave field
#

๐Ÿ‘€ Why I need to do tat if I can bake it?

rustic rain
#

think you guys using it for a wrong purpose ๐Ÿ˜…

misty wedge
#

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

robust scaffold
# sage kestrel Any help?

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.

misty wedge
#

Yep

brave field
#

๐Ÿ‘€ 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.

misty wedge
#

Just put a flag on AddComponent in the baker if you want to keep the component or not

rustic rain
#

๐Ÿ˜…

sage kestrel
rustic rain
#

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

misty wedge
#

Yes, that's what they are for

#

But sometimes you require some data that was baked to cleanup the entity

rustic rain
#

then you probably should create a destruction pipeline

misty wedge
#

Well yes, but that's more work than just being able to bake the component

brave field
#

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

drowsy pagoda
#

In 2022, did they remove Prefab editor context modes?

rustic rain
#

you can simply add component to whole query

#

which will from what I believe - change archetype to all existing chunks

misty wedge
#

You'd usually need some information to identify whatever you want to clean up though...

rustic rain
#

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 ๐Ÿ˜…

brave field
#

I can't use tat. I need to put unique cleanup component data to each entity.

misty wedge
rustic rain
misty wedge
#

Adding it manually at runtime is just an unneeded extra step that requires boilerplate

rustic rain
#

just add component to query

#

and then query over all of them

#

to do your thing

misty wedge
#

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)

sage kestrel
robust scaffold
rustic rain
#

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?

#

๐Ÿค”

dense storm
#

Also looking for the RenderMesh replacement

rustic rain
#

RenderMeshArray

#

it's a bit more complex now

dense storm
#

I see :0

rustic rain
#

hmm

#

Have NativeContainer inside NativeContainer restriction has been lifted since they are unmanaged now?

misty wedge
#

I don't think so, there was something about that in the docs

#

You still need to use an UnsafeContainer wrapping the NativeContainer iirc

rustic rain
#

๐Ÿค”

misty wedge
rustic rain
misty wedge
#

This is from the newest documentation, 2.1.0

austere pebble
#

with which thing GenerateAuthoringComponent was replaced in 1.0.0

misty wedge
#

Try it out and see I guess ๐Ÿคท

misty wedge
robust scaffold
#

Huh, this works:

misty wedge
#

Or wait until they add a replacement

austere pebble
#

any example? its that bakery thing

misty wedge
#

Yes, it's the bakery

rustic rain
#

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);
            }
misty wedge
#

I think you replied to the wrong message ๐Ÿ˜…

#

I'm just going off the docs mind you, I haven't tried it

robust scaffold
misty wedge
#

Yes, NativeArray isn't even part of collections

rustic rain
#

kek

misty wedge
#

๐Ÿคท

#

Maybe the docs are wrong, or the safety system breaks in some unforseen way

rustic rain
#
            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

robust scaffold
#

var test = new NativeList<NativeList<int>>(WorldUpdateAllocator); Huh, no errors

rustic rain
#

yeah

misty wedge
#

Maybe the docs haven't been updated

rustic rain
#

probably

misty wedge
#

The netcode documentation is wrong like 50% of the time

rustic rain
#

oh boy oh boy

#

What crazy mind can think of that

misty wedge
#

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

rustic rain
#

unsafe sucked

#

so much pain handling ref

misty wedge
#

I never had any issues with it ๐Ÿคท just replacing the unsafe stuff with the normal collections now is nice though

coarse turtle
#

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? ๐Ÿค”

rustic rain
#

you are acessing singletons only on main thread

#

so that's pretty much the only time you create ECB

coarse turtle
rustic rain
#

Don't you add job handle?

coarse turtle
#

with ecbsingletons - i dont see where you could

rustic rain
#

๐Ÿค”

coarse turtle
#
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;
  }
}```
rustic rain
coarse turtle
#

havent seen it

misty wedge
#

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

coarse turtle
#

oh - where do they store this write handle? Or is this implicit via registering the singleton?

misty wedge
#

It's when you get the singleton with the required permissions

rustic rain
#

hold up

#

meaning when you get ECB singleton query

#

it actually forces all systems with that query cached to be complete?

misty wedge
#

No, since all of your systems should only have a read permission on it

coarse turtle
misty wedge
#

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)

coarse turtle
#

ah lol - no worries

#

im trying to create a different kind of command buffer

#

but i also want it to be isystem friendly

misty wedge
#

You can use the normal ones in an ISystem

coarse turtle
#

oh by different - it's separate from actual entities

#

it's for my audio system internally

misty wedge
#

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

coarse turtle
#

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

misty wedge
#

What does the audio system do out of curiosity? You write to the buffer to create audio effects?

coarse turtle
#

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

robust scaffold
#

4 hours of work and I finally kinda recreated CGOs.

misty wedge
coarse turtle
#

lol - eventually i'll release it, but not anytime soon - i haven't really tested it in production yet ๐Ÿ˜…

viral sonnet
#

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 :/

coarse turtle
#

I guess AddressOf is causing a potential write with ref readonly var

robust scaffold
viral sonnet
#

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 ๐Ÿคท

coarse turtle
viral sonnet
#

it does ๐Ÿ˜„

robust scaffold
viral sonnet
#
    {
        readonly unsafe byte* _Data;
#if ENABLE_UNITY_COLLECTIONS_CHECKS
        readonly AtomicSafetyHandle _Safety;
#endif``` why is _Data not internal?
robust scaffold
viral sonnet
#

i can touch it regardless. the only question is, do they make it difficult or not ๐Ÿ˜„

robust scaffold
#

Exposed copies are pain to make though

viral sonnet
#

yeah but worth it. i'd hate to have all those dumb fixed statements around my code

viral sonnet
#

i'm working in unmanaged code. fixing is only for the c# compiler

spice vale
viral sonnet
# robust scaffold They're not that bad...

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;
            }```
viral sonnet
#

if it was handled like we can handle using statements i'd be okay

#

yeah, ref doesn't work and otherwise it gets copied

robust scaffold
#

Oh, eww

viral sonnet
#

if i use GetRefRW i make a version bump. can't do that either

#

unity hasn't thought this through. very plain and simple

robust scaffold
viral sonnet
#

HOLY

#

i didn't even check! thought this was a given

robust scaffold
#

Yea, it's odd.

#

I have no clue why there's a RO version of RW while there's also a RefRO.

viral sonnet
#

haha, noice! ๐Ÿ˜„ then i just use GetRefRW with readOnly ... that's some really shitty code

#

no, fk that

robust scaffold
#

Maybe RefRO returns copies whereas RefRW returns pointer and the RO version of RefRW doesnt bump version.

viral sonnet
#

thanks though, i have a solution.

spice vale
#

@viral sonnet just do: UnsafeUtilityExtensions.AddressOf(in refComp)

#

It is a special "overload" that does not take ref, but in instead

viral sonnet
#

sorry that doesn't work

spice vale
#

UnsafeUtilityExtensions

#

not UnsafeUtility

viral sonnet
#

oh nice ๐Ÿ˜„ that's working

#

thanks man!

spice vale
#

I guess "ref readonly" is sort of same as "in" but it would be confusing to have an "in" variable as output

robust scaffold
#

Is the pointer valid?

viral sonnet
#

i'll test now. also need to see what burst does with it

spice vale
#

probably why they went with ref readonly

viral sonnet
#

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;

rotund token
#

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

viral sonnet
rotund token
viral sonnet
#

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

rotund token
#

That's what is so great about these ref readonly

viral sonnet
#

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

misty wedge
#

Does it make more sense to stick singleton entities from baking all on one entity or to split them up?

rotund token
#

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

gusty comet
#

What's the difference between TranslateWorld and TranslateLocal?

rotund token
#

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

gusty comet
#

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?

rotund token
#

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

misty wedge
#

Why can't I read and write from something on a component lookup if I use Schedule for an IJE?

rotund token
#

you can?

#

what issue are you having

misty wedge
#

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.

rotund token
#

that usually means you've embedded it within another container

misty wedge
#

It's inside a component

rotund token
#

oh yeah that's another container (with the container being the whole chunk)

#

safety doesn't work like that

misty wedge
#

So I guess I need to make it unsafe then

gusty comet
misty wedge
#

e.g. [NativeDisableParallelForRestriction]

rotund token
#

you can disable safety on the entire job - but that's about it

misty wedge
#

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

wraith hinge
#

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

rotund token
#

i disagree with doing it, but [BurstCompile(DisableSafety=true)]

#

something like that

wraith hinge
#

it isn't safe because the main thread could also be writing to it

misty wedge
#

Yeah ideally I'd like to not turn off safety but I'm not sure how to go about it

rotund token
#

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

misty wedge
#

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

rotund token
#

is this a singleton entity?

misty wedge
#

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

rotund token
#

less now!

#

wish I could benchmark work project on 2022 somehow to actually compare

misty wedge
#

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

misty wedge
rotund token
#
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

misty wedge
#

I guess I'll just leave it like it is for now and optimize it if it becomes an issue

rotund token
#
  'Assets/Resources/SceneDependencyCache/6f5a7786b470eced84ed53b5a3e78fe1.sceneWithBuildSettings' (current owner)```
#

somehow managed to generate 2 subscene caches with same guid - that's a new one

misty wedge
#

What happens if you need to pass a jobhandle to an isystem? Save it on a component?

rotund token
#

you sit back and ask yourself

#

why the hell are you doing this

misty wedge
#

I don't like it either

rotund token
#

so don't

#

there's pretty much no reason to do it now

misty wedge
#

I need to call multiple IJobParallelFor that depend on the contents of a native collections

rotund token
#

yeah pass the collections via singleton entities

#

like commandbuffersystems do

misty wedge
#

They aren't fixed

rotund token
#

or physics

misty wedge
#

There could be 5 or 10

rotund token
#

EndSimulationCommandBufferSystem holds X number of commandbuffers

misty wedge
#

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

rotund token
#

so you need to sync point to schedule this job?

misty wedge
#

I need to call complete on a single jobhandle (the system writing the collections)

rotund token
#

booo

misty wedge
#

I know right

#

I hate it

rotund token
#

don't do it

misty wedge
#

Then how do I schedule the jobs?

rustic rain
#

With job handle?

misty wedge
#

How does that answer the question

rustic rain
#

I don't get why you can't use jobhandle as dependency

misty wedge
#

What length am I passing to the IJPF

rotund token
#

Schedule(List.Length)

how does jobhanlde help that

rustic rain
#

Hm

rotund token
#

that said you use IJobParallelForDeferred

misty wedge
#

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

rotund token
#

to me everything you're doing seems wrong here

misty wedge
#

I don't mind changing it, but I don't know how

rustic rain
#

Why not do it in a single system in the first place

rotund token
#

^ was my first thought

#

but without knowing why you're doing something it's hard to suggest an alternative

viral sonnet
#

the singleton method that was suggested before would create a sync point. hardly a good solution

rotund token
#

?

misty wedge
#

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

viral sonnet
#

oh unless you don't use GetSingletonRW in the update. well nvm me then ๐Ÿคฃ

rotund token
#

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?

rustic rain
misty wedge
#

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

rotund token
#

ok so that's fine keep them separate

#

but why can't you store all chunks on a single component?

misty wedge
#

How would that work around the dependency issue?

#

This is what the component looks like:

rotund token
#

var list = SytemAPI.GetSingleton<YourComponent>().YourList;

misty wedge
rotund token
#

there are more than 1 of these right?

misty wedge
#

Yes

rotund token
#

private readonly UnsafeList<ActiveChunkTrackingCleanupComponent>* drawers;

#

basically just copy the SimulationCommandBufferSystemPattern

#

well hmm

misty wedge
#

I still don't understand how I then schedule my IJPFD

rotund token
#

at what point do you know how many activechunktrackingcleanupcomponents there are

#

and what component determines the length of your ijpfd

misty wedge
#

AddedChunksThisFramePerWorld determines the length of the IJPFD per world entity

rotund token
#

(also activechunktrackingcleanupcomponents is a mouthful)

misty wedge
#

So fi there are 5 worlds, 5 jobs needs to be scheduled based on their length

misty wedge
misty wedge
#

That's why I'd like to change it

rotund token
#

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

misty wedge
#

Another alternative would be to make each created chunk an entity, but that would probably not be a good idea

rotund token
#

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

misty wedge
#

I'd still need to cache the lists in that case though right? Since otherwise I'd need to call complete to get them

rotund token
#

im confused why you need to call complete to get them?

misty wedge
#

They're in a component

#

That is being written to

rotund token
#

yeah

#

just get the component within the job

misty wedge
#

My bad, I was still thinking about the scheduling part (for the IJPFD)

rotund token
#

it's not ideal, but it works without redoing everything

misty wedge
#

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"

rotund token
#

or just don't change anything

#

and just stick with SystemBase

#

and share them between systems

misty wedge
#

Can you not store a JobHandle in a component?

rotund token
#

you probably could

misty wedge
#

It's just a struct after all

rotund token
#

never heard it being done before though

misty wedge
#

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 ๐Ÿ˜ฌ

rotund token
#

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

misty wedge
#

I stopped and started again

rotund token
#

and doesn't fix itself even leaving/restarting play mode

misty wedge
#

I don't think I've ever change the burst toggle during gameplay

#

Would clearing the burst folder fix that?

rotund token
#

how do you never forget to turn burst on!

#

restarting unity fixes it

misty wedge
#

I mean I never toggle it while the game is running ๐Ÿ˜…

rotund token
#

(and a new file change probably would as well)

rotund token
#

let's turn it back on because i'm lagging at 5fps

misty wedge
#

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

rotund token
#

are you relying on floats or something

#

for precision

misty wedge
#

the chunk positions are stored as int2

#

and then multiplied with chunksize (16) to get the world position

rotund token
#

hmm not sure, the only thing i know that really changes is float precision

misty wedge
#

This is with burst on:

#

so time to revert commits ๐Ÿ˜…

rotund token
#

the other issue is just timing

#

you're doing something unsafe but mono is too slow to break

#

and turning burst on breaks it

misty wedge
#

I seem to have broken something when moving the collections to the component, the commit before that one works ๐Ÿคท

misty wedge
#

The [WithAll] etc components go on top of the struct right? I couldn't find any documentation about it

rotund token
#

yes

misty wedge
#

What do I do if burst throws an exception, but turning burst off makes the exception not get thrown? ๐Ÿ˜…

rotund token
#

attach a native debugger while burst is on

misty wedge
#

The exception is mysteriously thrown here

rotund token
#

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

misty wedge
#

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? ๐Ÿคท

misty wedge
#

This job broke it, seems pretty simple:

rotund token
#

not even burst compiled?

misty wedge
#

Nope, I keep forgetting ๐Ÿ˜…

rotund token
#

so how is it creating a burst compile issue

misty wedge
#

This is old Entities.ForEach code I'm converting

#

Which defaulted to burst

misty wedge
#

I already restarted unity, that didn't help

rotund token
#

are you scheduling this from a ISystem

#

that is bursted?

misty wedge
#

SystemBase

rotund token
#

so how do you know it's this job

misty wedge
#

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

rotund token
#

how are you creating this job in your system

misty wedge
#

Is it normal that the generated file in the Temp folder doesn't match an exception?

#

The generated id is different

rotund token
#

i'd clear your cache

#

and restart

#

also this is magic

misty wedge
#

What do you mean?

rotund token
#

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.

misty wedge
#

Oh that's nice

#

It just takes my computer 900 years to switch from release to debug

rotund token
#

i find it odd you are not permanently on debug

misty wedge
#

Yeah I swapped earlier

rotund token
#

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

misty wedge
#

Why not use the default world?

rotund token
#

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

misty wedge
#

Ah, for UI stuff?

rotund token
#

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

misty wedge
#

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

rotund token
#

and it works even better in 1.0

#

because it actually ticks properly

#

but it's just like, gut feeling says it's off

misty wedge
#

I'm just using the default world currently, but I also don't plan to do anything fancy there

rotund token
#

1.0 kind of got rid of default world in netcode

#

unless you create it yourself

misty wedge
#

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

rotund token
#

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

misty wedge
#

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

rotund token
#

hmm whats your use case of reconnecting after destroying client?

#

is it for a game with multiple servers?

#

and you move between them

misty wedge
#

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 ok_handbutflipped

#

I switched to debug and now I don't get the exception anymore, even without changing any code pensive

rotund token
#

fixed

misty wedge
#

maybe it was burst cache vodoo going on

#

I'm probably getting some new hardware soon, I really hope my iteration time goes down

viral sonnet
#

they could rename isReadOnly from GetRefRW to bumpVersion.

rotund token
#

(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

viral sonnet
#

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)

drowsy pagoda
#

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)

rotund token
#

if not ๐Ÿ™… down with boilerplate

#

finally getting close to systems with nothing but jobs!

viral sonnet
#

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

rotund token
#

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

viral sonnet
#

how do you expect them in breaking it? it's not that internal library jobs and data are that exposed

rotund token
#

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

viral sonnet
#

are you aware that IJE codegen creates ptr access instead of chunk.GetNativeArray?

rotund token
#

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)

viral sonnet
#

i mean, it says a lot about how unity sees this all under the hood.

rotund token
#

yeah but no dev is touching that

viral sonnet
#

writing code for the lowest denominator is odd

rotund token
#

it's not about lowest denominator

viral sonnet
#

what makes you think an intern doesn't change a RefRO access to RefRW because he needs to modify it NOW?

rotund token
#

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

viral sonnet
#

i get that, yet not everything can be coded in safe space. i feel like we are talking about 2 different things

rotund token
viral sonnet
#

so he removes readonly ๐Ÿ™‚

rotund token
#

then it'd break because it needs marked to be readonly

viral sonnet
#

how can you make sure of that?

rotund token
#

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

viral sonnet
#

yep, that's all great. you have thought this through. i'm not sure why we are talking about it ๐Ÿ˜„

rotund token
#

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!

viral sonnet
#

none of the methods i have can modify readOnly marked components

rotund token
#

actually wait

#

can you implicit cast the Safe to Unsafe versions?

#

then it'd work fine

#

you just want a private field right

viral sonnet
#

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

rotund token
#

can't you just do something like
public implicit operator UnsafeComponentLookup<T>(ComponentLookup<T> lookup)

#

or does your memory layout not match

viral sonnet
#

it does match

rotund token
#

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

viral sonnet
#

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 ๐Ÿ˜„

rotund token
#

yeah just memory remap!

viral sonnet
#

at least it compiles public static implicit operator UnsafeComponentLookup<T>(ComponentLookup<T> lookup) { return UnsafeUtility.As<ComponentLookup<T>, UnsafeComponentLookup<T>>(ref lookup); }

rotund token
#

yeah i think that should be fine

viral sonnet
#

yeah nice idea. thanks!

rotund token
#

as long as your memory layouts match

viral sonnet
#

yep, all fine. also won't change

#

that's a really nice solution i must say

#

always good talking to you ๐Ÿ˜

rotund token
#

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)

viral sonnet
#

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

rotund token
#

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

viral sonnet
#

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 ๐Ÿ˜„

rotund token
#

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

dense storm
#

How come I can't access EntityManager from a static reference cache?

#

Throws me unsafe errors

viral sonnet
#

why would you need that when there's access through World?

dense storm
#

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

viral sonnet
#

well, it's a struct. you are asking for trouble ๐Ÿ™‚

dense storm
#

I see ๐Ÿ˜‚

viral sonnet
#

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

dense storm
#

Thanks for this, got everything working well :)

dense storm
#

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.

drowsy pagoda
#

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?

rotund token
drowsy pagoda
#

Ok thx Iโ€™ll read it over.

proud jackal
# drowsy pagoda Is there docs on SystemAPI? And also touching the subject of Source Gen, say if ...

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

drowsy pagoda
#

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?

proud jackal
#

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

drowsy pagoda
#

Ah i see, hence source gen.

proud jackal
#

Indeed :3

drowsy pagoda
#

Well, more wiggle room nonetheless

brave field
proud jackal
#

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

brave field
rustic rain
#

UI Toolkit

#

it's not dots

brave field
#

I try to use system to bridge UI but ends up really suck code ๐Ÿฅฒ

rustic rain
#

but you don't have to use mono

proud jackal
#

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

brave field
#

The code is much clearer to just write it directly at MonoBehavior

rustic rain
#

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

proud jackal
#

Which UI system are you using? think

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 ๐Ÿ˜†

rustic rain
proud jackal
#

OnStartRunning :3

rustic rain
#

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

brave field
#

๐Ÿ‘€ Wow. I thought can't put managed thingy at ISystem?

rustic rain
#

execution itself can be managedd

proud jackal
rustic rain
#

but you might want it only on OnCreate or OnStartRunning

proud jackal
rustic rain
#

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);
                }
            }
        }
rotund token
#

i personally found this pretty gross ๐Ÿ˜„

brave field
rustic rain
rotund token
#

just make you world created after scene load if you need something in oncreate

rustic rain
#

it sucked

#

hard

rotund token
#

how so

#

you're basically doing it now?

rustic rain
#

I had to implement tons of async code

#

no

rotund token
#

unless you're monobehaviours are referencing entity world

rustic rain
#
    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

rotund token
#

in which case you are beyond hope ๐Ÿ˜†

rustic rain
#

I kept all normal world creation the same

#

just added my own extensions to it

rotund token
#

and it cost you 2 weeks of work

#

because you couldn't use your inspector!

brave field
rustic rain
#

it did

#

but it wasn't exactly it

#

anyway's it works now, and I'm glad I can keep working

proud jackal
#

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

rotund token
#

(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)

proud jackal
#

Haha, yyuppp... ๐Ÿ˜†

brave field
proud jackal
brave field
#

๐Ÿง 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?

rustic rain
#

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?

misty wedge
#

I had the same issue, I have no idea. I instead just used and entityquery ๐Ÿคท

rotund token
#

you know what hasn't had enough credit yet? unmanaged shared components

misty wedge
#

Yeah I love it

#

I can finally burst my spawn functions

rotund token
#

i used to have like duplicate components

misty wedge
#

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

rustic rain
#

oh god

rotund token
#

yes? ๐Ÿ˜ˆ

rustic rain
#

tertle, remember that selection tool?

#

it's broken

rotund token
#

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

rustic rain
#

I'm trying to figure how to bring back mesh chunk gathering

rotund token
#

oh because rendermesh doesn't exist?

rustic rain
#

yeah

rotund token
#

ah yeah that's a bit of a pain to redo

misty wedge
#

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? ๐Ÿคท

rustic rain
#

wdym not being able?

rotund token
#

components are effectively containers (chunk)
and safety doesn't work nested containers

rustic rain
#

ah

misty wedge
#

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)

rotund token
#

so you can't inject safety handles while scheduling a job so it always errors with this is write only

misty wedge
#

I think you can write to it but you can't also read from it

rotund token
#

native containers on components only usable at system level

#

good for sharing between systems though

misty wedge
#

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

rotund token
#

and you can pass them in from the system

misty wedge
#

If it was just lists I would replace them with DBs, but I have some other stuff in there too

rotund token
#

and it'll work fine, it just breaks if you access the component itself in the job

misty wedge
rotund token
#

yeah there's no safety on them

misty wedge
#

And I'd still have dependencies at least from the read / write permissions on the component

rotund token
#

yes

misty wedge
#

So just be careful when defining those

rotund token
#

^

#

as long as you define your read/writes correctly it should be fine

deft pilot
#

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

rustic rain
deft pilot
#

i guess deterministic would require me to do it frame by frame

#

i'll just do that

rustic rain
#

FixedStep group uses it

deft pilot
#

i'll take a google of that thanks

deft pilot
#

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

spice vale
#

yes, it works like a list

deft pilot
#

alright making sure there isn't any weirdness under the hood

deft pilot
#

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

pliant pike
#

I mean you could just calculate it, if you know the size of the grid and the size of each tile?

pliant pike
#

is there no HasBuffer() method I thought there was ๐Ÿ˜•

proud jackal
pliant pike
#

I'm on 0.51 so maybe its different

#

Don't tell me I'm going to have to update ๐Ÿ˜Ÿ

half jay
#

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?

pliant pike
#

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

gusty comet
#

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

coarse turtle
gusty comet
#

I only want to disable certain components

coarse turtle
#

oh sorry I misread

gusty comet
#

youre good

brave field
#

@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

viral sonnet
#

there are a bunch of build problems currently. even without netcode. what error do you have? cant compile or crash?

whole gyro
#

@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.

viral sonnet
#

yeah runtime works fine

#

so have you managed to get it to work for baking systems?

whole gyro
#

No, tried a bunch of things and no luck so far.

viral sonnet
#

but you can change a prefab enabled state and then the instantiated are also correct?

whole gyro
#

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

viral sonnet
#

ok, i'm gonna wait this out and just set the flag on in the instantiation

gusty comet
#

Also, does Baking only work in Subscenes for now?

gusty comet
#

Are Subscenes the way to go from now on?

whole gyro
#

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.

gusty comet
#

Thanks!

drowsy pagoda
#

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?

rustic rain
#

๐Ÿค”

rustic rain
#

just compile it

#

and then take a look at source of codegen

rotund token
#

the description are pretty good for this

#
Calling this method should allow for construction of EntityQueries with almost no run-time performance overhead."```
drowsy pagoda
#

yeah that's how I understood it from description, just wanted to make sure I understood it correctly cause that's an awesome feature.

rotund token
#

that's basically SystemAPI in a nutshell

rustic rain
#

hmm

#

if it does caching under the hood

#

then you can save so much space

#

in files

#

pog

rotund token
#

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

rustic rain
#

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

patent kelp
rotund token
#

is probably the best

#

you can see on that page how many different samples they have

patent kelp
#

Do those still work in 1.0?

rotund token
#

yes

#

they were updated

patent kelp
#

Thank you Turtle

rotund token
#

only thing not updated yet is netcode

#

which is coming soon~

spice vale
#

Is it always better to use WorldUpdateAllocator rather than Allocation.Temp whenever possible?

rotund token
#

they are kind of do different things

#

i think for the most part you should replace TempJob with WorldUpdateAllocator

spice vale
#

WorldUpdateAllocator can be rewinded, right? but not Allocator.Temp?

rotund token
#

temp is rewound every frame

#

kind of

#

it's a fixed pre-allocated chunk of memory per thread

spice vale
#

so what is WorldUpdateAllocator then?

rotund token
#

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

spice vale
#

right

rotund token
#

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)

spice vale
#

WorldUpdateAllocator rewind functionality is hidden for us then I suspect?

rotund token
#

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

spice vale
#

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?

rotund token
#

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

spice vale
#

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

rotund token
#

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

spice vale
#

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

rustic rain
#

I don't get, what's the use case for that world allocator?

spice vale
#

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.

viral sonnet
#

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

rustic rain
#

๐Ÿค”

viral sonnet
#

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

rustic rain
#

So it's just faster allocator than jobtemp?

#

As For use case

viral sonnet
#

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 }

rotund token
#

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

viral sonnet
#

so am i right in the assumption that if you allocate 100Mb per frame, with the rewindable memory it'll actually be double, 200Mb?

rotund token
#

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

viral sonnet
#

ok

#

huh, this seems to mostly work for fixed allocations then. can a NativeList also be allocated with rewindable memory?

rotund token
#

yes

#

i believe all the native containers can be now

viral sonnet
#

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

viral sonnet
#

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)

rotund token
#

yes?

#

just like any allocation

viral sonnet
#

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.

rotund token
#
        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

rotund token
#

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

gusty comet
#

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

viral sonnet
#

true dat. i'll evaluate those persistent lists, some Capacity can be calculated so that would make it possible for rewindable memory

viral sonnet
gusty comet
#

Gotcha. Guess I'll rely on StaticOptimizeEntity then

gusty comet
viral sonnet
#

if it's just transform there are solutions

#

GetEntity(authoring, TransformUsageFlags.ManualOverride);

gusty comet
#

Does that remove the components?

viral sonnet
#

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

viral sonnet
gusty comet
#

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)
        {

        }
    }
rotund token
#

if you want no transform components just do
GetEntity(authoring, TransformUsageFlags.ManualOverride);
as enzi said

gusty comet
#

Gotcha. Thanks!

viral sonnet
#

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 ๐Ÿคฃ

rotund token
#

i made the mistake of redoing all this before i realized the power of systemapi

#

that said, really wasn't that time consuming

viral sonnet
#

do you know how netcode handles tick? is it in a singleton?

rotund token
#

oh it's super complicated

#

the first question you have to ask is

#

what tick

viral sonnet
#

oh damn ๐Ÿ˜„ server tick

rotund token
#

clients can tick multiple partial frames

viral sonnet
#

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.

rotund token
#

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

viral sonnet
#

NetcodeServerRateManager is a systemGroup, right?

rotund token
#

no