#archived-dots

1 messages ยท Page 4 of 1

viral sonnet
#

for example

devout prairie
#

so i guess really it depends how much data you're storing in the buffer ( ie whether it's faster/slower than a blob )

hot basin
#

you can just attach buffer element to the chunk

#

๐Ÿค”

viral sonnet
#

and i think the true strength of chunk buffers lies in simd.

#

and if it's not simd, at least that it's linear data

devout prairie
#

i think a blob should at least provide fast linear and native memory access right

viral sonnet
#

can't say that for most blob data. at least not in my case. i save spell data in blobs and that's quite a lot of data alltogether

devout prairie
#

in my case i'm using a blob to store for example 1500 float3's

#

so i don't think db would work there, in fact i don't think there's any real alternative

hot basin
devout prairie
viral sonnet
#

blobs are linear, yes the layout is like [blob struct data][ptrs/length][...][arraydata1][arraydata2]...

devout prairie
#

i'm not optimizing for the moment but yeah, just curious about that

viral sonnet
#

seems fine to me, the first access is random but then it's linear

devout prairie
#

atm it's just a flat array of float3's, all bone pos/rots packed into a single array

viral sonnet
#

i'd not save this any other way. you are not capped by any 16k limit

hot basin
#

can I have second opinion on that? ๐Ÿ˜„

viral sonnet
#

hm, i dunno, try it. should be a fast test ๐Ÿ™‚

#

i'd say it doesn't work but who knows ๐Ÿ˜„

hot basin
#

it doesn't

rotund token
#

Pretty sure I would not have said that

#

It definitely does not

robust scaffold
#

Inheritance is a naughty word here in dots land

balmy thistle
#

word

hot basin
#

and I don't think it was about generic jobs

#

nvm memory is a funny thing

drowsy pagoda
#

Is this what you remembered reading about? SceneManager.MoveGameObjectToScene(GameObject go, Scene scene) ?
Tried it, works perfect. Before this I tried what you mentioned Open scene, instantiate, and then go back to previous scene. T'was a disaster, buggy.

rustic rain
#

Great it works

#

It'll probably a good feature for designer tools

devout prairie
#

Anyone recognize this error from doing a build:

#

not using subscenes, wondering if my gameobject which is building a blob during Convert ( just in a mono / IConvertGameObjectToEntity ) has anything to do with it

#

last time i built was prior to building any blobs and it worked ok.. only other thing is, i recently created a new blank project and copied my assets/scripts in, so there's maybe possibly an outside chance it could be a package problem, but i doubt it

rotund token
#

Is this just a compile error?

#

I've seen this before when setting up a new project
What .net are you targeting

#

And do you have netcode in your project?

devout prairie
#

well oddly, it seems to have gone after messing around with it ๐Ÿ˜

#

i'd deleted the sample scene which comes with a blank template URP project, which was showing as 'deleted' in the build scene list, so i removed that, enabled dev build, clicked my heels together three times and rubbed my nose, and error seems to be gone

#

spoke to soon it came back

devout prairie
rotund token
#

yeah

#

that's the .net 4.x error i'm pretty sure

devout prairie
#

weird i never had this before

#

and weird it worked once then didn't

rotund token
#

entities only supports standard

devout prairie
#

i'm 99% sure my previous version of this project was 4.x

rotund token
#

was that before 0.50 or 0.51?

devout prairie
#

now i'm getting some staging error

devout prairie
rotund token
#

did you add local packages recently

devout prairie
#

no

#

just entities/hybrid/tmp

#

going to load my previous project and compare/doublecheck

#

weird error, i'll try a restart, maybe as i'd changed over to net 2.0

rotund token
#

not sure sorry but i can tell you that there are at least 2 studios who had this error targeting .net framework after a 0.51 upgrade and fixed it switching to standard 2.1

devout prairie
rotund token
#

the error generally occurs anytime a package change is made

#

including any use of asmref

#

(the original, no idea about that new weird one)

devout prairie
#

rather than importing from git url, i manually changed manifest which was probably a mistake

#

when i was setting up the project

rotund token
#

dont think that should make any difference

devout prairie
#

i had a couple of odd issues during that

rotund token
#

anyone who pulls repo has to setup via manifest

devout prairie
#

mm

#

it's also locked this folder even after closing unity, inside my build dir

#

just having lots of fun

rotund token
#

just restart your pc on that

#

if you check task manager you will probably see some process not closed

#

unity.exe

#

or some compiler

devout prairie
rotund token
#

easier/faster to just restart

devout prairie
#

yeah

viral sonnet
#

is it possible to setup performancetest data via subscenes? the editor entities are there so shoudkd be possible, right?

rotund token
#

Never tried but I don't see why not

#

Just load the subscene into a custom world in the test

#

Just need to add the 2 or 3 scene systems that are required for loading then tick it until it's loaded

viral sonnet
#

hm, gonna try it. i need some better testing ground ๐Ÿ˜„

#

now i've time to get back to the stats reading. that last coding session really annoyed me. i tried 3 different ways and every way was slower. i came to the conclusion. as i'm reading a few stats in the first job the must be already in cache and it's faster to then build the stats for the spell calculation. otherwise, i don't know how to explain that the first job needs 1.5ms for building and another job needs 2+ms

rotund token
#

Only concern would be maybe the requirement for editor tick to load assets but in pretty sure there's a way for unit tests to support this

viral sonnet
#

hm, i guess i don't need a full subscene. just a prefab that has to be converted

rotund token
#

Probably an easier alternative

#

Generally everything in my subscenes are prefabs anyway so I don't need to open to edit them

drowsy pagoda
#

Getting some strange behavior, can someone help me understand why this is happening? Ok. So I have static Game.Save(), which writes to disk data gathered by an ECS job like so var data = await _system.GenerateSnapshot();
_system is a SystemBase class. Here is the async GenerateSnapshot() method:

public async Task<WorldSnapshot> GenerateSnapshot()
        {
            // gather all unit positions and rotations
            var unitSnapshots = new NativeArray<UnitSnapshot>(_unitQuery.CalculateEntityCount(), Allocator.TempJob,
                NativeArrayOptions.UninitializedMemory);
            
            var unitSnapshotJob = new UnitDataExtractionJob
            {
                unitGuids = _unitQuery.ToComponentDataArrayAsync<UnitGuid>(Allocator.TempJob, out var guidsJobHandle),
                transforms = _unitQuery.ToComponentDataArrayAsync<LocalToWorld>(Allocator.TempJob, out var transformsJobHandle),
                unitSnapshots = unitSnapshots
            };
            
            var dependencies = JobHandle.CombineDependencies(guidsJobHandle, transformsJobHandle);
            var unitSnapshotJobHandle = unitSnapshotJob.ScheduleParallel(_unitQuery, dependencies);
            Dependency = JobHandle.CombineDependencies(unitSnapshotJobHandle, Dependency);

            while (!unitSnapshotJobHandle.IsCompleted)
                await Task.Yield();

            var snapshot = new WorldSnapshot(unitSnapshots);
            unitSnapshots.Dispose();
            return snapshot;
        }
#

