#archived-dots
1 messages ยท Page 45 of 1
i've found it really dependent on my library
and i think there is a correlation between number of scriptable objects that are referenced by subscene
though data is small and could be completely unrelated
i haven't changed authoring comps in a long time. maybe that's a reason it's mostly stable for me
personally i haven't seen any difference in frequency in any version between b6 and b14
all just fail as much as each other
haha
i've not seen any references to this problem in known issues
so that's a bit concerning
i wrote a little interface that let's me replicate baking at runtime
They know it exists. My bug report on some asset database bug got an internal marker for tracking to fix by the time it enters prerelease status. The known issues I think are for core module bugs in Unity. The stuff that ships with the editor.
i was finding writing unit tests really annoying with bakers
asset database is not core?
It is but it hasnt been a problem until DOTS decided to do fancy things with it
huh okay, i thought this is a global problem, not just related to dots
Has anyone outside of dots reported similar compilation problems?
no idea but then again i haven't even read about it in the dots forum
true... i wonder why
i'm pretty sure it's a core engine issue
it just manifests in the separate processes that baking uses
It's kinda blatant the bug when just creating a new file causes subscene corruption
were you making a repo case?
i have a 100% repo - recompile ๐
i have found i can minimize the effect of this bug by not coding bugs ๐
reduces recompiling
corruption as in gotta clear subscene cache or gotta remake the actual unity scene file?
Open the subscene, clear entities cache, close and reopen the editor, the close the subscene and enter play mode.
It's very convenient that unloading a scene (full scene) closes all the subscenes within it so I just need to unload the main scene and re-enter play mode to test instead of unchecking every single one of my subscenes whenever I need to go through this song and dance when I forget to close out of the editor before creating a new file. Incredibly annoying altogether and hopefully fixed sooner rather than later.
ah that dance. just downloaded b16 and hoping that has some fixes for that
Do Baking Systems work in the same way as Bakers on build the baking systems will not execute right? They run during build and that's it right?
yes baking systems only execute during bake
am i crazy does this actually exist? https://docs.unity3d.com/2022.2/Documentation/ScriptReference/Unity.Collections.NativeArray_1.ToArray.html
in 2022.2
why not?
has been here for a while
If it does I cant seem to access it
ToArray no longer returns a managed array according to the ide
And also takes in an allocator
๐ค
You have collections package?
yeah ofc
@robust scaffold thank you very much for your help. I solved my problem. I had everything right but I was not setting NetworkStreamInGame on the server-side for the client connection. I did it just on the client-side. Therefore it didn't properly started the connection. Do you have any site, where I can buy you a coffee? I would like to appreciate you were helping me.
How can I temporarily remove an entity from physics (like it never exists)? I intend to enable it again later. But I'd like to keep the entity enabled for quering other components
remove physics world index shared comp
o are you using this to bake entities for tests?
Nah, just make the best game ya can.
I found out that I have to use ComponentSystemBase.GetBufferTypeHandle instead, but ArchetypeChunk.GetNativeArray only accepts a ComponentTypeHandle, not a BufferTypeHandle, so what do I do?
Nevermind I just found ArchetypeChunk.GetBufferAccessor.
In a baking system i need to gather buffers from additional entities back to the main entity. unity is telling me that the lookup is defined as WriteOnly but i also read from it. Is there a way to disable this error? I can guarantee that there is no read from buffers i write to
Entity e, in NavModifierMainEntity navModifierMainEntity) =>
{
var subModifierBuffer = navModifierSettingsBufferLookup[e];
var mainModifierBuffer = navModifierSettingsBufferLookup[navModifierMainEntity.entity];
mainModifierBuffer.AddRange(subModifierBuffer.AsNativeArray());
}).Schedule(Dependency);```
or do i really have to use a different buffer?
@dense crypt i think you can just remove the physicsworldindex from it(just remember the actual value if you happen to have multiple physics worlds)
oh didnt see issue's post. gotta drink more coffee
Hey, Do you know how dependencies are resolved between jobs in the same system ? let's say i schedule one job after the other, will the run concurrently or one after the other ?
those will run one after the other
I'm guessing those are IJE?
if you want them in parallel, use Dependency property from state for parameter and store output jobhandle
and then assign that dependency property to JobHande.Combine of those 2
thanks ! yes thoses are IJobEntities
for clarification - take a look at codegen behind the scenes
it's in other part of this partial struct of system
good to know how to run them in parallel but i actually want them one after the other
@vernal cypress then just change the second job's schedule to depend on the first job
e.g. var starterJob = new NavQueryJob().schedule(Dependency); var disposalJob = new DisposalJob().Schedule(starterJob); disposalJob.Complete();
Yeah I don't create any runtime entities but I wanted to use the same collection of builders for setting up some unit tests that I do for baking
Oh are these PlayMode tests or Edit Mode tests btw?
edit
oh cool, do you think you can share how it's done? (I want to move away from creating the entities in set up to test some things)
is what my baker looks like right
{
/// <inheritdoc/>
public override void Bake(EffectAuthoring authoring)
{
var effectBuilder = new EffectBuilder(Allocator.Temp);
authoring.LifeCycle.With(ref effectBuilder);
authoring.Conditions.With(ref effectBuilder);
authoring.Stats.With(ref effectBuilder);
authoring.AddTagAuthoring.With(ref effectBuilder);
authoring.ModifyEffects.With(ref effectBuilder);
authoring.createEffect.With(this, ref effectBuilder);
authoring.General.With(ref effectBuilder);
var bakerConverter = new BakerConvert(this);
effectBuilder.Build(ref bakerConverter);
}
}```
and for example a test
public abstract class EffectTestFixture : ECSTestsFixture
{
// ...
public override void Setup()
{
base.Setup();
this.blobAssetStore = new BlobAssetStore(64);
this.EffectEntity = this.Manager.CreateEntity();
this.converter = new EntityManagerConvert(this.Manager, this.EffectEntity, this.blobAssetStore);
}
// ...
}
[Test]
public void CooldownDurationTest()
{
new EffectBuilder(Allocator.Temp).WithActiveCooldown(2).WithActiveDuration(1).Build(ref this.Converter);```
there's nothing crazy going on here
{
void AddBlobAsset<T>(ref BlobAssetReference<T> blobAssetReference, out Hash128 objectHash)
where T : unmanaged;
void AddComponent<T>()
where T : unmanaged, IComponentData;
void AddComponent<T>(in T component)
where T : unmanaged, IComponentData;
DynamicBuffer<T> AddBuffer<T>()
where T : unmanaged, IBufferElementData;
}```
just a tiny interface
and implementations for baker/em/ecb/ecbp
Can we use properties in struct to encapsulate in job system? and if yes, is it OK instead of simple public fields?
and do you know a priority queue implementation which works with job system?
you can use properties though generally not recommended except to present data in a specific way (i.e. avoid logic)
note properties won't appear in your inspector in unity
ohhh I thought it was more complicated - cool thanks
i don't have the will power to make it anymore complicated ๐
but it should make my tests much more maintainable
as i can update the various builders and the test will have correct data
my 1 issue with unit tests has always been maintainability
writing them is fine, but maintaining such a drag
inspector?!
I said I want to use that struct in job system
ok maybe i misunderstood what you are using properties on
Don't need inspector
is it the job struct not the component?
Yes
ok i read it as properties on components which is a common request
not sure i've ever had someone ask about properties on job structs
i see no reason it wouldn't work
though not sure i've ever seen anyone do it
For example, instead of changing a field and then write another line to set another field in the next line, change the second field inside the first property
The second field value is dependent
In job, Field A can change, so Field B value changes because of Field A (it is getter)
B= A+C
hmm this has a bit of a risk involved
if you're using a parallel job
avoid doing a ScheduleByRef if your storing state inside the job
also note that the same struct is re-used between chunks of work
Also, if there is a big array (readonly when executing a job but can change in different situation with low frequency), I should keep that array as a NativeArray persistent?
or when I want to execute a job, copy it and make a native array based on it
if you're changing it then i think its best to just keep it as a native array
especially if it's big
It is worth noting, a job works in a section of that 3d array, a 3d slice
It is a tile map
I am worried if I have trouble when I want to work with it as a simple array (OOP) because probably, I will use job only for some specific parts
nothing stopping you using the native array in OOP
if you need it in array[] for a specific API
you can make the native array from the [] and have them point at the same memory
@rotund token Thanks dude, I ask more in the future
private GCHandle handle;
private NativeArray<int> myNativeArray;
protected override void OnCreate()
{
this.handle = GCHandle.Alloc(this.myArray, GCHandleType.Pinned);
unsafe
{
var addr = this.handle.AddrOfPinnedObject();
this.myNativeArray = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray<int>((void*)addr, this.myArray.Length, Allocator.None);
#if ENABLE_UNITY_COLLECTIONS_CHECKS
NativeArrayUnsafeUtility.SetAtomicSafetyHandle(ref this.myNativeArray, AtomicSafetyHandle.Create());
#endif
}
}
protected override void OnDestroy()
{
this.handle.Free();
}```
myArray and myNativeArray will point to the same memory
if you change one the other one will be affected
this way you can use both a native array and regular array without needing to memcpy between them
just make sure you free the handle
What is the best way to have a Dictionary in ECS 1.0? I have a system that determines which objects need to spawn given a position. However, I need a quick way to determine if the object is already spawned. I would like to have a list/dictionary of items that have spawned, and be able to do if (!dictionary.Contains(spawnPoint)) SpawnObject(spawnPoint); or something like that. DynamicBuffer does not seem to support Contains, and I really don't want to iterate over every element in a dynamic buffer and check if (element.position == spawnPoint) found = true; or anything like that
NativeHashMap<TKey, TValue> is the dictionary in collections (also NativeParallelHashMap if you need support to write in parallel)
DynamicBuffer does not seem to support Contains
buffer.AsArray().Contains(X)
is one preferable over the other? is AsArray() okay to run every update?
AsArray is just a reinterpretation of the buffer
it's not a copy
it's as costly as looking up buffer[0]
you can cache it if you are doing multiple iterations/lookups
What is the most efficient way to create new entities? Spawning from a prefab using Instantiate, or CreateEntity with an archetype? Can you instantiate from an Aspect? I'm a bit fuzzy on the difference between archetypes and aspects
Spawning from a prefab using Instantiate, or CreateEntity with an archetype
they'd probably be the same
though spawning using instantiate might already set a bunch of values
which would be more efficient than having to set them yourself
so ideally you should be doing instantiates instead of create
I was wondering if ECS benefits from pooling objects for spawning
So for example build up a pool of x number items over several frames so they are available to spawn, rather than instantiate all at once
anything benefits from pooling
I guess ECS would benefit from that just the same
Yep
not really to OOP/ECS
I suppose GC is still a factor even within ECS, never actually considered that
How do I append to a singleton buffer? Getting "Invalidated by structural change" errors. I see that i can use ecb.AppendToBuffer but that requires an entity, and I have used SystemAPI.GetSingletonBuffer to get a reference to the buffer
as soon as any structural change happens buffer references are invalidated
at least by safety system
structural changes for a buffer only occur when the buffer exceeds the capacity, right?
structural change = entity/component add/remove
my code has not done any of that
doesn't it occur when the buffer location needs to change?
i'm not sure there's much benefit in pooling entities over instantiating
it's basically the exact same structural change
(assuming pooling is done adding Disabled)
the best way to instantiate lots of entities is EM.Instantiate batch overload
it's magnitudes faster than individual instantiation
yeah at some point you can reduce it down to the costs of memcpy
em batch instantiate is insanely fast
interesting
How do you mean?
I instantiate a lot of ragdolls, usually spread over a number of frames, but I think even one prefab with joints and colliders has a certain cost
Maybe impossible to avoid that in the case of prefabs with physics setups
What is the difference between an ECB and state.EntityManager? I have an ISystem and ecb.CreateEntity does not work in Update, but if I run state.EntityManager.CreateEntity, then it works
an entitycommandbuffer is a buffer you write commands to to execute later. so you need to have that buffer played back at some point else nothing happens
id still love advice on this issue : #archived-dots message
its probably some very easy solution i miss
ecb is mostly used to queue commands in (parallel) jobs. there are also other usages, when you don't want to wait for an ecb sync point and you create an ecb in update, queue some commands and then call playback.
not entities, objects
Is this the correct general pattern?
EntityCommandBuffer ecb = new EntityCommandBuffer(Allocator.Temp);
new MyJob { ecb = ecb }.Schedule();
ecb.Playback(state.EntityManager);
ecb.Dispose();
}```
then in the job you do ecb.createentity or what have you
also dispose it
i don't know for sure about the dispose. some weeks ago it was said we don't need to anymore (in ISystem) and my baking ISystem since then has no dispose call anymore. no leaks, although leak detection is not working anymore according to other posts. so, better save than sorry, and dispose ๐
My advice is but to use efe ๐
But I don't get where the write only is coming from
That nearly 100% of the time means safety not setup since no one actually marks writeonly
Can you show code outside job
Also you're using schedule
So you don't even need to disable parallel for safety
And why do you have it twice
I lost the circle thing next to the hierarchy to see systems and non-subscene entities. Does anyone know how to get it back?
This circle thing
Lost it?
I'd try just reimport entities package
Reminds me of the subscene script disappearing
why am I getting this error? using unity version 2021.3.14f1
also for some reason I was able to install an earlier version of entities (I think 0.51?)
nevermind, just had to use 2022+
Is there a good way to debug entity positions? Like Gizmos but for entities?
if you want a third party one, ALINE is pretty good: https://assetstore.unity.com/packages/tools/gui/aline-162772
i used to just record the positions and then later draw the positions with a Graphics CommandBuffer before switching to aline
Thanks, I'll check it out! Does it support ECS 1.0?
https://arongranberg.com/aline/docs/jobsystem.html You can use the command builder to record drawing commands which will be playedback later to draw
i usually mock it up with EFE and then change it to IJE as soon as it works.
once its disabled safety and the other is disabled parallel for restriction. i was just testing if one of those is helping in any way.
{
navModifierSettingsBufferLookup = GetBufferLookup<NavMeshModifierSettingsBuffer>(false)
}.Schedule(Dependency);```
```public partial struct CollectBufferModifiersJob : IJobEntity
{
public BufferLookup<NavMeshModifierSettingsBuffer> navModifierSettingsBufferLookup;
public void Execute(Entity e, in NavModifierMainEntity navModifierMainEntity)
{
var subModifierBuffer = navModifierSettingsBufferLookup[e];
var mainModifierBuffer = navModifierSettingsBufferLookup[navModifierMainEntity.entity];
mainModifierBuffer.AddRange(subModifierBuffer.AsNativeArray());
}
}```
thats the whole code. nothing else happening in that system with those buffers.
{
public override void Bake(NavMeshModifier authoring)
{
var additionalEntity = CreateAdditionalEntity(TransformUsageFlags.None, true);
AddComponent<NavMeshModifierSettings>(additionalEntity);
AddComponent<NavModifierMainEntity>(additionalEntity, new NavModifierMainEntity
{
entity = GetEntity()
});
var modifierBuffer = AddBuffer<NavMeshModifierSettingsBuffer>(additionalEntity);
var settingsCount = NavMesh.GetSettingsCount();
for (int i = 0; i < settingsCount; i++)
{
var a = NavMesh.GetSettingsByIndex(i);
var agentID = a.agentTypeID;
if (authoring.AffectsAgentType(agentID))
{
var navModifierData = new NavMeshModifierData
{
ignoreFromBuild = authoring.ignoreFromBuild,
overrideArea = authoring.overrideArea,
area = authoring.area,
affectedAgentTypes = agentID
};
modifierBuffer.Add(new NavMeshModifierSettingsBuffer
{
navMeshModifierData = navModifierData
});
}
}
}
}```
thats the baker that is adding those buffers to additional entities. i had the need to use multiple navmeshmodifiers on one gameobject. so instead of adding the components to the main entity i add it to additional components and later in a baking system combine them back to the main entity
Can you show me error
1 sec. entity header...
Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckReadAndThrowNoEarlyOut (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) <0x3c70f8718 + 0x0003f> in <fc0f0c704593490789be2e6908a1168e>:0
Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckReadAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at /Users/bokken/build/output/unity/unity/Runtime/Export/Jobs/AtomicSafetyHandle.bindings.cs:166)
Unity.Collections.LowLevel.Unsafe.NativeArrayUnsafeUtility.GetUnsafeReadOnlyPtr[T] (Unity.Collections.NativeArray`1[T] nativeArray) (at /Users/bokken/build/output/unity/unity/Runtime/Export/NativeArray/NativeArray.cs:1059)
Unity.Entities.DynamicBuffer`1[T].AddRange (Unity.Collections.NativeArray`1[T] newElems) (at Library/PackageCache/com.unity.entities@1.0.0-exp.12/Unity.Entities/Iterators/DynamicBuffer.cs:387)
AI.Comp.CollectBufferModifiersJob.Execute (Unity.Entities.Entity e, AI.Comp.NavModifierMainEntity& navModifierMainEntity) (at Assets/Scripts/AI/Comp/NavMeshModifierBakingSys.cs:167)````
the error happens in the line where i do buffer.AddRange
Do me a favour and change it to ToNativeArray and see if it still errors
My tile map is chunk based. I keep an array for each chunk. In some situations, I need to access several chunks for example in path finding.
I think maybe it is better to keep all of them in one giant array. So, the access is faster.
If I want to keep them separately, I should use NativeMultiHashMap and inside NativeArray?
World => Chunks[]
Chunk => Voxels[]
at how many crashes/needed restarts per code iteration are you guys? im close to 1
hmm i don't recall crashing recently
but close to 1 on subscene corruption
thankfully most of the time i don't care
yeah i'm not 100% certain here, something funny is going on
i didn't think writing to a buffer should invalidate other buffers
it's probably something like the secondary handle just not liking it
Hmm. Is entity chunk hashmap pre allocated with size of max value or gets dynamically reallocated on demand?
which hashmap are you talking about exactly?
Random access entity chunk array
sry i dont follow. its an array isnt it? not a hashmap
okay that statement confused me lol. In which case you think it has a max size? if you get the chunkarray and then loop over it you dont get empty entries in the array. its always the length of the available chunks for the query you specified
Chunks
Supposedly it'll be size of int.maxvalue
But that seems a lot
var chunks = query.ToArchetypeChunkArray(Allocator.TempJob); you talking about those chunk arrays?
really i try to find what you mean. but i cant.
any idea how this error is happening? : Invalid allocation label passed to UnsafeUtility::Malloc
i get this error as a followup : System::ArgumentException: Could not allocate native memory. Please report a bug. This Exception was thrown from a job compiled with Burst, which has limited exception support. #3 scripting_raise_exception(ScriptingExceptionPtr) #4 UnsafeUtility::Malloc(long long, int, NativeCollection::Allocator, ScriptingExceptionPtr*) #5 Unity.Collections.LowLevel.Unsafe.HashMapHelper`1<int>.Resize(Unity.Collections.LowLevel.Unsafe.HashMapHelper`1<int>* this, int newCapacity) -> void_e7f125cd1d9c91d6115fba1a3b491d17 #6 ForwardJobToManaged(ManagedJobData*) #7 ujob_execute_job(ujob_control_t*, ujob_lane_t*, ujob_job_t*, ujob_handle_t, int) #8 lane_guts(ujob_control_t*, ujob_lane_t*, int, int)
seems like resizing the hashmap doesnt work. but it shouldnt really resize anyways.
Hmm that makes no sense then
Dependency = new BuildSurfaceEntitiesMap
{
navMeshEntities = navMeshEntities,
}.Schedule(Dependency);```
public partial struct BuildSurfaceEntitiesMap : IJobEntity
{
public NativeHashMap<int, Entity> navMeshEntities;
public void Execute(Entity e, in AgentTypeID agentTypeID)
{
if (navMeshEntities.ContainsKey(agentTypeID.Value))
{
navMeshEntities[agentTypeID.Value] = e; //TODO atm only one navmesh per agentID is possible.
}
else
{
navMeshEntities.Add(agentTypeID.Value,e);
}
}
}```
Assuming you have confirmed only adding 2 you have some weird stuff going on
Is this at runtime or baking
runtime and yes i confirmed it
(probably shouldn't use tempjob anyway over world update allocator)
(doesn't stop the weirdness though)
Same issue without burst?
havent used that yet
When you think tempjob just think update allocator
not sure how to assign it
There's a shortcut in both system base and isystem
same but different. ill try to get the error. without burst everything is so insanely slow that its hard to repro anything
oh nice
I'm not as familiar with inner workings of new native hash map
And I'm not at home atm so hard for me to recall what it's trying to do internally
I did see an odd bug report about it though
ooh wait wasnt the old one actually renamed to nativeparallelhashmap or something?
its not something that is in a performance critical path anyways
oh god it works with the old Hashmap
i lost so much time already on this ^^ i didnt get that i was using a new one...
i think that solves some of my unity crashes i had too
cause crash report said something about the hashmap having 20 stackframes or sth
Yeah I don't know what's up with it
I haven't had any issues but I definitely saw a post about someone having a fundamental issue like this
Though I don't use that many tbh
Your case seemed very simple though
I'm still curious about the non burst error
ill try to get it
my first frame setting up everything literally takes minutes...
without burst
i really wish i could disable burst just for certain assemblies
it crashed this time with this Error: #0 0x0000010745d244 in block_merge_next #1 0x0000010536bae4 in DynamicHeapAllocator::Deallocate(void*) #2 0x000001053791c8 in DualThreadAllocator<DynamicHeapAllocator>::TryDeallocate(void*) #3 0x0000010536f6bc in MemoryManager::Deallocate(void*, MemLabelId const&, char const*, int) #4 0x0000010536f494 in MemoryManager::Deallocate(void*, MemLabelId const&, char const*, int) #5 0x0000010536d768 in free_alloc_internal(void*, MemLabelId const&, char const*, int) #6 0x00000104dd49e0 in UnsafeUtility_CUSTOM_Free(void*, NativeCollection::Allocator) #7 0x000002dcbda43c in (wrapper managed-to-native) Unity.Collections.LowLevel.Unsafe.UnsafeUtility:Free (void*,Unity.Collections.Allocator) [{0x3767cd870} + 0xb4] (0x2dcbda388 0x2dcbda4d0) [0x17644ea80 - Unity Child Domain] #8 0x000002dcd223fc in Unity.Collections.Memory/Unmanaged/Array:Resize (void*,long,long,Unity.Collections.AllocatorManager/AllocatorHandle,long,int) [{0x33b299988} + 0x37c] [/Users/tom/Documents/UnityProjects/ZombieRoad/zombie-road/ZombieRoad/Library/PackageCache/com.unity.collections@2.1.0-exp.4/Unity.Collections/Memory.cs :: 89u] (0x2dcd22080 0x2dcd22464) [0x17644ea80 - Unity Child Domain]
the stacktrace is too long to post it all here
another weird thing about it is that sometimes i can play for quite a while until the error happens. despite this beeing run every frame (not in final version ofc)
hmm i cannot reproduce that error with burst disabled. it just sometimes crashes but i cant identify the cause.
I upgraded an old project from 2021 to 2022 and now there's a million complaints about missing assembly definitions. I've updated and refreshed the cache of Unity packages but it's not helping. It can't find Unity.Mathematics which for sure is there.
try reimport the packages
I completely deleted the library cache and redownloaded them.
It's really frustrating, every few months I try to play with ECS again and the first problem I encounter is some bullshit about assembly definitions. Almost every time I've used Unity I've had some catastrophic and impossibly ambiguous issues with assembly definitions, even before ECS.
This code works fine in the older version but something about the upgrading pipeline destroys it
It's the same, complaints about missing definitions. I restarted Unity twice and somehow the second time resolved the assembly issues. The remaining errors are actual problems from the upgrade (api incompatibilities).
can i do a requireforupdate with an IJE without specifying the query?
lots of boilerplate id like to avoid
attributes
[WithAll(type)]
and etc
and on system you need to add attribute
[RequireMatchingQueriesToUpdate]
Might be a double free - how reproducible is that error?
RequireMatchingQueries would trigger an update as soon as any query is not empty. i would like to not update the system if one of many IJobEntity has an empty query
i dont know exactly how to get the error without burst enabled. the one with burst enabled pretty much happened every time.
Is there a way to limit how many entities a system processes at once? For example, if I have many entities and a heavy job, can I just run it on 10 entities at a time?
if it's entities job (IJE, IJC) then it will be split per chunk
Is there a way to limit it though? Using any of the IJob* interfaces? Could you only processes a single chunk at a time?
yeah
you can quite literally iterate chunks manually
but to use job system you'll have to go abit more complex
allthough, you can just use IJobFor
@covert spire i split up the work over multiple frames for my AI. every frame i choose 10 or so chunks that get to be updated.
I use manual chunk iteration with IJobFor like Issue suggested. Its not really complicated to get going.
thanks!
When I added the Unity.Physics package to my project it seemed to have completely removed LocalToWorldTransform anyone know how I can get it back? I want to use the Unity.Physics for collision detection.
physics is incompatible with transforms 2
Is there any alternatives that I can use?
no other physics for unity ECS
hopefully yet
Oh no I mean is there any other alternatives for LocalToWorldTransform that will work with Unity Physics
it uses old transform system
Cool cool thanks for the help ๐
Should have probably imported all the packages first xD. Now I have some refactoring to do
Does adding/removing tag components cause a structural change? I have a group of entities that go through various "stages" of their lifecycle and wondering the best structure for it. If each entity has say, an Enum with a State, then each system would have to process all of the entities, and check if (state == the one the system cares about), which is inefficient. Would it be better to add a tag component for each State and only have one enabled at a time, or have a tag component for each State and add/remove them from the entities as needed?
yes its a structural change. if you want to avoid structural changes but still want queries to work you can now enable/disable components in DOTS 1.0.
How you implement it really depends on how often your state changes. If you change it every few frames you enable/disable is probably the better choice. if it happens only once in a while you should add/remove components to keep the chunks sorted
Is enable/disable the only way to effectively get a where in an entity query?
not sure i get the question. enable / disable does filter out entities the same way add/remove would. it just does not incur a structural change. the entity still is in the chunk but is not processed by systems that use the enabledfilter
I'm effectively trying to do something like public void Execute(Aspect a where a.state == NeedsInitializing) in an IJobEntity
I know that I could make NeedsInitializing a component and then create a new aspect where it is required
lets say state has 3 different options. I have a system that processes entities that have each type of state
Would it be better to give the entities all 3 state components and only enable 1 at a time, or add/remove state components as needed? Is there a better way to filter out the entities of state X?
i would say there is no better way.
and see what i wrote above. it depends on how many statechanges happen. if its very frequent -> enable / disable otherwise add/remove
that beeing said if you have a lot of states AND you have frequent changes it maybe even better to check inside the system for the state and early out instead of having alot of state components. but that would have to be profiled
another option that would also lead to a structural change is having a shared component with the state enum and filtering after that
but i have no idea how performant shared components are now. it used to be a bad option to do this but i think it got massively improved by now
i havent worked with aspects at all but id imagine id not want to have new aspects just because of one single component that is there for only one frame.
Does this look like the correct pattern to you? WaitingToGenerateComponent implements IEnableableComponent
{
EntityCommandBuffer ecb = new EntityCommandBuffer(Allocator.TempJob);
new GenerateChunksJob
{
ecb = ecb,
}.ScheduleParallel();
ecb.Playback(state.EntityManager);
ecb.Dispose();
}
[BurstCompile]
[WithAll(typeof(WaitingToGenerateComponent))]
public partial struct GenerateChunksJob : IJobEntity
{
public EntityCommandBuffer ecb;
[BurstCompile]
public void Execute(Entity chunk)
{
// TODO do work
ecb.SetComponentEnabled<WaitingToGenerateComponent>(chunk, false);
ecb.SetComponentEnabled<WaitingToMeshComponent>(chunk, true);
}
}```
The idea is to then having a Meshing system do the same thing, do its work, disable the WaitingToMeshComponent, then enable the next state component
why are you enabling/disabling when it seems like you will ever do this once?
The states go in a cycle
that statechange wont occur often right? on the same entity i mean
I'm planning on reusing entities. So for example, when they are too far away they will "become" the next one that is needed and the cycle will start over
kind of like pooling i guess
and you expect to have an entity cycle through all states every few seconds?
Fairly often, yes
well i guess its fine then. but one of the real advantages of enabling / disabling is that you dont need syncpoints
you might wanna get rid of that
you don't need ecb to set enabled btw. set it directly with a componentlookup
i don't know if there's a chunk based solution
i think there is, just needs an IJobChunk then
a chunk based solution to the state switching thing or to the loadbalancing?
How is this?
{
ComponentLookup<WaitingToGenerateComponent> generateLookup = state.GetComponentLookup<WaitingToGenerateComponent>();
ComponentLookup<WaitingToMeshComponent> meshLookup = state.GetComponentLookup<WaitingToMeshComponent>();
new GenerateChunksJob
{
generateLookup = generateLookup,
meshLookup = meshLookup,
}.ScheduleParallel();
}
}
[BurstCompile]
[WithAll(typeof(WaitingToGenerateComponent))]
public partial struct GenerateChunksJob : IJobEntity
{
public ComponentLookup<WaitingToGenerateComponent> generateLookup;
public ComponentLookup<WaitingToMeshComponent> meshLookup;
[BurstCompile]
public void Execute(Entity entity)
{
// TODO do work
generateLookup.SetComponentEnabled(entity, false);
meshLookup.SetComponentEnabled(entity, true);
}
}
Or should I be using SystemAPI?
it really confused me there that you call your Entity chunk lol
Oh woops, its a chunk system haha
a what? ^^
Like minecraft chunks
aah
i havent really used enable / disable yet so im not sure if lookups are the only way to set these? cant you just set it from the ComponentData directly without indirect lookup?
Not sure, I'm looking at https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/components-enableable-use.html
use SystemAPI.GetComponentLookup<T> instead of state.GetComponentLookup<T>
What is the difference?
SystemAPI writes additional code. caches the handle in a private variable, creates in OnCreate and then just calls Update in the Update method. it's faster that way
and that's also the pattern for all handles.
SystemAPI.GetComponentTypeHandle is still missing but coming in 1.0 final
and you do that in create or update?
in update
{
generateLookup = SystemAPI.GetComponentLookup<WaitingToGenerateComponent>(),
meshLookup = SystemAPI.GetComponentLookup<WaitingToMeshComponent>(),
}.ScheduleParallel();``` this is how it would look then
not when you chunk iterate
cause you get access to the enabled bitmask right?
right. there's public readonly void SetComponentEnabled<T>(ComponentTypeHandle<T> typeHandle, int entityIndexInChunk, bool value) for example
in ArchetypeChunk
ah! alright. but requires boilerplate ๐ฆ
yep, i'm not aware how you'd do it in an IJobEntity. maybe there's a way but i've only seen code that uses ComponentLookup
thats something probably comming at some point
hmmm can't write to ComponentLookup in IJobEntity
what the error? maybe its not possible in parallel
This container does not support parallel writing
try disabling nativeparallelforrestriction
works just with Schedule() though
since you only ever write to your own entity you could disable safety
that seems to work also, thanks
here its fine to do. just take care to not cause raceconditions when you write from one entity to another.
Nope, didnt help, it's gone. It disappeared after upgrading to B16 if that is any help.
Rip
im on b16 and i still got it :S
Are you using netcode?
no
Hrm. Well, I can type "c:" into the search bar and it'll show all entities so I can get around this strange bug/feature at least.
wait a second. i thought you were talking about inspector
my hierarchy doesnt have it either
In the entities hierarchy, not regular one
both dont have it
This is what mine looks like, suppose to have a yellow circle next to the triple dots
Yea, okay good. It's not me fucking up the editor.
tbh i never toggled it there so i didnt notice
I got a bunch of buffers on system entities used for prepping rendering data so not being able to see systems is slightly annoying
Not quite as annoying at 0.51 bug where selected entities werent highlighted. That was unusable.
i hope unity is aware of this issue already
the editor useability is the main thing im looking forward to in official 1.0 release
I dont doubt they know this is an issue but I'm hesitant on sending in a bug report on something this obvious and I want them to focus on making the baker functional.
is it "normal" that clicking on things in Entities Hierarchy breaks them? like clicking on stuff with colliders causes the colliders to stop working :p
The physics getting disabled on selected entities? Yes, it's a known bug.
close your subscene
it's only an issue with subscene open
todays invention
DynamicLookup
or maybe DynamicEnableableLookup
i want to be able to set a ComponentType enableable state (without having <T>)
without a command buffer
basically
EntityDataAccess.SetComponentEnabled(Entity entity, TypeIndex typeIndex, bool value)
but adding a dependency to all potential components
Is this the correct way of writing to buffers from aspects?
Ah alright, got it thanks ๐
Is there an updated guide on how to get info from the ECS world from outside? Currently I need some info from the camera as a gameObject to follow the player and not sure how to move forward on that
World.DefaultGameObjectInjectionWorld.EntityManager
Editor: Console messages logged from Burst code now have clickable stacktraces.
2023 alpha, sweet.
they are pretty close there on 2022 with 1.8
so nice to see the final hurdle has been done
clickable but doesn't go anywhere ๐
Yea. I saw those in my code right now and checking the patchnotes of 23 alpha, it seems it actually works, soon.
oh wait
my burst jobs work fine for stack traces
its just my burst function pointers dont (ISystem OnUpdate)
but yeah i already get fully clickable burst stacks from jobs already
yeah i thought i was already getting these
Huh. I thought there would be more clickable links. Standard (unbursted) has a bunch of them. The root calling line is the important one though.
i have a couple of different types
not sure why they are different (there are 2 separate systems that call this job, but i have 3 different call stacks)
but yeah its not like execution of the job is actually from the system - it's just added to a queue
Also, has anyone tried out the new native render pass API in URP? It seems like an alternative way to render compared to command buffers.
Probably explains why I have multiple identical Debug.Log() text when I have the console set to collapse.
yeah these the bottom 2 are the same job/system
486+5376=5862
they should match as they run as frequently
Well, as long as the caller, in your case Timer.cs:82 are the same and easily / reliably identifiable, good enough.
yeah it's pretty useful
burst quality of life has definitely improved a lot recently
the breaking in it has been amazing
rarely need to turn burst off now
Yea. I dont think I've ever needed to turn off burst for any debugging now.
Does anyone know why "Multiplayer PlayMode Tools" is limited to 32 thin clients? I want to scale up to 100.
Random constant
I see, I was worried why the limit is set to 32. What is the reasoning behind it. i.e. if it means netcode supports only up to 32 concurrent players?
Nah, you can have more. Just use ClientServerBootstrap.CreateThinClientWorld()
Nice, thank you ๐
Question on practices: Do you store (or at least note) queries and archetypes somewhere ?
Like for the scenarios when you want to create/query specific entities, but you don't want to left out some components, or you don't expect anyone to know exactly what that entity must contain, or you want to have some kind of factory method that you can modify once for the whole project when you need that entity to have something more or less, etc.
I just edit the EQ Builder: Maps = state.GetEntityQuery(builder.WithAll<LightMap, LightVertices, LightActive>()); with what I'm looking for.
what is the builder ?
EntityQueryBuilder
I either store an archetype in the body of the system or just CreateEntity and add the relevant components
that can work if only that single system is the only one responsible for creating that entity
but in case of some kind of "event entity" that triggers certain behaviour and can be triggered by several other systems ?
Okay? Query for unique components on that entity for relevant systems and conduct work on the entities that match the query.
Entities are universal and not tied to a single system, systems query for relevant entities.
How does unity patch deferred entities not set via the ECB? For example, say I create an entity in a job with an ECB, and have a reference to a component, and assign an Entity field in that component to the deferred entity. How does unity replace it with the "real" entity?
Magic. Or negative indices that somehow gets mapped to the proper positive Entity when the ECB completes. Check the source.
Yeah I know the indices are negative, but I thought they are re-used between ECBs. I know there's a function to check if a component has any entity fields, so I'm assuming they're doing something along those lines. However, I am also too lazy to check.
it's actually surprisingly easy
the typemanager stores all the info you need
i do something similar for my save system, except map old entities to new entities
kind of like transferring entities between worlds
/// Gets a pointer to entity offsets for a given type index.
/// </summary>
/// <remarks>
/// This always returns a pointer even if the given type has
/// no entity offsets. Always check and iterate over the returned pointer using the
/// returned count.
/// </remarks>
/// <param name="typeIndex">The TypeIndex to review.</param>
/// <param name="count"></param>
/// <returns>Returns a pointer to the entity offsets.</returns>
public static EntityOffsetInfo* GetEntityOffsets(TypeIndex typeIndex, out int count)
{
var typeInfo = GetTypeInfoPointer() + typeIndex.Index;
count = typeInfo->EntityOffsetCount;
return GetEntityOffsets(*typeInfo);
}```
is basically the magic you need
but how do I see the entities created from bakers then? xd they're in the subscene in the hierarchy
what do you mean?
closed subscene is the final state of baking
you can see all the entities
i never have my subscenes open except when editing them - old habitat as netcode did not work with open subscenes in 0.51 or earlier
or do you mean in like scene view?
game playing with the subscene opened:
subscene closed is the experience you will get in a build
closing with the button "close" here:
the game now ^
what was in the subscene is missing (?)
oh, just noticed this error after closing the subscene:
Loading Entity Scene failed because the entity header file couldn't be resolved. This might be caused by a failed import of the entity scene. Please take a look at the SubScene MonoBehaviour that references this scene or at the asset import worker log in D:\Unity\resourcerer2d\Logs. scenePath=Assets/Scenes/MainScene/test.unity guid=83c65158b405a0847a1ea5baa4e581ce
yeah it hasn't baked
ok so that's the bug that is very unfun atm
basically requires a unity restart, preferences -> entities -> clear entity cache, reimport
what do you mean by reimport?
should be a button on the subscene that says reimport
alternatively just open, clear, close i think works as well
But does it just run over all components in the world (with an entity field)?
what do you mean by that sorry?
How does it know which entity fields to "fix"?
any component that has an entity field is cached in the typemanager
so it just needs to check if the data exists or not
So it just runs over all of them?
when you do a set|addcomponent
ecb is broken into 2 paths
SetComponent
SetComponentWithEntityFixUp
which one is used is determined at time of calling the command
{
if (op == ECBCommand.AddComponent)
cmd->Header.Header.CommandType = ECBCommand.AddComponentWithEntityFixUp;
else if (op == ECBCommand.SetComponent)
cmd->Header.Header.CommandType = ECBCommand.SetComponentWithEntityFixUp;
else if (op == ECBCommand.ReplaceComponentLinkedEntityGroup) //TODO DOTS-5586: Add support for component data with fixup
throw new ArgumentException("This component value passed to this command contains a reference to a temporary Entity, which is not currently supported.");
}```
not during playback
{
if (!TypeManager.HasEntityReferences(typeIndex))
return false;
var offsets = TypeManager.GetEntityOffsets(typeIndex, out var offsetCount);
for (int i = 0; i < offsetCount; i++)
{
if (((Entity*)(data + offsets[i].Offset))->Index < 0)
{
return true;
}
}
return false;
}```
it checks if the data exists in the typemanager, if not early outs
then checks each possible entity field and checks if it's index < 0
i.e. it's been added by command buffer
the caching of the offsets makes the whole thing quite fast and efficient
No, I meant the scenario where I don't use the ECB to set the component, and just write the deferred entity to a component by reference
And I think that that isn't actually supported
It requires the setcomponent on the ECB to "fix" the values from what I can tell, but I assume that's what you meant
yes
references wont be updated unless you use ECB
it will just have the virtual entity
and you will get an error saying entity wasn't played back blahblah if you try to use it
Yeah
I'm using a kind of weird workaround where I just read all entities in a job and them set them again, probably far from ideal but it works
2 separate ECB will both have the same -1, -2, -3 etc virtual entities so it's only valid within that ecb until its played back
They all have deferred values so it may even be faster than using the ECB a bunch of times
Yes, that's why I was confused how something like that could even be possible, turns out it isn't
Looks so dumb 
ahhh is cellData using the same ECB or something?
otherwise this ain't going to work
yeah, they basically all write deferred values directly to the component and then at the end this fixes it
this is the type of code you want to comment so when you look at it again in 2 years you aren't like wtf? delete ๐
haha, i made this exact mistake with an ecb.setcomp call that was patching some entity reference.
that's really easy to miss after some time
i was just like, why am i not setting this directly?
So I'm not seeing the LocalToWorldTransform in entities 1.0, despite the docs explicitly saying that this is the new way of doing this now. I see all the old LocalToWorld etc, but not the new one. I have the Unity.Transforms namespace referenced. What am I not getting here?
physics/netcode doesn't work with new transform system
if you install either package it will be disabled and use old transform system
Ah, wow. Ok. The issue I was having was when I remove parent, the item's global transform was overwritten by it's previous local transform. Need to manually overwrite after de-parenting. Or is there an easier way?
Using 1.0 and latest 2022.2.0b16. Did a build and it said it was built successfully, but before that it gives this error in console:
Failed to build EntityScene for 'Assets/Scenes/Main/Sandbox.unity'
Then when running the build, get this exception:
Loading Entity Scene failed because the entity header file couldn't be resolved: guid=5b6967bf99878714ab9b019f2db397f7.```
I went into the `StreamingAssets` directory, but the `EntityScenes` folder does not exist.
This is strange because before (on this same setup) I build and ran successfully without issues.
I just have a `Main` scene with a `Sandbox` subscene. Do both `Main` and sub scene need to be in the build scenes? Or just main?
your subscenes don't need to be in the build config
is your subscene closed and properly building in editor?
Thanks, I will try without subscene in build list. Didn't know I needed to close it, last successful build I didn't close scenes. Let me try this out.
you don't need to close it
but closing it will build the subscene in the editor
and well, if you get an entity header error
you know it's not building properly atm
and might need to restart/clear cache
ok. I'll try all of that out. Thx for the tips man. I really appreciate it
how to instantiate entity from prefab as additional entity in IConvertGameObjectToEntity? There is no Instantiate method in GameObjectConversionSystem and while trying spawn entities through EntityManager.Instantiate I get DuplicateEntityGuidException: Found 7 EntityGuid components that are shared by more than one Entity with all my 7 prefabs
still on 0.51 i take it?
umm
i think you can only be using CreateAdditionalEntity
no such thing in either 0.51 or 1.0
is there a way to easily inspect queued commands inside an ecb?
since 1.0 i got some weird spikes where one of my commandbuffers takes 12ms
Is that currently not possible to modify the data of buffer at idiomatic foreach?
error CS1654: Cannot modify members of 'xxx' because it is a 'foreach iteration variable'
thanks that works for now! for the future i would love to be able to inspect a single ECB and not all of them. debugging all of them costs me 75% of my fps ^^
Its the same for disabling burst for debugging. i do get all the info i need when i disable it but my game becomes unplayable. i would love to disable burst just for certain assemblies to specifically debug them
whenever i get a spike UnsafeUtility.Malloc and .Free are present in the ecb playback
the difference is 25ms vs. under 0.5ms
already a thing
burst gets disabled for specific job
as long as burst tells you which job generates the error i guess its fine. then i can disable burst for that job. maybe that is actually a non issue by now because burst debug messages became much better already. maybe its just an old habit of mine to disable burst entirely sometimes when i could just disable it locally.
there were cases in the past where burst couldnt tell me at all where the error comes from
Has anyone worked on an implementation for trail renderer in ECS? I have looked for it and haven't seen anything but wanted to confirm before implementing my own
I mean it's automatic process
as soon as you set breakpoint inside job
it gets unbursted for debugging
take a look at burst manual for explanation
omg i didnt know
How one should access IBufferElementData component in Aspect?
I know how to get another aspect or component but not sure how to access IBufferElementData component
try same way as normal comp
Unity.Entities.SourceGen.AspectGenerator\Unity.Entities.SourceGen.Aspect.AspectGenerator\PlayerAspect__Aspect_1407537409.g.cs(40,94): error CS0315: The type 'Unity.Entities.LinkedEntityGroup' cannot be used as type parameter 'T' in the generic type or method 'ComponentLookup<T>'. There is no boxing conversion from 'Unity.Entities.LinkedEntityGroup' to 'Unity.Entities.IComponentData'.
ah
just use it as a direct type
DynamicBuffer<T>
no wrappers
@rustic rain yo, thank you
Unfortunately I hit another snag. There is no SystemAPI inside aspect, so I have no way of access components of entities inside LinkedEntityGroup
I guess ill keep that piece of code inside the system
why not?
you don't need SystemAPI
I need it to check for component inside an entity that I get from LinkedEntityGroup buffer
I created a Physics Material Template. But when I go to attach it to a PhysicsShape, it gives me this error.
Is this a bug?
Did you read the message? Are you sure file and type name match?
I created the asset using the asset creation menu: DOTS>Physics>Physics Material Template.
Then I am not sure what could be the problem
Find physics in your project and right click reimport
There's been a few versions of unity that have had some odd asset issues
How should I go about getting a singleton entity from a monobehaviour? Right now I'm doing this but not working:
playerEntity = new EntityQueryBuilder().WithAll<Player>().Build(World.DefaultGameObjectInjectionWorld.EntityManager).GetSingletonEntity();
var playerPos = World.DefaultGameObjectInjectionWorld.EntityManager.GetComponentData<LocalToWorld>(playerEntity).Position;
I see thx for that. Iโll try it first thing.
@slow epoch whats the error? have you walked through the steps, like does the entity exist, does it have a localtoworld on it?
Not at pc to check but from memory don't you need to pass an allocator to entity query builder
it says there's no localtoworld, it's in update so it's checking all the time
But checking the inspector, I can see the entity with both Player and LocaltoWorld
also why does your query not have WithAll<LocalToWorld>
then you can just use GetSignleton<LocalToWorld>() instead of having to use EM
Fixed with the allocator and "WithAll<LocalToWorld>", cheers!
Also issue is I don't know where I can use "GetSingleton" besides SystemAPI
Alright, just so we're on the same page. In my Project window, I scrolled down to Packages and then down to Unity Physics folder, then right-click -> Reimport. Gave me the same error.
got to my PC
i can repo your issue
i don't understand why though - the script looks fine
ok got it to work by finding PhysicsMaterialTemplate and reimporting
just that script, nothing else
some really funky stuff going on with asset database
Yeah, it's unstable it seems, can't figure out the culprit.
Only other thing I can think of, and this is a very long shot, is that a plugin is interfering? I'm using Odin Inspector.
It's slowly breaking down entirely...
What's a quick way to get SharedComponent from a specific entity?
from main thread.
EntityManager.GetSharedComponent
Is there still no way to use a component lookup for a shared component?
nope
you can if you use my library
(someone asked for this a couple of days ago so I threw it together in 5min)
I wonder why Unity hasn't done it yet
with shared components finally being unmanaged they're actually usable now
Have the devs said anything about what the plan is going forward with the extreme entity size?
Very cool, thanks!
They said they have variable sized chunks on the todo list (think years down the line when dots is stable). Otherwise, use buffers, blobs, or break the entity up.
It's not really an issue for me right now, I was just wondering how they would address it
I think enzi and tertle already tested with different chunk sizes and it seemed to work relatively well
I mean, what are you sticking onto an entity that is ballooning it to 16KB or more?
Jesus christ.
i can beat that.
like 80% of those components aren't even mine
wait till you realize there is a cap on number of components this inspector can show
it's all unity's stuff
I really need to get rid of LEG and the physics stuff I don't use
You can set them to buffer size 0 (which makes them 16B). @rotund token, do you have that script?
I have it as well since that dev educated us all on the magic of pointers but yours is probably far better structured.
I hope they make a bunch of this stuff optional in the future
I also hope cleanup components can be baked in the future, that would also get rid of some stuff
I cant find Tertle's script in his repo but here's my copy:
Awesome, thanks.
You're gotta have to set up a bunch of internal exposing folders for it to work:
Is this not in Unity.Entities.Hybrid?
It's not even internal but for some reason I can't import it
What do you mean?
the assembly it's in
Oh, it's a custom assembly. CornExt.
That's the reason why you need the other folders.
Ah oops, I forgot to actually ask the correct question
I meant this group: LinkedEntityGroupBakingCleanUp
๐
I don't know how I forgot to put that part in my question
Uh, no clue what that is.
i got a very basic question... im new to reflection sry:
```if (Type.GetType(moduleType.Name + "Ref") == null)````
this never is true. i also tried assembly.GetType()
Also consider using halfs. Like health and stamina doesnt need 7 digits of precision. Halfs reduce it to 3 to 4 but that's plenty.
i need to codegen something if the type doesnt exist
Yeah I've not done any kind of optimization
iirc I mentioned this some time ago and you said the performance hit isn't insignificant ๐
(something along the lines of halfs are used for storage and not computation)
Yea... but 1KB an entity is just ewww
The thing is, this is the "normal" entity size
Anyone working on a regular old unity project that wants to use dots will run into this as soon as they import all the standard unity stuff
physics, netcode, etc
Starting unity is pain, give me a sec and let me see how big my entities are
pain
I don't think your project is indicative of the average user ๐
It's just a 20-620 lights and a player.
Yeah but you aren't using physics or netcode are you?
That's what I'm wondering. We don't even have all of the basic "game" stuff, and the entities are already huge. What happens once audio, animation, etc is in? 2 kb per entity?
I'll check once the buffers are smaller
Unity didn't like that
ArgumentException: LinkedEntityGroup[0] must always be the Entity itself.

re-bake fixed it
(which kind of makes sense)
if you download my library @misty wedge you'll get access to a window
that lets you set capacity of any buffer element
no need for code
nice
what version are you developing the library on?
Yea. Tertle's version has nice UI and added features. Mine is just a block of code and any changes must be hardcoded at the point in script.
i still have my original version which is attribute based -edit- oh wow this needs a code cleanup, seems i committed it mid changes
Huh, odd. The EditorWindow is failing creation for some reason
Ah, I see why. Nevermind, I messed up
Are you sure that's part of your core library? ๐
oh no it's not pushed to github/upm yet
once i merge 0.9 back to master i'll update upm/master
i'm pretty close to finalizing a 1.0 branch
as i need it for some libraries i intend to release soon
Do I clone it in the same folder I would normally put local packages?
yeah
I cloned it to standard assets earlier and it failed loading the UXML
Packages/com.bovinelabs.core/
I have high hopes that you will achieve my goal of 0 code in the OnUpdate() method.
A library to read my mind and instantly parse it into high performance bursted code will be a good start.
Very cool. Looking forward to that @rotund token
See, not hard at all. We're just asking for the bare minimum.
Serialization? ๐ 
yeah
thats the first
ive been very slow at writing documentation...
(also been pretty busy, our game content lock is in a couple of weeks)
Very cool, been looking forward to that
Congrats!
so when im off work, last thing i feel like doing is writing documentation
Understandable
Shit, this thing is falling apart at the seams lol.
I had some strange behaviour with Editor, so I closed everything, nuked the library and re-opened project.
Now my subscene can't load, it shows this in console:
Loading Entity Scene failed because the entity header file couldn't be resolved. This might be caused by a failed import of the entity scene. Please take a look at the SubScene MonoBehaviour that references this scene or at the asset import worker log in D:\Projects\Access\Logs. scenePath=Assets/Scenes/Main/Sandbox.unity guid=5b6967bf99878714ab9b019f2db397f7
So I looked into the logs, found this line:
Exception thrown during SubScene import: System.ArgumentException: Tried to serialized an Entity reference however entity reference serialization has been explicitly disabled.
Where do I enable this entity reference serialization?
Ok, here is another weird behavior.
When I register a prefab in the Baker via GetEntity into an IComponentData, it works fine, I verified that it indeed saves the right Entity reference.
However, when I register a prefab in the Baker the same way except into an ISharedComponentData, it references a Unity.Rendering.InstantiateDeformationSystem instead, which obviously gives me all kinds of errors being as it doesn't even have the basic transform components.
Is this a bug, or am I misunderstanding something?
this is basically the 1.0 broke state of entities
many of us get this every recompile and need to restart editor
clear cache
to continue
Yup, I found where to clear cache, once i did that, everything started to work.
Any thoughts on the Shared Component issue?
i dont think shared components support entity remapping
Ah ok. Just keep shared component data to primitives yeah?
You can use more than primitives
Hey. Is there a way to set constraints in DOTS physics for rotation like in classic rigidbody?
yeah, take a look at physics samples
it is a bit complex though
anyone of you know how to create a class via codegen and then afterwards create a scriptable object for it reliably? I do get the script and the asset at some point but never without errors getting thrown.
It seems like it is impossible to wait until unity can discover the new type file.
I tried AssetPostProcessor, AfterAssemblyLoadEvent, [DidReloadScripts], [InitializeOnLoad]... in every version the Type im trying to instanciate is not found by unity. but its there if i tab into rider... ```Exception thrown while invoking [DidReloadScripts] method 'UtilityAI.ReferenceGeneration:CreateScriptableObjectAsset ()' : NullReferenceException: Object reference not set to an instance of an object
UtilityAI.ReferenceGeneration.CreateScriptableObjectAsset () (at Assets/Scripts/UtilityAI/Core/ReferenceGeneration.cs:166)
The goal is to generate Scriptable Objects that hold references to IComponentData Types to be able to drag and drop references in the Editor and enable visual scripting with them.
I dont want to find the Types directly and serialize them since renaming such a type would break everything.
are you manually calling refresh?
yes after creating the .cs file from the template i call AssetDatabase.Refresh
whats weird is that i got another editor script where i do essentially the same thing which works fine.
public static void CreateScriptableObjectAsset()
{
if (dataInstance)
{
var newScrObj = CreateInstance(dataInstance.persistentName);
AssetDatabase.CreateAsset(newScrObj,
folderPath + dataInstance.persistentPath + dataInstance.persistentName + ".asset");
AssetDatabase.SaveAssets();
DestroyImmediate(dataInstance);
}
}```
this is called after an assetdatabase refresh and it creates the scriptable object without issues
How do i regenerate the system codegen?
[Worker3] Exception thrown during SubScene import: System.ArgumentException: ResourceEngine.FoodProducerSys+FoodProducerSys_3B57E52E_LambdaJob_0_Job must already be filtered by ComponentSystemBase or ISystem
@rotund token you might be interested in this. I think my Codegen Code calling AssetDataBase.Refresh is somehow exposing errors in the baking process for me.
maybe i can get rid of the entityheader breaking all the time by fixing those
which one?
i just deleted the whole library to get it done
interestingly enough the first bake went through without errors. after creating my asset and calling assetdatabase.resfresh i get errors again
Unity.Entities.BakerDataUtility.AddBaker (System.Type type) (at Library/PackageCache/com.unity.entities@1.0.0-exp.12/Unity.Entities.Hybrid/Baking/BakerDataUtility.cs:91)```
this one i have no idea what to do
and the one from above also reoccured. despite me rewriting it to an IJE too
When making IJobEntityBatch jobs I have the option to check for changes using DidChange on the archetype. The same option sort of exists on queries as well. I looked in to the ParentSystem and I see that Unity sets a change filter on the query, and also checks for DidChange in their jobs.
I suppose that a consumer of the job could forget to set the change filter on the query, and the job would ensure that it checks for changes first. But is there any other sort of pro/con to doing stuff "twice" in this sense?
Would WithChangeFilter be a good approach for listening for when new components of a type are created?
you use DidChange on chunks inside jobs and anything else on queries in order to avoid doing useless jobs
no, it's only checking whether values were overwritten
you need DidOrderChange check on chunks
The DOTS Physics package gets more and more annoying the more I use it. Does anybody have a solution for Objects with multiple colliders? E.g. hit zones?
Imho there should not be any need for a physics body at all in this case. But without physics body conversion just creates compound colliders ๐ฌ which does not make any sense if the sub colliders are moving and also makes it hard to figure out which one was hit
multiple colliders are meant to be combined with hierarchy
Yeah except when they are not. For example of the children are moving because of animation
If they where static they would not need to be children would they?
Is there any way to make [UpdateInGroup] conditionally? Fallback when the group is not enabled would be enough.
Background: I would like to prototype systems without multiplayer to see if the issue is coming from dots logic or network logic. Then maybe a button that will start a quick multiplayer and shows the behaviour of online mode. So using host solution won't help here.
I think I will have to make some bootstrap around systems, prevent auto loading and load them in the bootstrap when the condition is satisfied ๐ค
you can set up your very own system creation. Looking at class DefaultWorldInitialization would be a good example
this is all just regular baking issues
happens every time i recompile and manifest in 3 different ways
hm but i didnt get to those messages before. thats what baffled me
welcome to our world ๐
as far as i can tell, the baking is running too early with an our of date type set or something
i am really worried that played into my codegen issues somehow
i have no idea why it works now
maybe something got weird when they introduced the possiblility to multithread asset import
there were issues with this conversion as far as back 2020.3
i noticed in 2020.3 if you created a new assembly it would not appear in the bake process
until you restarted
in unities assembly list
i found that out because of this
{
if (!AssembliesMap.TryGetValue(asm.GetName().Name, out var uAssembly))
{
return false; // this happens in sub scene conversion process if a new assembly is added after loading unity...
}
return (uAssembly.flags & UnityEditor.Compilation.AssemblyFlags.EditorAssembly) != 0;
}```
private static Dictionary<string, UnityEditor.Compilation.Assembly> AssembliesMap =>
assemblies ??= UnityEditor.Compilation.CompilationPipeline.GetAssemblies().ToDictionary(r => r.name, r => r);```
the editor compilation pipeline in the conversion process wouldn't return a new assembly until restart
basically cached at startup
no idea if this is still an issue in 2022/1.0 i haven't tested
another thing in 2022 is it doesn't read the like asset cache
if you make a change to a scriptable object in unity, you can use that new value straight away without saving
but in the baking process if you access it will be the value on disk
very easy way to make a mistake
i'm actually considering removing all my SO
oh god i just hope for a reasonably fast fix. i couldnt do my tooling without ScrObjects
So you have to rebake after every scrObj change?
well of course you do if you make changes to SO that affect baking world
but the problem is, if you don't actually hit the save button the changed values won't be baked
it isn't that unintuitive it's just different to how the regular unity experience is
ah right. maybe ill just resort to saving in onvalidate then for now
i had something in my head about scriptable objects not retriggering baking when changeing
thought there was a forum thread about the dependency not working
they worked in 0.51
i do believe they might have been bugged in 1.0 for a time, not sure if fixed let me test quickly
though i can't 100% recall but i remember what you're talking about
yeah seems to work fine now
oh wait hmm, might only be working with an open subscene
yes i havent encountered any issues myself with them but i really didnt change too many values
yeah... only works if subscene open
hm and how do prefabs factor into this?
do prefabs get rebaked seperately from the objects in a subscene?
it really blowed my mind that an instance of a prefab inside a subscene is baked differently than a prefab itself
i had that issue with the linked entity group not beeing added
it's just not detecting changes in a SO
LEG is only added to prefabs
objects in a SS don't get LEG
(unless you add the script)
yes exactly. but that really caught me offguard. say i have a unit entity inside my subscene placed at a certain point. and an ability kills it. now if id rely on LEG to kill all children with id have a bug
but not with units i spawned into the scene later on
well i think subscenes are kind of designed to be static
because if you close/open it again it'll respawn
unless you use my save library which can handle this! ๐
runtime subscene state saving
yes i totally get it but i feel like its not communicated like that. especially when its now the only way to convert entities
most people trying to get rid of LEG, you're trying to add it!
its better than traversing a hierarchy to delete children lol
i dont think you can avoid hierarchies completly
then let me rephrase : should ๐
but i haven't had one in like 4
it's been peaceful
just never needed one in any library i've written
i think they're more gameplay related
i try to design without it but sometimes its just too convenient...
and really having the option to destroy a bunch of entities in one go is nice
the alternative is reimplementing something similar to LEG if you need to cleanup other entities after you destroy one
I have a concept in mind
where entities have a component with index to other entity
which contains array
instead of having whole LEG on entity
you might as well reduce leg size to 0 and have the same result
just seems like you're reinventing the wheel but making it square?
LEG does magic stuff under the hood with instantiate/destroy
you'd have to managed it yourself as manarz said about the alternative
i wonder if making a system have a write dependency on every IEnableableComponent is a bad idea
sounds sketchy
basically i have the ability to enable/disable components via effect system
but i got no idea what component users will set
and well the easiest solution is obviously to enable/disable via command buffer
and it's all safe
but being me i don't like that
instead I wrote an UnsafeEnableableLookup
which let's me toggle the enable component using ComponentType of any component
but I need to add dependencies to the system
and I dont know what components a user will toggle with the effect system so easiest way it just add all valid enableable components
alternative I can require them to be tagged with an attribute but that's a pain and means a developer has to do it for a designer
but yeah it's requiring a huge like semi sync point i don't like
i feel you. its really hard to give the user full control inside your packages
with their own components
its exactly why i did that codegen thing yesterday...
honestly i wouldnt like that at all. id prefer the attributes.
going to start looking ridiculous
[EffectTag]
[EffectEnableable]
[InternalBufferCapacity(0)]
public struct TestEnableable : IBufferElementData, IEnableableComponent```
whats the difference between discovering them with attributes vs implemented interfaces?
bad practice to have empty interfaces?
i dont discover from interface
i do since yesterday and i wondered what the difference really is
maybe reflection being faster with attributes or sth?
{
return false;
}```
i just use the typemanager for everything
already has the data
ah makes sense. i need to do it in editor tools though
as for your question, i think just thematics
imo attributes re more data oriented while interfaces object
but realistically makes no difference
oh wait i thought the TypeManager is something ECS does to manage mapping between IComponentData and Types
im total reflection noob here
i have a [StableHash] attribute
that i can put on any field
and have a bunch of rules
public bool OnlyZeroSize { get; }
public bool OnlyEnableable { get; }
public bool AllowUnityNamespace { get; }
public bool AllowEditorAssemblies { get; }```
been very useful
typemanager has all types, including classes etc
line 114
how i filter for this attribute
and is the typemanager something comming with entities or would i always have access to it?
TypeManager is from the entities package
okay atleast i got that right puh
this looks really nice. i like it more than looping through assemblies getting all the types :S
but thats the thing you meant is not updating when adding new types right?
no
assemblies aren't updating
well i guess
if (!attribute.AllowEditorAssemblies && type.Assembly.IsAssemblyEditorAssembly())
this check here isn't updating technically
if you create a new editor assembly
add a new component into that editor assembly
yeah it'll appear until you restart
(though i haven't tested this in a year, it might be fine in 2022/1.0)
okay that isnt so bad. i dont intend to start codegening assemblies
god i could look at your code the whole day and learn something new every 3 lines...
So you let the user add tags to effects(?) in editor?
and those tags are done by the user. so how do you serialize them in a way they would not break when the user renames them
they will break
ah that was a no go for my workflow
and then the baking will yell at them
and they will meekly revert their renaming
renaming components breaks saving
and requires a migration
which is not hard but developers are lazy
they'll learn they cbf
yeah all that is what i am trying to avoid going the huge detour with scriptable objects
might be a bad idea :S
im not actually sure how your scriptable object would help here
if it still needs to point to a component?
i could write a tool reasonably easily to update this data
my save system has a type database to store old stable hashes
so if they rename/add fields etc
they can figure out what the type was previously
then migrate it to the new type hash
i could probably automate this for effect config files since i dont care about data, only hash
but yeah... i'll look at that in like, 2 years
using Unity.Entities;
using UnityEngine;
namespace UtilityAI
{
[CreateAssetMenu(fileName = "#CLASSNAME#.asset", menuName = "UtilityAI/ComponentTypeRef/#CLASSNAME#")]
public class #CLASSNAME# : ComponentTypeRef
{
public override Type GetComponentType => typeof(#CONNECTEDCOMPONENT#);
}
}```
i codegen this for all IComponentData the user actually wants to use
oh that makes sense i guess
one added benefit is i dont need to worry about UI code
just a note
componenttypes are not stable between editor and builds
they will change on certain platforms
and between mono/il2cpp
if you are baking the component type that will break
yes thats why i codegen that
yeah but won't this be baked?
or are you reading the actual scriptable object in a build
wait let me think about this for a sec
im saying, your component type might be 1234 in editor
when you bake and make a build that is what will be saved
when you play the build it will try find 1234
and go, this component not found
we found this to fail about 3 in 500 times
not sure what makes a component differ
but anyway the solution is easy, just store the stabletypehash map instead of the componenttype
thats why it exists
it's guaranteed to be stable across platforms
you don't need to change like anything just add a
TypeManager.GetTypeIndexFromStableTypeHash()
sry my mind is just not really grasping it right now. i dont think i store the componenttype in any field while baking
what i do is using that componenttype to create generic systems
oh yeah thats fine then
if you aren't storing it in a component / on entity all good
i think im not having that issue. atleast i havent encountered any issues on other platforms for 2 years now
we encountered it mostly on consoles
okay i couldnt speak to that.
though windows il2cpp also had issue
but anyway yeah thats why the stablehash exists
its in TypeManager i assume
TypeManager.GetTypeInfo(t.TypeIndex).StableTypeHash
/// Hash used to uniquely identify a component based on its runtime memory footprint.
/// </summary>
/// <remarks>
/// This value is deterministic across builds provided that the underlying type layout
/// of the component hasn't changed. For example, renaming a member doesn't affect things,
/// however changing a member's type causes the parent StableTypeHash to change).
/// </remarks>
/// <seealso cref="TypeHash"/>
public readonly ulong StableTypeHash;```
the ) bothers me ๐
ah and with saving the hashmap you meant you create your own hashmap
wait if renaming a member doesnt change the hash why would renaming the type itself do?
changing a member's type causes the parent StableTypeHash to change
because it uses type/namespace as part of hash
ah damn
so that 2 things with same memory layout dont have the same hash
otherwise
struct component1 {int value}
struct component2 {int value}
would get the same hash
and you could only have 1 tag component in your project ๐
yeah i wondered how they would solve this but figured they have some internal variables to types maybe or sth. like i said i dont know nothing about reflection and the actual typesystem of c#
haha and you cannot even recover the Type by inspection of the members in ECS now since every member is just called Value
TypeHash.CalculateStableTypeHash
{
ulong versionHash = HashVersionAttribute(type, customAttributes);
if (hashCache == null)
hashCache = new Dictionary<Type, ulong>();
ulong typeHash = HashType(type, hashCache);
return CombineFNV1A64(versionHash, typeHash);
}```
if you're interested
it uses
HashVersionAttribute
HashTypeName
unity objects use their internal hash and early out
GetFields - ignore statics
and that's basically it
oh lets go from naming types with typenames to tagging them with unique attributes. ๐
what if you rename the attribute?!
well then use the Typename as a redundancy!?!
i hope noone changes both at once ๐
anyway that's how it all works
TUL ๐
still undecided about my original problem
i feel so much smarter ! another tool in my belt
remind me what started it xD i havent slept much
registering dependencies on all ienableable
the enable disable system
and alternatives
cant you let users define dependencies in the Editor?
subject to very badly breaking
if they forget
there will be no warning
they'd just be writing unsafely
i could just use a command buffer but ๐ฆ
maybe i can find a way to add a check
this might not be too bad
i can strip the check in builds
idk about them... its hard to avoid using them but holy shit they eat into my frametime
dont know if you saw me posting it but i got huge ECB playback spikes in 1.0 now
with unsafeUtility.Malloc and .Free calls seemingly beeing the culprit
spikes that are 25 ms compared to normally sub 0,5 ms
i use them pretty minimally
you might be able to only check in baking no?