The reason why I am not using Source generation is because it gave me weird errors since I was trying to execute this outside the system's OnUpdate method. But old school worked ๐Ÿ˜‰
Alright here is the strange behavior part. On my in-game UI, you click Save Data button, and it will just forward call to Game.Save(). The data gets saved without error.
But in my inspector, I have a component that has a button Save Game In Editor and it too does Game.Save(), but it gives me this error and I have no way of knowing how to plug this hole! Can someone help me understand why in one place it executes fine, but called from another it doesn't?
Here is the exception: InvalidOperationException: The previously scheduled job GatherComponentDataJob reads from the Unity.Entities.EntityTypeHandle GatherComponentDataJob.safety. You must call JobHandle.Complete() on the job GatherComponentDataJob, before you can deallocate the Unity.Entities.EntityTypeHandle safely.
As you know GatherComponentDataJob is a Unity job and not one I wrote...what's going on? If you need to see other code, let me know I'll paste it.

rotund token
#

What you're doing is not safe and the editor button is just pointing this out

#

It's not safe to use ecs access via public methods like that

#

A system only updates its dependencies in before on update

#

Just use em, cache the data and run your save

#

Or do it if the same system as caller

drowsy pagoda
drowsy pagoda
#

Also both are being executed during runtime.

rotund token
#

Yeah pretty much, you can just use an Entity event (what I do) to trigger system or just use entity manager instead to sync data before and do it directly on the ui

drowsy pagoda
#

Could you elaborate on that Entity event?

#

And that system that "GenerateSnapshot" has "AlwaysUpdateSystem" attribute

rotund token
#

Also 1 note is you're not writing your dependency back either so no other system can wait on it

rotund token
#

And if I want to save game I create an entity with that component

#

And that triggers my system to run

drowsy pagoda
drowsy pagoda
#

Could you help me understand how to write the dep back so other systems can wait on it?

rotund token
#

You can't doing it that way

#

That's the problem

#

You're not in the right system

drowsy pagoda
#

Meaning the system is not in the stack trace initiating the call to that method? Because that method is in the system class.

devout prairie
#

build working fine after switch to net 2.0 and restart

rotund token
#

Arriving at gym back in like 90min

drowsy pagoda
#

Ok, cool. I'll mess around and hopefully find a solution before then ๐Ÿ˜‰

rotund token
#

Just to confirm

drowsy pagoda
#

Ok, right after I wait for handle.IsCompleted to be true, I do CompleteDependency() and the operation actually works. It still throws that exception, but it actually does what I need it.
When I remove that await handle.IsCompleted and just do CompleteDependency() it works without throwing.

rotund token
#

Where are you calling generate snapshot from

drowsy pagoda
#

Game.Save()

#

Game is a static class that doesn't inherit

rotund token
#

So it's not called from the system the method is in

drowsy pagoda
#

No. Game.Save() has var data = await _system.GenerateSnapshot();

#

that's where that injection takes place. _system is a SystemBase class.

rotund token
#

Class starting afk again

drowsy pagoda
#

ok

#

I can upload all the relative code for you somewhere if you want to look at it later and give me some insight.

drowsy pagoda
#

Alright I just did Game.Save(bool forceMainThread = false). And when editor calls this, it does Game.Save(true); This then bypasses the handle.IsCompleted awaiter and just forces CompleteDependency() and it all works ๐Ÿ™‚

drowsy pagoda
#

how do you clear/rebuild entity cache via script?

rotund token
#

You can register asset dependencies in subscenes and any change to these assets will rebuild relative subscenes

#

And you can version conversion scripts

#

That said the version approach is a pain tbh

drowsy pagoda
#

I agree. But my editor script that loads worlds into a sub scene, and when that does, it spawns remains of previous data even though game objects have been destroyed.

#

So I need to clear cache when I clear scene before loading

drowsy pagoda
rotund token
#

In the dots menu

#

There's I button that opens a window

#

That has a button that clears the cache for you

#

I can't remember what it's called, on a tram so can't check

#

If you look at the code of that window though you could see how to trigger it from code yourself

drowsy pagoda
rotund token
#

you can

drowsy pagoda
#

Oh! Can you give me a quick boiler plate? So this is the magic formula: EntitiesCacheUtility.UpdateEntitySceneGlobalDependency();, but EntitiesCacheUtility accessor is internal and sits in the Unity.Scenes.Editor assembly. How can I trigger this via Reflections?

rotund token
#

imo easier to just give yourself internal access using asmref

#

but if you want to do it via reflection you need to get access to type using something like Type.GetType()

#

then just call GetMethod using something like GetMethod("UpdateEntitySceneGlobalDependency", BindingFlags.Static | BindingFlags.NonPublic)

drowsy pagoda
#

Yeah I know how to use reflections. I'm just having a hard time EntitiesCacheUtility.GetType() because EntitiesCacheUtility is not allowed to be used since it's internal lol. Anyways, I just did EditorSceneManager.MarkSceneDirty(scene); and it seemed to do the trick, I'm no longer experiencing those issues. So for now, keep my fingers crossed cause this wasted way too much time.

rotund token
#

typeof(SceneImporterData).Assembly.GetType("Unity.Scenes.EntitiesCacheUtility")

drowsy pagoda
#

SceneImporterData was simply just something you picked at random that exists in Unity.Scenes.Editor assy right?

rotund token
#

yep

#

just the first thing i saw in that assembly that was public

#

most of it's internal

#

alternatively you could use a full qualified name with Type.GetType(namespace, type, assembly, version etc)

drowsy pagoda
#

smart thinking. That's exactly what push I was looking for. Thx!

rotund token
#

but that's a bit more painful to figure out exactly

#

i always forget the format

drowsy pagoda
#

lol

late mural
#

had this warning pop up randomly, is this something i should try fixing, or is it just a random one off thing? I have not touched any of what it was saying in the warning, as far as i know.

robust scaffold
late mural
late mural
robust scaffold
late mural
#

oh ok, should i check both?

robust scaffold
#

You havent been putting [BurstDiscard] anywhere have you?

robust scaffold
# late mural i dont think so

Check your entire solution for any of those tags on methods. See if it's the same situation as in that documentation page. If you know for certain it isnt your code, just ignore it.

late mural
late mural
#

ok ye no burst discard anywhere

robust scaffold
late mural
robust scaffold
late mural
#

ok ill try that and report back, thanks!

late mural
rotund token
#

anyone know much about these artifacts for unity physics?

#

enabling it definitely seems to show a more stable simulation

rustic rain
#

Sir, do you happen to know whether it's possible to swap burst compiled function pointer with another?
Or whether it's even presented this way internally?
It's regarding modding

rotund token
#

sure why not?

new FunctionPointer<TryFunction>(ptr)
function ptr just takes an int ptr

#

you can pass in anything you want

#

as long as signature is correct it'll work fine

rustic rain
#

are those pointers stored somewhere available to user code?

rotund token
#

you can pass whatever function pointer you want into a job conditionally

rustic rain
#

but what I mean is modding from outside

#

after you built game

#

you launch it, load your assembly and you want to swap pointers

#

meanwhile original implementation is vanilla burst in Entities.ForEach loop

rotund token
#

there's really nothing special about function pointers as far as i'm aware

rustic rain
#

waaaait a second

rotund token
#
        {
            get
            {
                CheckIsCreated();
                return Marshal.GetDelegateForFunctionPointer<T>(_ptr);
            }
        }```
by default (outside of burst) all it does is marshal pointer
rustic rain
#

let's say there's 3 bursted functions with same signature

#

can you put them all in one, that will be executed one by one?

rotund token
#

ahh what

rustic rain
#

prefix,postfix

rotund token
#

a function pointer maps 1 : 1 to a method

rustic rain
#

hmmm

rotund token
#

just think of it as a delegate

rustic rain
#

yeah

#

that's what I mean

#
() => {
/// code
}
#

instead of this

#

have

#
()=>{
ptr.Invoke();
ptr1.Invoke();
ptr2.Invoke();
}
#

for bursted function pointers

#

so that you can swap original one with that one

rotund token
#

no because you can't do () => in burst

rustic rain
#

and pass all parameters between them

#

that's just example

#

for the sake of passing my thought process

rotund token
#

if you have a job with 3 function ptr fields

#

you can pass whatever 3 functions you want to those methods

#

they can be different each frame

rustic rain
#

no, I mean is modify existing job without any function pointers

#

so instead of only original code that was compiled AOT

#

you could run additionally loaded more bursted functions

rotund token
#

probably going to have a much easier time just writing a call to a native library

#

and have that run extra code

#

i guess the only way i could think of

#

is if function pointer of function pointers work

#

i dont know about this though

rustic rain
#

eh, I just hope Unity will simply make a JIT compilation on demand

#

for burst and modification of code

rotund token
#

you're probably going to have to pay for an engine license if you want that anytime remotely soon

#

in which case you couldn't share it anyway

#

modification license*

rustic rain
#

allthough

#

considering ECS

#

I have a feeling

#

that simply creating a System with constraints UpdateBefore/After can be enough

#

literally will work like prefix/postfix

rustic rain
#

ahem

#

FixedString serialization doesn't work?

rustic rain
#

oof

#

I really need to think of a way to have prefab system

#

But I can't figure any solution

#

I need a way to keep prefab reference of existing entity

#

so that I can easily "clone" entity based of it's initial prefab

#

not based of it's existing state

open condor
#

In Dots NetCode is it possible to define a Component that will NOT be synced through network? Because everytime i ADD a component on serverside it seems to result in a network update for this entity, even though the component is not actually being synced

rustic rain
#
        public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
        {
            var builder = new BlobBuilder(Allocator.Temp);
            ref var def = ref builder.ConstructRoot<Def>();
            def.defType = new FixedString128Bytes(defType);
            def.defName = new FixedString128Bytes(defName);

            var reference = builder.CreateBlobAssetReference<Def>(Allocator.Persistent);
            conversionSystem.BlobAssetStore.AddUniqueBlobAsset(ref reference);

            dstManager.AddComponentData(entity, new DefReference { def = reference });
        }

Is that the correct way to create blob assets in conversion?

viral sonnet
viral sonnet
rustic rain
#

it's also about having link on entity

#

to that prefab

#

rn I figured

#

I could store blob asset reference on every entity

viral sonnet
#

so the instantiated entity needs a reference to its original prefab?

rustic rain
#

yes

viral sonnet
#

i also had that at one point. you can patch it via ecb

rustic rain
#

this for A: saving system
B: gameplay interaction

#

nah, I want to do it one time in conversion

#

I decided

#

that I just limit myself from having prespawned entities

#

and instead do all spawning through code

viral sonnet
#

would also work when the prefab references itself

rustic rain
#

unless it's debugging

#

yeah, prefab will reference itself in this case

viral sonnet
#

i had true runtime data so when i was doing it i had to use ecb patching

rustic rain
#

but actually

#

it's not Entity reference

#

it's string reference

#

I figured I'll use

#

defType and defName strings

viral sonnet
#

some stable hash or id makes sense when it's for a savesystem too

rustic rain
#

to define unique combinations for any sort of defnitiion I want

#

currently I have this weird error

#

and counter makes me worry a bit ๐Ÿ˜…

#
    [Serializable]
    public struct Def
    {
        public FixedString128Bytes defType;
        public FixedString128Bytes defName;
    }

    public struct DefReference : IComponentData
    {
        public BlobAssetReference<Def> def;
    }
#

not sure if I did anything wrong

viral sonnet
#

it's correct. try to remove the serializable

rustic rain
#

nope

viral sonnet
#

hm, that's odd. i don't get any errors with FixedString in my blob.

rustic rain
#

I am very confused

#

I even changed name for type

#

and it still says same error with old name

viral sonnet
#

just copy/pasted your code. no errors

#

maybe restart unity ๐Ÿ˜„

rustic rain
#

yeah, that helped only on second attempt

#

bruh, now I get this odd error which pauses editor on start

#

tf is wrong with blobs

#

hmm

viral sonnet
#

doesn't look like anything from blobs

rustic rain
#
    public struct Definition
    {
        public FixedString128Bytes defType;
        public FixedString128Bytes defName;
    }

    public struct DefReference
    {
        public BlobAssetReference<Definition> def;
    }

    public struct Def : IComponentData
    {
        public DefReference def;
    }

oh god...

#

do I really need this monstrocity?

viral sonnet
#

no ๐Ÿ™‚

rustic rain
#

that's the only way error dissappears

viral sonnet
#

does it work with a second struct?

rustic rain
#

hehe

viral sonnet
#

lol wtf

rustic rain
#

ok, I'll try again

#

with 1 wrapper

#

nope

#

errors

#

[assembly: RegisterGenericComponentType(typeof(BlobAssetReference<Definition>))]
hmmm

#

what if

#

nah

#

double wrapper lezzgo

#

wait a second

#

turns out

#

this error appeared

#

if you had query debug window opened

#

huh

#

damn, it was hidden so well behind other windows ๐Ÿ˜…

rustic rain
#

@rotund token sir. I remember that you made custom inspector for some pointer based component. Could you tip me how were you able to do that?

rustic rain
#

at least

#

can't locate any useful reference in manual

rotund token
#

I am the manual

#

It's probably Inspector can't remember

#

Yeah Inspector

#

Just override the build method

#
    {
        public override VisualElement Build()
        {
            var list = this.Target.Targets;
            var label = new Label($"Target Chunks: {(list.IsCreated ? list.Count() : 0)}");
            return label;
        }
    }
rustic rain
#

thank you sir

devout prairie
#

math has this little helper math.all(bool2 x) which will return if both bools are true

#

any idea if there's something like a math.none?

#

ie if both bools are false

rustic rain
#

hm

#

just do NOT

#

on result?

#

actually

devout prairie
#

mm no because, if one is true and one is false, it'll return false

rustic rain
#

you need

#

math.any

#

and then invert

devout prairie
#

ahhhhh

#

any

#

nice

rustic rain
#

no idea if that one exists, kek

#

but would be weird if it's not

devout prairie
#

it does haha

#

useful little helpers

rustic rain
#

smid friendly little helpers hehe

devout prairie
#

yeahh

#

tbf, it's just this:

#

but cleans things up and as you say any math stuff should be simd friendly afaik

stiff valve
#

Does anyone know how to fix this problem: my cube disappears when I "close" the scene

#

I have this

rotund token
#

I assume you have hybrid renderer installed?

stiff valve
#

Yes

rotund token
#

What render pipeline?

stiff valve
rotund token
#

You don't seem to have urp or hdrp

#

It does not work with built in pipeline

stiff valve
rustic rain
#

For the Universal Render Pipeline (URP), use the Universal Render Pipeline template.
I'd say start with that

stiff valve
#

Thanks

robust scaffold
#

Burrrrrrst. Why is IJobEntity not vectorizing any of the code. PAIN. Dont make me write out the whole IJobEntityBatch by hand

#

UGGGGHHHHHHHHHH. I'm gonna have to atomize these components if I want actual vectorization arn't I.

#

PAIN

rotund token
#

yes

#

generally a requirement if you want to vectorize your components

robust scaffold
#

Holy shit unity. VECTORIZE IT PLZ

rotund token
#

IJobEntityBatch 4 life

robust scaffold
#

What was the entire purpose of 0.50 if I have to sully myself with this manual code writing?

#

come on burrrrst

#

Wait no, that's the fallback. Here we go

#

This is so sad. 0.50 did absolutely nothing to the standard workflow

#

If I have to manually list the component type handles in order to get some vectorization, this was a complete waste.

#

At this point, I'm using a slightly fixed up version of 0.17. Unity has failed me.

#

I feel like I regressed in some way. After seeing the light that is code-generated jobs, this is just so disappointing.

#

I guess the upside is that now I can see the burst compiled code really easily with the no inlining tag.

viral sonnet
#

you can rewrite that with Reinterpret instead of the float*

robust scaffold
viral sonnet
#

i had some good results with burst 1.7.3

robust scaffold
#

In this case, I can use Reinterpret as it did unroll it successfully but I would like to keep my code style standardized.

viral sonnet
#

auto 2 loops for counts that are % 4 > 0

robust scaffold
#

I guess, would make things easier

#

But it would balloon the size of the method parameter list

viral sonnet
#

afaik it's not even burst but LLVM

#

don't make a method. i stopped doing that

#

should be quick enough for you to test out the results

robust scaffold
#

Otherwise it's buried in a mountain of chunk code.

viral sonnet
#

yeah makes sense. i wish there was some focus on the codefile to get rid of all the other nonsense

robust scaffold
#

During the early days of 0.50 announcement when Unity felt brave enough to talk on the forums, the Burst team did say that was a proposal they were looking into. Not implementing, just testing out things.

viral sonnet
#

or a simple keyword search ... ๐Ÿ˜„

#

i have a 42k loc assembly

robust scaffold
#

Yea, it unrolled. Hopefully this works for everything.

#

I dont get why Unity's code gen version doesnt. It's literally the same code.

#

Literally.

viral sonnet
#

wait, what doesn't unroll?

robust scaffold
viral sonnet
#

how does it help?

robust scaffold
#

Aspects will group together component structs without actually merging them together into one struct.

#

You want them in separate structs to pack the native array for burst. But an aspect will simplify querying the components together

#

So you dont need to type in a quarter million ComponentTypeHandle<> for all the components now separated into their own unique struct/component

viral sonnet
#

ah i see, less compHandles and GetNativeArrays, right?

#

yeah ok

robust scaffold
#

Yea, hopefully

viral sonnet
#

that will be nice. haven't thought of that

robust scaffold
#

But seeing how the current code gen isnt able to handle vectorizing a simple multiplication, i'm not holding my breath

viral sonnet
#

i think it will still need some reinterprets though. not sure the compiler gets it

robust scaffold
#

Hrm

#

This allows for a single loop vectorized multiplication

#

However, not unrolled.

#

This will allow for the unrolling of the angular multiplication but not the second. Both loops are vectorized though but not merged into 1 by burst.

#

This does not vectorize.

viral sonnet
robust scaffold
#

Yea, doesnt matter

viral sonnet
#

k ... yeah auto vec is reaaally basic

#

expect more than 1 line to fail ๐Ÿ˜„

robust scaffold
viral sonnet
#

needs a ref afaik

#

which would also mean pointer reinterpret to float3

robust scaffold
viral sonnet
#

ElementAt returns a ref

#

don't think that's wise though. just cast the pointer.

rotund token
#

(elementat on a native array is my extension, it only exists on buffer by default)

viral sonnet
#

but a ref float3 should be able to just write back to xy

robust scaffold
#

This also works, I think

viral sonnet
#

oh lol, right i just have it as extension. sorry ๐Ÿ˜„

rotund token
#

i'm curious if it'd be different if you used element at

viral sonnet
#

anyway, that's the method if you need it public static unsafe ref T ElementAt<T>(this NativeArray<T> array, int index) where T : struct { return ref UnsafeUtility.ArrayElementAsRef<T>(array.GetUnsafePtr(), index); }

robust scaffold
#

Using a pointer also removes several commands.

viral sonnet
#

pointers are my jam ๐Ÿ˜„

robust scaffold
#

If I just use the pointer directly, there's no need for custom extension methods

rotund token
#

hmm

#

why does this show up in the mix

#

is that just the indexer

#

doesnt look right

viral sonnet
#

yeah, i think it is

robust scaffold
#

Kinda a mess

#

I dont think it's the indexer

#

Seems like if I were to use .xy swizzler, it moves the result of the addition as a single operation instead of packed

#

Dont know if the cost of an addition insert and blend operation, even packed vectorized, is worth having the move be vectorized as well

#

Of course, if I assume everything is a float4, that simplifies everything

#

That however means 4 floats being wasted. Hrm, I might need to make translation a float2

#

Rolling my own translation simplifies the commands slightly. But that would mean completely re-implementing the transform system.

rotund token
#

out of interest why the noinlining

robust scaffold
#

I change it to aggressive inlining when I'm done staring at purple colors.

rotund token
#

because without that

#

mine generates nicer code

#

burst generated different operations

robust scaffold
#

No difference

rotund token
#

interesting

robust scaffold
#

Also fails to vectorize when merging the for loops together. Commented out the [NoInlining]

#

And copy pasting it into the Execute() method doesnt change the code. Just disperses it across the entire output

#

Im gonna stick with [NoInlining]. Makes debugging small changes a lot easier to find.

rotund token
#

left inline, right noinline
removes the vbroadcastss instruction

robust scaffold
#

huh. hrm

rotund token
#

๐Ÿคทโ€โ™‚๏ธ

robust scaffold
rotund token
#

is your damping marked readonly?

robust scaffold
rotund token
#

no idea

#

quite odd

#

nothing special i don't think

robust scaffold
rotund token
#
        private struct TestInline : IJob
        {
            public float FixedDt;

            [ReadOnly]
            public NativeArray<float> Damping;
            public NativeArray<float> Angular;
            public NativeArray<float2> Velocity;
            public NativeArray<float3> Translation;

            public void Execute()
            {
                this.Vectorized(this.Damping, this.Angular, this.Velocity, this.Translation);
            }

            private void Vectorized(NativeArray<float> damping, NativeArray<float> angular, NativeArray<float2> velocity, NativeArray<float3> translation)
            {
                for (var i = 0; i < angular.Length; i++)
                {
                    angular[i] *= damping[i];
                }

                for (var i = 0; i < translation.Length; i++)
                {
                    velocity[i] *= damping[i];
                    translation.ElementAt(i).xy += velocity[i] * this.FixedDt;
                }
            }
        }```
#

thought i'd just throw it in a performance test for interest

robust scaffold
rotund token
#

10 mill elements

robust scaffold
#

Yea, broadcast is gone

#

what is going on?

rotund token
#

the only thing i can think of is native array vs ptrs

#

but i dont see why burst couldnt figure that out

#

alternatively can you try to use another value for count

robust scaffold
viral sonnet
#

oh tertle did the test with elementat. seems fine, right?

rotund token
#

oh mine was using withelement

#

same as the ptr

robust scaffold
rotund token
#

yeah i saw

rotund token
robust scaffold
#

The broadcast is for FixedDt.

#

Commenting it out and turning it back to no inlining removes the broadcast

rotund token
#

ah

robust scaffold
rotund token
#

if you pass it into the method does it produce a similar thing

#

or maybe cache it at start of loop

#

odd

robust scaffold
#

Hrm, yea. Alright, so make Vectorized static.

#

Yep, this is for the actual IJobEntityBatch method.

robust scaffold
# rotund token thought i'd just throw it in a performance test for interest
[BurstCompile]
private unsafe struct TestInline : IJob
{
    public float FixedDt;

    [ReadOnly]
    public NativeArray<float> Damping;
    public NativeArray<float> Angular;
    public NativeArray<float2> Velocity;
    public NativeArray<float3> Translation;

    public void Execute()
    {
        Vectorized(Damping.Length, FixedDt, (float*) Damping.GetUnsafeReadOnlyPtr(), (float*) Angular.GetUnsafePtr(),
            (float2*) Velocity.GetUnsafePtr(), (float3*) Translation.GetUnsafePtr());
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    private static void Vectorized([AssumeRange(1, int.MaxValue)] int length, float dt, float* damping, float* angular,
        float2* velocity, float3* translation)
    {
        for (var i = 0; i < length; i++)
        {
            angular[i] *= damping[i];
        }

        for (var i = 0; i < length; i++)
        {
            velocity[i] *= damping[i];
            translation[i].xy += velocity[i] * dt;
        }
    }
}```
Can you performance test this?
#

The only difference now is inlining. And with [MethodImpl(MethodImplOptions.NoInlining)] -> [MethodImpl(MethodImplOptions.AggressiveInlining)]

rotund token
#

let me undo my deletes then sure

#

actually

#

take that second one

#

i think the first was flawed

robust scaffold
#

Wait, no inlining is faster?

#

by nanoseconds

#

eh, it falls within 1SD

#

Is the inline using aggressive?

rotund token
#

i think they're exactly the same but the results vary 1ms between tests

rotund token
robust scaffold
rotund token
#

actually id say on average no inline does tend to edge ahead

#

but maybe its because its running second ๐Ÿคทโ€โ™‚๏ธ

robust scaffold
#

Yea, with a difference in the 10 ns, it might as well be equal.

#

Thats what, 4 operations?

rotund token
#

run it in reverse order

#

and it swaps around

#

but yeah results are quite varied

#

sometimes randomly have a 17 vs 21ms fights

#

alternating

robust scaffold
#

Im gonna run with yea, no difference.

rotund token
#

i dont think we'd expect there to be

robust scaffold
rotund token
#

static method in a method with nothing else

#

good distraction anyway

#

time to back to debugging something that's causing me issues =\

robust scaffold
#

Huh, using floating point deterministic mode does actually change the burst output

#

They did say it was in very early testing phase. No announcement but if you do every single math operation to floats in burst, it's largely deterministic

rotund token
#

on the modern hardware within the same environment we've found it to be completely determinstic (as expected)

#

any modern intel/amd chip seems to be fine

#

it fails across platforms though

#

i.e. consoles

robust scaffold
#

ah, about to say cross platform

robust scaffold
rotund token
#

without

robust scaffold
#

How about fast float operations, MADD?

rotund token
#

havent tested

robust scaffold
#

hrm, interesting. I guess deterministic will be for cross platforms and for 100% guarantee determinism by removing any optimization

rotund token
#

we don't rely on determinism we just use it for debugging seeds that people report as having issues

robust scaffold
#

Im very slowly rolling my own 2D deterministic stateless physics engine

rotund token
#

so it's nice to be able to generate the same environment if an issue is reported

robust scaffold
#

works across desktop platforms? Linux - Windows?

rotund token
#

we haven't released linux/osx

#

so can't say

robust scaffold
#

hrm, good to know

rotund token
#

only tested consoles + windows

#

dont quote me but i believe scarlett might be fine with desktop windows

#

i haven't tested enough to be certain though

robust scaffold
#

It's unannounced feature anyways. I'll develop with the assumption it'll work someday

#

Unity has advertised the 3D physics as deterministic so burst will have to be deterministic one day

rotund token
#

burst team have mostly worked on usability, bug fixes and performance for last like ~year

#

which i appreciate

#

but i feel like it's at a good point now

#

so we might start seeing new features sometime

robust scaffold
#

The inspector itself has been making leaps and bounds in usability.

rotund token
#

yeah the one thing htat would make it amazing

#

is the ability to hide job boilerplate code in it

#

basically, an only show user code option

robust scaffold
#

Yea, as I said above, the Burst team has stated on the forums they're looking into it. Compiler magic if they figure it out.

rotund token
#

from a purist coding perspective it sounds a bit gross

robust scaffold
#

Until then, I'll stick with no-inlining

rotund token
#

like the compiler having knowledge about other libraries that may or may not exist

robust scaffold
#

might just be a tag, something like "folder this method in the inspector"

#

and have unity tag everything they do to the job under it

rotund token
#

but yeah definitely my #2 feature i'd like to see

#

#1 being my request for an always/force burst compile option for specific jobs

robust scaffold
#

Make the [BurstCompile] tag optional?

rotund token
#

there are certain jobs that are just not usable without burst on

robust scaffold
#

Assume everything is burst compiled, make the burst discard the new conditional?

rotund token
#

an example which i think may expedite my request for them is the dots hierarchy

#

accidently start the game without burst and spawn like 1mill entities with that window open

#

and your editor just locks up for ages

robust scaffold
#

Oh yea, without burst it simply doesnt function with large amount of entities

rotund token
#

yeah hence that window should be force burst compiled always regardless if burst compile is enabled!

robust scaffold
#

I have to kill unity in task manager just to close and reopen

#

Why does the editor pull all entities? Shouldn't it pull just enough to populate the current hierarchy view. Dont know if thats possible though

rotund token
#

i've done testing with 100mill entities recently

#

and the window handle it fine

robust scaffold
#

With burst, anything is possible

rotund token
#

well i'm more thinking about ui toolkit

#

and how it's holding up

#

imagine if that was drawn with imgui

robust scaffold
#

I've gotta check the code for the hierarchy to see how they're passing data to UIT. The current method of per element is very slow.

#

ugh, burst why

rotund token
#

why don't you actually memset this

robust scaffold
rotund token
#

does it? interesting

#

it's always done some simd instruction to set it for me

#

instead of using an intrinsic

#

tbf i haven't tested in ages

robust scaffold
rotund token
#

well thats nice of it

#

think i'll still keep using my memset so some other dev doesn't come in and add something to the loop

#

and just break everything

#

but good to know

robust scaffold
#

If it's grouped with other operations in the same loop, yea it breaks the mem set

#

which is why there are 3 for loops and not 2.

rotund token
#

sure it wouldn't perform better if the top 2 loops were combined?

robust scaffold
#

Burst will not vectorize the first for loop for some reason. Switches to scalar single operations.

#

If it's merged with the second.

#

Isolating it results in proper PS operations and even unrolling. A similar drop in efficiency occurs when I merge the quaternion.RotateZ(angle[i]) in the second for loop. But it's just a single mov operation added to the loop so I determined it, without testing mind you, worth the cost of not having a 4th loop.

rotund token
#

oh

#

it's the quaternion

#

yeah

robust scaffold
#

no no, removing the quat and merging it has the same issue

#

it's the float2 of velocity and float3 of translation thats the problem

#

i have screenshots of the burst output above with and without merged, this was before I added the quat line.

rotund token
#

the single loop seems to reliably perform just marginally faster in a test for me

robust scaffold
rotund token
#

but within SD

#

burst shows it's much more scalar but doesn't really matter

robust scaffold
#

Scroll down a bit and it should produce this:

#

for 2 loops

rotund token
#

yeah i get that

#

but it just performs worse than combined

robust scaffold
#

alright, so merge it together seems to win. Wow

#

I really gotta figure out how to run performance tests. That is quite surprising

rotund token
#

again though, it's too close to really say

robust scaffold
#

Easier to read if it's merged. And I dont think I need to run a test to know that mem-set is always faster than a vectorized set.

rotund token
#

1 sec

#

might have been a minor flaw in my test let me rerun

#

burst above was fine but because i have safety off for running these missed something

#

ok your double loop actually helps

#

measurably

#

๐Ÿ‘

robust scaffold
#

Alright, thats much more logical.

rotund token
#

starts performing worse once you get to 5 loops ๐Ÿ˜„ (makes sense)

#

saw no difference with 4

#

anyway i really need to stop procrastinating

robust scaffold
mortal crow
#

Can't find anything on a DOTS physics rope. Is there any asset or tutorial to have that?

viral sonnet
#

heavily testing burst and simd = procrastinating. got it, i'll continue blowing leafs and be productive

rotund token
#

i'm too easily distracted by interesting things others are doing

viral sonnet
#

i can relate. at least it's a learning experience and eventually useful ๐Ÿ™‚

viral sonnet
#

well, that's not good. i've now a testcase for my job. pretty complicated one to setup. in game it's around 3.8ms, in performance test ~12ms.

robust scaffold
#

@rotund token There has to be a better way than this. Is there?

viral sonnet
#

afraid that's it

#

put a #region around this abomination. this is what i did so at least i don't have to look at it

robust scaffold
rotund token
viral sonnet
#

you take that back!

rotund token
#

my project is a safe space from regions

viral sonnet
#

ok i'll bite. what's so bad about regions? especially around ugly fire and forget code blocks?

rotund token
#

i mostly stick to stylecop ruleset to ensure consistency

#

In many editors, including Visual Studio, the region will appear collapsed by default, hiding the code within the region. It is generally a bad practice to hide code, as this can lead to bad decisions as the code is maintained over time.

#

i don't necessarily agree with all the rules in the set, but i like having a standard ruleset for consistency that i can enforce with analyzers

#

(though personally i somewhat agree with regions, i've never felt they improved any codebase I worked with)

timber ivy
#

is the navmesh api available in dots?

#

I have a large world that spans multiple scenes so I need to generate a navmesh 100x100 around the player. I dont plan on using ecs but i'd like to use the job system if possible

rotund token
#

they used it in the first demo way way back

timber ivy
rotund token
#

oh there's no need

#

they already have runtime navmesh generation

#

(but yes)

timber ivy
rotund token
#

a job would not change anything

#

but no i find unitys navmesh generation extremely fast

#

i wrote my own wrapper for recast

#

and unless i drop down all settings

#

unitys is about 6x faster

#

if i drop down all settings is near identical

#

(it does produce a very similar navmesh)

#

except their height is better for some reason

timber ivy
#

What is the class name i would be looking for in the docs to do this?

timber ivy
rotund token
#

i cant remember size

#

but it was a city

timber ivy
#

larger than 100 meters id imagine?

rotund token
#

with 8000+ meshes

timber ivy
#

ok then yeah

rotund token
#

it does it async in background

#

(optionally)

timber ivy
#

alright awesome what api did you use to do this?

rotund token
#

unity actually has a tutorial for this (never looked at it)

#

but it's just all from this package

timber ivy
#

Do you know if it supports 2d navmesh?

#

my world is 3d but its a top down on a flat level so I could in theory just make the navmesh 2d

rotund token
#

there's no specific option i don't think but if you define your components so only the ground is walkable and everything else blocks

#

it'll just be a single ground mesh

timber ivy
#

Alright thank you

#

So since I am just generating a surface around the player could I just attach a navmesh surface component to the camera or does it actually have to be attached to the geometry I am generating for?

rotund token
#

can be anything

#

CollectObjects use volume

timber ivy
#

ah yep thats the one thanks

timber ivy
#

do i just use this when I want to regenerate?

/// <summary> Rebuilds parts of an existing NavMesh in the regions of the scene where the objects have changed. </summary>
        /// <remarks> This operation is executed asynchronously. </remarks>
        /// <param name="data"> The NavMesh to update according to the changes in the scene. </param>
        /// <returns> A reference to the asynchronous coroutine that builds the NavMesh. </returns>
        public AsyncOperation UpdateNavMesh(NavMeshData data)
rotund token
#

that is async

#
        {
            var sources = CollectSources();

            // Use unscaled bounds - this differs in behaviour from e.g. collider components.
            // But is similar to reflection probe - and since navmesh data has no scaling support - it is the right choice here.
            var surfaceBounds = new Bounds(m_Center, Abs(m_Size));
            if (m_CollectObjects == CollectObjects.All || m_CollectObjects == CollectObjects.Children)
                surfaceBounds = CalculateWorldBounds(sources);

            return NavMeshBuilder.UpdateNavMeshDataAsync(data, GetBuildSettings(), sources, surfaceBounds);
        }```
#

it returns an async handle for you

#

nav mesh surface just provides a convenient wrapper for you

#

the underlying actual api if you want to write your own implementation
NavMeshBuilder.BuildNavMeshData
NavMeshBuilder.UpdateNavMeshData
NavMeshBuilder.UpdateNavMeshDataAsync
etc

robust scaffold
#

@rotund token Is this the right setup for a performance test?

rotund token
#

seems fine

#

i usually have my measures in separate methods

#

but whatever works

#

this might be nicer if it works

#

i am far from an expert on this package, there are a lot of tools in it that i am not familiar with that are probably really useful

robust scaffold
#

This is my first time writing unit tests so any knowledge is infinitely more than my knowledge

robust scaffold
#

Wow, performance test shows that PS operations is not always better: Another test shows 0 difference.

#

Ran it for twice as long. There is 0 difference

drowsy pagoda
#

Can someone give me a quick example on how to use ArchetypeChunk.GetComponentDataPtrRW()

robust scaffold
#

Yea. It's basically GetNativeArray<>().GetUnsafePtr() you see in IJobEntityBatch.

rotund token
robust scaffold
#

Imagine if unity code gen worked:

#

And it's gonna get even longer. That's only a circle.

#

Imagine, if unity provided an "unsafe" IJobEntity code gen job type. Instead of handholding users with "safe" ref and in parameters that break burst vectorization, they pass the raw pointers and let the user deal with the safety. For example, my Vectorized() method should be the Execute() passed by the code gen. Everything else is boilerplate.

#

Well, code gen for IJobEntity doesnt work on ISystem anyways.

robust scaffold
#

TRS to Local to World. Slightly more readable with the one shipped with DOTS.

#

Fully vectorized. The WithoutRotation is actually unrolled by burst.

rotund token
#

why are you rewriting all of this ๐Ÿ˜…

#

thought i was going to be 2d or something at least

rustic rain
#

hmm, is there a way to register generic component type through attribute to that generic type, not to assembly?

rustic rain
#

Fatal error. Internal CLR error. (0x80131506)

#

bruh

#

don't mess with generic components

#

or else you get this

#

bruuuh

#

I have no idea what's up, it appeared after I added generic component

#

but now it won't be gone

#

even after full library folder removal

rustic rain
#

all right, I went fully rogue with New Input System and burst

#

kek

rustic rain
#

I assume RequireSingletonForUpdate ignores Disabled tagged entities?

timber ivy
rotund token
timber ivy
#

Doesn't appear UpdateNavMesh works with volume surfaces

#

Its just building a one piece mesh the same size/shap of the ground ignoring any buildings x)

rotund token
#

Also how I wrapped it and exposed it to unity still let me take individual methods from the native library and rewrite them in burst over time

rotund token
#

You need to register what can be in your volume from memory

rustic rain
#

hmmm

#

having WAY too many systems is ok?

#

I talk about like 200-400

#

or more

#

With the way I decided to handle my Input

#

I'd need quite a lot of ISystems

#

to handle events

rotund token
#

we have about that many or more at work

#

main thread cost definitely adds up

#

strongly recommend making as many ISystem

#

imagine if they're only 0.1ms each

#

thats 40ms

#

or 25fps

rustic rain
#

hmm

#

they are quite faster

#

lemme actually check

rotund token
#

you say that now

#

but your project will get slower as you add more entities, systems and archetypes

rustic rain
#

actually they are not even running, kek

rotund token
#

usually 0.03ms is about as fast as SystemBase will run at for the most basic work

rustic rain
#

I forgot that they are reactive systems

#

that react on singleton events

rustic rain
#
        [BurstCompatible]
        public static bool ToggleState<T>(this EntityManager em, in Entity stateEntity)
            where T : unmanaged, IComponentData
        {
            if (em.RemoveComponent<T>(stateEntity))
            {
                return false;
            }

            em.AddComponent<T>(stateEntity);
            return true;
        }

On average my reactive input handlers will just run smt hlike this in OnUpdate

#

and only once trigger fired

#

meaning like once per 10 seconds or smth

#

so the most of my concern - checks whether that system should run

#
    [UpdateInGroup(typeof(LateSimulationSystemGroup))]
    [BurstCompile]
    public struct PlaySimulationHandler : ISystem
    {
        private Entity _playSimulationState;

        public void OnCreate(ref SystemState state)
        {
            state.RequireSingletonForUpdate<GalaxyLoaded>();
            state.RequireSingletonForUpdate<Performed<TogglePlay>>();

            _playSimulationState = state.EntityManager.GetOrCreateSingletonEntity<Singleton<PlaySimulation>>();
        }

        public void OnDestroy(ref SystemState state) { }

        [BurstCompile]
        public void OnUpdate(ref SystemState state)
        {
            state.EntityManager.ToggleState<PlaySimulation>(_playSimulationState);
        }
    }

here one example of such system

rotund token
#

your system is still running

#

in the sense it has to look at a query

rustic rain
#

(this is for starting/pausing game)

rustic rain
rotund token
#

simply checking if theres any entity in the query

rustic rain
#

hmm

rotund token
#

the Complete() that happens at the start of every system

rustic rain
#

I'd need to figure a way to group them

rotund token
#

that doesn't happen anymore unless the system actually runs

#

but yeah if you're doing this in ISystem

#

it won't be that bad

rustic rain
#

are such checks bursted?

rotund token
#

i believe its in a function ptr

#

but its actually cached as well

#

theres been a lot of work on this

#

they are certainly trying to build entities to support this number

#

via ISystem

rustic rain
#

if it was me who did it I'd make a one bursted check that generates array of bools, so later it just does simple bool comparison

rotund token
#

really hope they have some improvements to ComponentSystemGroup in 1.0

rustic rain
#

whether system should update I mean

#

so, you mentioned that ISystem does query check faster

#

hmm

#

is it actually check one by one?

rotund token
rustic rain
#

in sync?

#

as in

rotund token
#

all it does to check a query is

public bool IsEmptyIgnoreFilter => _QueryData->GetMatchingChunkCache().Length == 0;

rustic rain
#

can I literally see in profiler that timeline

rotund token
#
        {
            if(!MatchingChunkCache.IsCacheValid)
                ChunkIterationUtility.RebuildChunkListCache((EntityQueryData*)UnsafeUtility.AddressOf(ref this));

            return MatchingChunkCache;
        }```
rustic rain
#

when it checks whether system should run?

rotund token
#

if you have a valid cache all it's really doing is a bool check and an int check

#

it's pretty fast

rustic rain
#

wdym valid cache?

#

how to keep it valid?

#

no structural changes?

rotund token
#

yes structural changes will invalid caches

rustic rain
#

hmmm

rotund token
#

(another reason static archetypes are important for performance)

rustic rain
#

this is all part of my main thread fast system group

#

in which all I do are structural changes

#

hmmm

#

that's no good I guess

#

meanwhile implementing ECB will probably be not as good

#

hmmmm

rotund token
#

i believe it has to be a structural change that affects this chunk

#

but i assume you aren't doing these changes every frame?

rustic rain
#

nnnah

rotund token
#

only when you make game state changes

rustic rain
#

I also made a some kind of pattern

#

where I use one entity per

#

toggle state

#

as in EnabledTag is switched on and off

#

on one entity

#

while it also has some other tag, that says that this Entity is this EnabledTag holder one

#

singletons basically

#

Trade off of memory for perfomance I guess

#

kek

opal lynx
#

I am using ecs 0.51 with unity 2020.3 2021.3.5f1
and it shows same 6 messages but I don't understand why

how can I fix for these messages?

rotund token
#

You're using a class not a struct

opal lynx
rustic rain
#

hmmm, I wonder how I can implement dynamic building for required Query with multiple constraints

#

basically I have that same EntitySelectionSystem

#

and now it requires SelectionRequested singleton

#

if it exists, selection is performed and result is written to other component

#

but here's the thing

#

maybe instead of SelectionRequested I can implement a way to dynamically require any sort of components for selection to be performed

#

goal is that it can be done without changing types (since modders don't have access to adding interfaces to types)

dreamy glade
#

Is there any ways to have the entity manager itself hold custom data? I want to be able to reference a value that all components can read from. Thanks.

#

For instance, a global integer.

rustic rain
#

EntityManager is partial

#

you can reference assembly and add new fields to it

#

but I'm not sure

#

whether it's safe

dreamy glade
#

Then rather than an entity manager, how would you go about it?

rustic rain
#

I just avoid it as pattern

#

on the very low end

#

I use World for such modifications

#

it's managed anyways

candid epoch
devout prairie
dreamy glade
candid epoch
dreamy glade
candid epoch
#

There's a convenience method GetSingleton which you can use to get the entity before for each

dreamy glade
rustic rain
#

you can use this poggie woggie approach

#
        [NotBurstCompatible]
        public static Entity GetOrCreateSingletonEntity<T>(this EntityManager em)
        {
            using var query = em.CreateEntityQuery(ComponentType.ReadOnly<T>());
            return query.IsEmptyIgnoreFilter ? em.CreateEntity(typeof(T)) : query.GetSingletonEntity();
        }
#

so you just keep Entity reference

#

in any system you want to access some data

#

and anytime you need it

#

you just do

#

EntityManager.GetComponentData<PlayerInput>(_inputEntity)

#

in case if you need it in jobs

#

you can access it through ComponentDataFromEntity

#

but sadly for best efficiency you'd need to use IJobEntityBatch

#

but if you really just want static value

#

burst supports SharedStatic<T>

devout prairie
rustic rain
devout prairie
#

( i've never used or looked at those jobs )

rustic rain
#

getting that value in any job but batch

#

equals getting that value for every entity

#

meanwhile in batch you access it once for chunk

devout prairie
#

ah right

#

so with for each, probably the best approach is just get/cache the value to a local variable first, and then pass that into the foreach right

rustic rain
#

well

#

in case where you need it in loop

#

you are simply doing smth wrong

#

kek

#

that's kind of against the pattern imo

devout prairie
#

not sure why you'd say that, it's often necessary to get data from elsewhere and use it inside foreach

#

say for example deltaTime, or some global value

#

you get it in OnUpdate, store it to a local value, then use it inside foreach

rustic rain
#

well, for time they literally built that into World

#

unmanaged one

#

hmmm

#

do you guys know any way to implement this:

#

I have a special singleton entity, which is loaded from subscene/async

#

because of conversion

#

I need to convert it

#

can't make it manually

#

and so as result I can't get reference to that entity at OnCreate

#

meanwhile that entity is basically static, once loaded never unloaded

#

Is there any solution to this?

#

goal is to avoid Getting singleton in loops

devout prairie
#

sometimes if i can't get something, due to ordering with creation of systems and mono's and conversion etc, i just put a hack inside OnUpdate like:
if (systemFieldEntity == Entity.Null) systemFieldEntity = //get entity code//

#

so often just fighting with how and when things are created etc, easier to just do that, and then maybe later fine tune it

#

just my 2c ๐Ÿ˜›

rustic rain
#

yeah, that's what I avoid...

#

OnUpdate is bursted

#

getting singletons is not possible here

devout prairie
#

i'm not sure i get what you mean

#

you're only actually getting it once right

rustic rain
#

yeah

#

and I can't use unburstable methods inside bursted method

#

even if it's behind if check

devout prairie
#

how then would you get a singleton inside OnUpdate?

elfin spire
rustic rain
#

you are not copying large arrays tho

elfin spire
rustic rain
#

ah

#

that's not really what we talked about though

#

accessing data from jobs is equally troublesome

#

no matter if you use ECS or not

#

kek

robust scaffold
robust scaffold
#

Also, OnCreate() will get bursted when Unity finally makes entity query creation burst compatible.

rustic rain
#

huh

robust scaffold
#

Singletons were a pain point in 0.17. One of the improvements in 0.50 was burst compatible get singleton. Might be the only one in fact...

rustic rain
#

Is there an Entity journal yet?

robust scaffold
rustic rain
#

where you can see where certain entity was instantiated?

robust scaffold
#

Never used the journal before. So no clue.

rustic rain
#

@rotund token btw, I checked that approach of using DestroyEntity in order to clean it up from all components but system states
Here results:

#

every frame I destroy same entity

#

for 0.02ms perfomance

#

kind of curious whether I can optimize with query check

#

but I can't think of a way to check whether entity has any components but this

#

creating query with way too many component types also didn't really work

drowsy pagoda
#

Can I create BlobAssetReferences (that point to BlobArray wrappers) from within a Parallel job?

robust scaffold
#

You might be able to create and allocate Blob builders outside a job, send it into a job to populate, move it out and then finish it off with create references outside the job.

drowsy pagoda
#

I see. Thanks for that.

robust scaffold
#

My inspector is getting really really long. Anyone have any tips on either a custom inspector or something to compress it?

robust scaffold
#

18 components but each component is small:

gusty comet
#

I've just started to dabble with DOTS and I've noticed a convert to entity bool on the item inspector, is this meant to replace the ConvertToEntity script? if so, does anyone know where the API is to access it?

rustic rain
gusty comet
#

ok, so its a check-in-editor thing

#

?

rustic rain
#

pretty sure it's just Editor script that adds component to editor scene game object

robust scaffold
#

That button is a carry over from... 0.12? 0.9? Ancient.

gusty comet
robust scaffold
balmy thistle
#

Word

gusty comet
rustic rain
#

it fully serializes data

#

before you press run

robust scaffold
rustic rain
#

making loading way faster

gusty comet
#

sweet, im planning a hybrid approach first, gonna convert all the static geometry to entities for a start

#

do normal raycasts work on entities?

rustic rain
#

no

#

nothing

robust scaffold
#

It's just a surprisingly advanced DOTS feature. Not really something that a beginner to the land of ECS or Unity's flavor of it can easily pick up.

gusty comet
#

ah, special API for it?

rustic rain
#

separate physics package

robust scaffold
#

Join me in coding your own physics engine. Free from capitalism unity interference.

gusty comet
#

so i wont be able to detect ground or shoot walls or anything using standard raycasts? or even have access to API that enables me to? 0-0

rustic rain
gusty comet
#

unless i install physics that is

robust scaffold
rustic rain
#

a lot of things

#

A LOT

#

will have to be reimplemented from ground 0

robust scaffold
#

Are missing

#

Like rendering, if you hate the hybrid renderer like I do.

rustic rain
#

bruh

#

why so much hate?

#

even tertle's own fully bursted renderer had similiar perfomance as HR

robust scaffold
#

DOTS without HR = fast. DOTS with HR = slower than mono.

rustic rain
#

that's not true at all

gusty comet
#

i suppose i could use the seperated collider objects, since they are seperate from the ECS'd renderer, i can still detect the colliders using standard raycasts, I just wouldnt be able to do anything fancy like have specific sounds for specific surfaces.....

robust scaffold
rustic rain
#

pretty much anything Hybrid = pain, imo

gusty comet
robust scaffold
#

I tried with something as "simple" as 2D tilemaps. It's really clunky and slow.

#

So bad, I'm implementing my own 2D physics. DOTS integrated.

rustic rain
#

I decided to do pure ECS, so far I feel like it's the best decision

#

learning is though

#

but

#

I work on very simple game visually

#

so that might not apply to others, kek

robust scaffold