{
var map = new NativeParallelHashMap<ulong, ComponentType>(64, Allocator.Persistent);
foreach (var t in TypeManager.AllTypes)
{
if (EffectUtil.ValidateTypeInfoForEnableable(t))
{
var componentType = ComponentType.FromTypeIndex(t.TypeIndex);
map.Add(t.StableTypeHash, componentType);
state.AddSystemDependency(t.TypeIndex);
}
}
return map;
}```
#archived-dots
1 messages ยท Page 46 of 1
i need to convert the saved stablehashes into component types
so i just make a map in oncreate
if i made this map from user supplied data it'd kind of just work
it is still a bit more workflow annoyance though
i guess i could take user supplied data + grab the data during baking
and make a final map
this way only runtime set components would need to be manually registered
everything else would register automatically
actually taking it from baking a bad idea, would be tied to subscene
i could find all prefab authorings at a bare minimum and auto populate
anyway something to investigate now
sounds like a plan though
currently i'm trying to get myself into the habit of using aspects
wrote my first, i intend to write a lot more
just something i've neglected in 1.0 as i had too much stuff to update
even though it was what i considered to be the most important feature
so time to start writing them
same for me. but i think i wait till others figure out some pattern to use with them
i have a feeling some people are overusing them atm
well i've used one, and it might already be in the overuse case ๐
haha and it broke my unit tests
oh wait no that's unrelated
forgot a NativeDisableUnsafePtrRestriction on some previous code
{
private readonly RefRO<EffectActive> effectActive;
private readonly RefRO<EffectActivePrevious> effectActivePrevious;
public bool WasActivatedThisFrame => this.effectActive.ValueRO.Value && !this.effectActivePrevious.ValueRO.Value;
public bool WasDeactivatedThisFrame => !this.effectActive.ValueRO.Value && this.effectActivePrevious.ValueRO.Value;
}```
what an amazing aspect
i am a little confused about how readonly / readwrite with aspects works. sounds to me like i will create alot of unwanted dependencies when i create aspects with too many components that need to be written to
i have saved 2 lines of code over 2 files and added 8 ๐
i am gonna predict your cause of death at some point will be ignoring safety
๐
there is no safety ignoring here
i just wanted a pointer to EntityDataAccess
for a custom Lookup
i actually take offense to this! i write my code extra safe
i am strongly against exposing anything unsafe to users
no user should need to touch a pointer to use any of my libraries
not saying you dont make your users feel safe ๐
i don't think you realize how many safety checks i have
i never bypass safety
i would rather my code ran slow
than to not be safe
okay i apologize! its true ive never seen any unsafe code from you. i only mean you live in unsafe lands
oh totally
i dont even dare going there^^
but funny enough i was just thinking this the other day
i haven't crashed my editor in months
i used to crash it frequently doing unsafe things
(my editor has crashed, just not my fault =D)
๐ my crashes vanished since i replaced the new NativeHashmap
yeah that was a bit dodgy
but yeah i've been scared by bugs in unsafe code (that others have written and i had to track down)
i spent 3 weeks of work tracking down a single super rare timing bug
im really interested in how you will use write access with aspects
1 step at a time!
i think for the most part though i'll keep my aspects small
just an easy way to ensure if i make a change to some logic it's propagated to all systems
yep and i totally see that working for reading. its a good feature. just afraid of having unintended write dependencies and essentially killing parallel execution for a lot of systemchains
it is an interesting point
i think i'd only add write access to an aspect if that's the purpose of an aspect
is having 2 aspects for 1 set of features that bad? hmm no idea
yes i was considering a write and read version of aspects... seems not that great
it could also add a bunch of extra dependencies you don't need
i guess the problems start when you have multiple components that can be written to in one aspect
take this
what if i only wanted EffectActive.Value
which is what i care about 90% of time
only 2 systems care about change of state
i guess i'd just use the component directly
oh you mean cause the system only interested in EffectActive now would have to wait for Systems that write to EffectActivePrevious
yep
and i just realized if i wanted both i should only pass in EffectActiveChangedAspect
so i've just explosed the underlying value
{
private readonly RefRO<EffectActive> effectActive;
private readonly RefRO<EffectActivePrevious> effectActivePrevious;
public bool IsActive => this.effectActive.ValueRO.Value;
public bool WasActivatedThisFrame => this.effectActive.ValueRO.Value && !this.effectActivePrevious.ValueRO.Value;
public bool WasDeactivatedThisFrame => !this.effectActive.ValueRO.Value && this.effectActivePrevious.ValueRO.Value;
}```
i guess this discussion is only really relevent for really highly parallized high throughput systems though right?
(which is what my effect library is)
im going to check how burst code gen differs
before i use this
since most of the time you have enough space on the workers to live with some jobs waiting a bit
as is my AI. I just mean that for most gameplay systems this discussion should not be had
oh yeah i agree
though im not too sure about how transform aspect is going to work
cause lets face it. gameplay is moving things around
yeah that seems like it's going to add a chain of dependencies
though i will probably just write a readonly version
literally copy/paste remove the setters
i'm much more often only reading
yep but i bet they (unity) will realize this problem too (if it is one) when doing physics
it'd be kind of nice if you could just do it with safety
unless it already works this way ๐ค
if you pass by in
does it just do a read only safety
i'll need to check codegen
yes as i understand it
because honestly that'd be the best way to handle it
not sure if it was mentioned in docs or in some forum post
annoyingly i currently have the opposite issue everyone seems to have
and my codegen isn't showing up in rider
everyone else is still doing EFE. that shows up for me
IJE shows too. sry
not sure if a unity or rider update changed the behaviour
but yeah all my ije show as unused now
i could have sworn i didnt see IJE the last time i checked
yes its unused for me too
dont show up in find window anymore
basically i can't browse to them unless i load up explorer
its probably because my source generators dont even appear
except
this one for some reason
oh wait no, they appear under analyzers not generators
๐คทโโ๏ธ
either way, can't browse to generated code for some reason
Huh, that is really odd ๐ค
not sure if unity or rider issue, but wasn't working in unity 2022.2 b14 and now b16
or latest rider 2022.2.4
hasnt worked for a few weeks at least
dont recall exactly when it stopped working
I mean it could be either, not unheard of in both cases. Tho i am curious what the MonoSctiotGenerator is, never seen that before and why that for some reason is also the exception to the rule ๐
well ok
i just fixed it
and now i'm even more curious so let me confirm why it's fixed
and they now appear in list as expected
yep
it doesn't like when i add the stylecop roslyn analyzer
it adds the monoscript generator back
(no idea what that is and why it's related to stylecop going to check)
and removes the generated code
hm but why am i seeing the same. got all the Generators inside Analyzers too. and i dont see a MonoScriptGenerator
i am doing a rider update first. lets see if its fixed then
didnt realize im on an old version for a while now
well i have a solution for those who want to remove the find on these ๐
i don't know if this is stylecop specifically on my analyzer library that auto adds analyziers to projects without having to go through unitys cumbersome way that i could not find a way to add .json based configs
after update it looks like this:
yep. just to understand all those analyzers are basically generators that didnt find something to generate?
i think a lot of those are actual analyzers
like, partial required on a system
kind of stuff
ah ok. was just confused why you said your generators where analyzers. first time i see them like this tbh ^^
oh yeah was my mistake
i was confused because i could see stuff there but not under source generators
and i was like, why are they appearing under that
@proud jackal i can tell you what is causing the issue
{
XDocument xml = XDocument.Parse(contents);
UpgradeProjectFile(xml);
// Write to the csproj file:
using (Utf8StringWriter str = new Utf8StringWriter())
{
xml.Save(str);
return str.ToString();
}```
making changes to project in a AssetPostprocessor
i'm only adding to the Analyzer and AdditionalFile xml, not removing anything =S
``` switch (extension)
{
case ".dll":
{
var reference = new XElement(xmlns + "Analyzer");
reference.Add(new XAttribute("Include", file));
itemGroup.Add(reference);
break;
}
case ".json":
{
var reference = new XElement(xmlns + "AdditionalFiles");
reference.Add(new XAttribute("Include", file));
itemGroup.Add(reference);
break;
}```
Going to investigate this further to see if/what i'm breaking
so now i the codegen is not appearing in my searches anymore. i like it
wtf the whole codegen looks completely different now
and i think i got around 10 fps more in editor 0.o i might be imagining things
these are only changes i made to the project, somehow it breaks it
oh wow it is not what i expected
it's failing purely from adding a .json to additional files
it has no issue with the dlls
all this json has is my header template
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"documentationRules": {
"companyName": "BovineLabs",
"copyrightText": " Copyright (c) BovineLabs. All rights reserved.",
"documentInternalElements": false
}
}
}
that's a super odd bug
i guess it's more likely to be the <AdditionalFiles /> than the json in particular
https://github.com/dotnet/roslyn/issues/60532
a quick search while probably not the same problem seems to imply source generators use additionalfiles in a weird way
So I have a managed component that holds various ComputeBuffers. Where would I Dispose/Release the buffers?
usually the system responsible for creating them
Where is Quaternion.Lerp in Unity.Mathematics?
math.nlerp()
is it bad practice to have components and authoring in the same file? it seems like whatever is in the component code is also in the authoring code, so wouldn't it make sense to put them in the same place for convenience?
hmm i'm not sure there would be community agreement on this
personally my authoring exists in an editor only assembly
baking is editor only so why should it exist in a runtime assembly?
so for me, no, components/authoring are always in different scripts
also i think you'll eventually find your components to authoring don't map 1:1
it's much easier workflow to have 1 authoring script setup an entire feature which is likely a handful of components
in which case you would start having, 5, 10, 20? components in a single script
thanks for the info, didn't know that things could be separated by editor/runtime
also, another question: aren't aspects sort of like classes? i'm watching an intro to dots by codemonkey, and the way he uses an aspect, i feel, is similar to a class. won't this sort of defeat the point of ecs?
No, because it's compositional, the components are still in the entity data store
there's an argument to be made that it encourages instance oriented programming, but I'm not sure that's so different with Execute() style jobs either
ultimately it's scaffolding on top of ecs which you can always "descend" if you want to make sure you're taking advantage of every amortization opportunity
bit of jargon in those 3 messages ๐ but I guess the takeaway is that it builds on top of ecs rather than changing its structure?
classes inherit from each other. Aspects are composed from multiple structs. That's about it
very far from oop
what is inner loop batch count for the job schedule method ?
its basically how much you want to split chunks into even smaller batches. only makes sense for jobs that are very heavy per single entity. its not even an option anymore in 1.0
it seems to still be there when scheduling jobs with IJobParallelFor
how come
cause IJobFor is not for entities only id imagine. so whatever you schedule there is not necassarily already split up into chunks
ah fair enough
kind've annoying mesh data is vector3 and not float3
have to make copies and alloc more memory every time i want to modify mesh data
you can reinterpret float3/vector3
no need to copy it
they have the same memory layout
i am trying to work out how to use those functions but not understanding them so far
NativeArray<float3> array = new NativeArray<float3>(1234);
NativeArray<Vector3> array2 = array.Reinterpret<Vector3>();
these point to the same thing in memory
changes to 1 will affect the other
first im trying to copy it to the native array like this :
var buffer = new NativeArray<float3>(_verts.Length, Allocator.Temp);
buffer.ReinterpretStore(0, _buffer);
``` but says vector3[] cannot be nullable
_buffer is my Vector3[] copy of the original verts array
yeah that doesn't work
but you don't need to do this either
var buffer = new NativeArray<float3>(_verts.Length, Allocator.Temp);
is memcpy
your code is just native to native though
mesh functions dont accept native array only normal array or list
here
i wrote this up for someone the other day
you can make a nativearray and a [] point to the same memory
so editing the nativearray will edit the []
no need to copy the array to native array
oh ill take a read of it ๐ thanks
how do you manage unmanaged system dependencies ?
let's say i want system A dependencies to complete before System B
@vernal cypress wont attributes do the job for you?
yes, i thought i had a race condition going even though i had the attributes turns out it was not a race condition
Burst has strict limitations (no managed code) but because of this can compile extremely fast code using LLVM
One of the things LLVM can do is auto vectorization of your code allowing you to execute 4+ instructions at once
So it adds in more performance to the unmanned code on top of compiling it to machine code?
Burst code is compiled to separate library and then called from managed code similar to c++ extern methods
Burst code is extremely fast if you code properly
It's perfect to process large chunks of data
On top of it you can use il2cpp
IL2CPP compiles with Clang (at least on Linux) which is also LLVM.
All major C++ compilers can autovectorize well anyway as far as I know.
But IL2CPP doesn't let you choose the target instruction set vector extensions I think so it probably uses the compiler default which should be SSE2 for x86-64.
Whereas Burst lets you generate a version of the code targeting AVX2 for example.
And I think I read that the vector and matrix struct types in com.unity.mathematics are replaced with compiler built-in vector types when using Burst.
So it's mostly explicit vectorization really.
How do I write to a NativeStream in IJobEntity? I need to use Begin & End Index but I can only do it once per index. Would it be fine to do a single write per index?
In IJobEntityBatch I could easily use the batchIndex.
mmm I'm trying to figure out how to use Interlocked.Increment on a field obtained through a ComponentLookup, and is unable to find examples...
seems like I need to use NativeReference, but that doesn't seem to do what I need?
You need to get the component by ref
Not ideal from a performance perspective to do 1 entity per index in a ns
Ns usually reserved for ijobchunk or ijobfor
However it'll be fine unless you are doing something extreme
Can we have NativeArray<NativeArray<int>> or I have to use MultiHashMap?
How can I install netcode [1.0.0-pre.15]? The package manager allows me just exp.13. I was adding it by name com.unity.netcode
// nvm, I just specified the version ๐ for some reason I was stuck on experimental version ๐ same for entities.graphics and physics, wow
Interesting, I just refreshed physics page and it shown 1.0.0-pre.15, is it released just now? cuz there is date from 16th November ๐
ah, 2022.2.0f1 is out 
is it? i dont see it in hub or website
unityhub://2022.2.0f1/1c1f8590be28
was trying to upgrade to 2022.1.23 from 2021.3.11 -- on entities 0.51 -- I'm not seeing anything get generated in Temp/NetCodeGenerated, even after running Multiplayer -> Force Code Generation and reimporting assets --- any ideas on what to check to get these files to generate?
easy solution, thanks
yep
was just released
I literally refreshed page and pre version appeared. I was soooo confused ๐
SystemAPI.GetXTypeHandle to easily get cached and .Update'd handles :3
haha :3
dani
Seems like dani wrote that lol
IJobEntityChunkBeginEnd - allowing you to run code at the start and end of chunk iteration.
wait what, you did it?! ๐
It will be a long night... TRANSFORMS_V2 - 1000 errors ๐คฃ
this is a good day
from what? archetype chunks?
i noticed there is a new ref version
yeah
Ahh ok cool
chunk.GetNativeArray<LocalToWorld>(ref LocalToWorldTypeHandleInfo);
seems to be what they're doing internally now
do i win
I had the same thing!! ๐ I'm fixing all errors in safe mode now ๐
at UnityEditorInternal.InternalEditorUtility:SaveToSerializedFileAndForgetInternal <0x000f6>
at UnityEditorInternal.InternalEditorUtility:SaveToSerializedFileAndForget <0x00092>
at UnityEditor.WindowLayout:SaveSplitViewAndChildren <0x0036a>
at UnityEditor.WindowLayout:MaximizePrepare <0x008b2>
at UnityEditor.WindowLayout:Maximize <0x00092>
at UnityEditor.EditorWindow:set_maximized <0x0018a>
at <>c__DisplayClass86_0:<WindowMaximizeStateOnDoubleClick>b__0 <0x000a2>```
you double click to maximize a window and next thing you've 'closed' it ๐
This is the future ๐
i find this weird
why is ref readonly not allowed
seems like it's just removing a layer of safety
Maybe there were a few breaking changes, so they wanted to make the changelog longer. ๐
๐ฌ
nevermind
SystemAPI.ManagedAPI
i forgot that was being added
this entities has everything i want
except default interface implementations for ISystem OnCreate/OnDestroy
deleted hundreds of lines of code in minutes
Parameter name: type
System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic, System.Boolean wrapExceptions) (at <8f06425e63004caf99a79845675f751e>:0)
System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) (at <8f06425e63004caf99a79845675f751e>:0)
System.Activator.CreateInstance (System.Type type) (at <8f06425e63004caf99a79845675f751e>:0)
UnityEditor.SceneTemplate.SceneTemplateAsset.CreatePipeline () (at <b1ffc38ca9d3409db9b51da2ce9185db>:0)
UnityEditor.SceneTemplate.SceneTemplateUtils+<>c.<GetSceneTemplateInfos>b__26_1 (UnityEditor.Tuple`2[T1,T2] templateData) (at <b1ffc38ca9d3409db9b51da2ce9185db>:0)
System.Linq.Enumerable+WhereSelectEnumerableIterator`2[TSource,TResult].ToList () (at <7e91c7d737f04acfa67ccef9a61afddb>:0)
System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable`1[T] source) (at <7e91c7d737f04acfa67ccef9a61afddb>:0)
UnityEditor.SceneTemplate.SceneTemplateUtils.GetSceneTemplateInfos () (at <b1ffc38ca9d3409db9b51da2ce9185db>:0)
UnityEditor.SceneTemplate.SceneTemplateService.UpdateSceneTemplatesOnSceneSave (UnityEngine.SceneManagement.Scene scene) (at <b1ffc38ca9d3409db9b51da2ce9185db>:0)
UnityEditor.SceneTemplate.SceneTemplateService.OnSceneSaved (UnityEngine.SceneManagement.Scene scene) (at <b1ffc38ca9d3409db9b51da2ce9185db>:0)
UnityEditor.SceneManagement.EditorSceneManager.Internal_SceneSaved (UnityEngine.SceneManagement.Scene scene) (at <73e8d78521f6493493e0128fd6894857>:0)
UnityEditor.SceneManagement.EditorSceneManager:SaveModifiedScenesIfUserWantsTo(Scene[])
Unity.Scenes.Editor.SubSceneInspectorUtility:CloseAndAskSaveIfUserWantsTo(SubScene[]) (at Library/PackageCache/com.unity.entities@1.0.0-pre.15/Unity.Scenes.Editor/SubSceneInspectorUtility.cs:204)```
first exception
doesn't seem to break anything
Yeah I think I'll stick to 0.51 on Unity 2021 LTS.
Has Rival been updated to 1.0 yet?
i don't use rival but I think you'll need to wait for updated samples from what i heard
Yeah I can't wait much.
I want to start working on the game by the end of this year.
And I'll work on it only for a few months.
oh fair enough if it's a short term project
we're sticking with 0.51 for our game full launch (and 2020.3 actually)
but we have ~1500 jobs so an update is likely never going to happen
Right.
anyone else getting
[Worker6] 1 entities in the scene 'Empty' had no SceneSection and as a result were not serialized at all.
1 entity not serialized
i'm getting this in an empty subscene
so only possibility i can think of is a baking system of mine was adding one but i disabled them all and it still happens
Has 1.0 pre come out?
Player stripping levels higher than minimal would fail to build with burst if they used String.Formatters, String Copy, or BurstDiscard.
Burst 1.8.2 from a few days back. Might be the cause of some IL2CPP builds breaking.
yes
oh no
i haven't had a corrupt subscene once
Oh yes?
though time will tell
and they snuck in my request!
IJobEntityChunkBeginEnd - allowing you to run code at the start and end of chunk iteration.
best day ever
Im checking the changelogs right now. I check burst every morning so I only saw... holy shit
Tertle for Unity CTO when?
You got my vote
and obviously
SystemAPI.GetXTypeHandle to easily get cached and .Update'd handles :3
ive deleted so much code
in just an hour this morning
Ugh, gonna have to make my way to the lab for internet...
oof
Support for RefRW<T>, RefRO<T>, EnabledRefRW<T> and EnabledRefRO<T> parameters in IJE
Actually pretty important as you can pull pointers from this...
oh i need to test if leak detection is working yet
A isReadOnly field (with default arg) to TryGetSingletonBuffer
Nice. That was annoying to get around in SAPI.
Curious about the new content management stuff in pre.15
oh it is
var leak = new NativeArray<int>(1, Allocator.TempJob);
jsut spamming a leak every frame
Wondering if it will work for referencing scene game objects from a subscene
IJobEntityChunkBeginEnd - allowing you to run code at the start and end of chunk iteration.
And that invalidates any reason to use IJC anymore. Sweet.
It wasnt working before? Although I was seeing leak warnings for Temp only.
or if its only for referencing assets and loading async
support for animation curves in component objects was kind of a random thing to see in the added changelog
well temp should never leak ๐
but no it hasn't been working for most versions of 2022
All they have to do is add the typeof to a giant hardcoded list.
I was getting temp leaks from leaving component types in the entity hierarchy search bar after disabling play mode.
there's definitely cases, but it'll get rid of 80% of mine
Optional components without an aspect maybe?
SystemAPI.GetXTypeHandle to easily get cached and .Update'd handles :3
Ha, that ":3" at the end, yea someone who frequents this discord definitely wrote that.
yeah sometimes i prefer to write 1 job with separate Has options instead of X separate jobs
Hmm, didn't see anything in the changelog for disabling IEnableableComponents in bakers. And no fixes for aspects.
it already worked
it just didn't work with open subscenes
because there was no differ (i think that was the problem)
yeah I meant for open subscenes. I'll have to test
The only IJC I have right now is one with optional components and a custom extension to pull only a specific component's enabled bit v128 instead of getting merged into the query wide enabled state parameter.
I'm hopeful that this content building stuff can be used for a nice hybrid workflow
1 is doing a whole chunk memcpy
WorldUnmanaged.CurrentTime renamed to WorldUnamanged.Time
What? Hopefully that's a typo.
var effectActives = chunk.GetNativeArray(ref this.EffectActiveHandle);
effectActivePreviouses.Reinterpret<bool>().CopyFrom(effectActives.Reinterpret<bool>());```
so that isn't going
Theoredically you can do that in the the begin execute section and then not have anything in the main Execute().
that's true
but i'm not sure why that'd actually be better ๐
i'd still have same overhead of passing in handle
Getting chunk count though is gonna be difficult and roundabout. So yea.
yeah i think in this library i can only remove 3 of my remaining 8
but those 5 are very specialized jobs
anyone using unity 2022.2.0b16?
2022.2.0f1 is out
oh
Renamed the DOTS Hierarchy window to Entities Hierarchy.
Renamed the DOTS sub-menu from the top-level Window menu to Entities.
Renamed the DOTS section in the Preferences window to Entities.
Huh, going back to Unity ECS? It's a full circle now.
it kind of makes sense
jobs/burst were in their own windows
and they are dots
so what really was the dots preference window, it was just entities
ah
seems like this is the package that updates physics to the new transform system
IJobEntity scheduling calls now can contain calls to SystemAPI calls and other JobEntity scheduling
OH MY GOD!!!. WOOOOOOOOO
yep lines deleted
wait, is it? I didn't see much in the physics changelog
Can system API be used inside IJE now? I think i skipped over something that said that and I cant find it anymore
i dont either but an example from the docs shows use of LocalTransform and all my translation rotation code is broken in my project ๐ฅฒ
imagine rotating. embrace sphere life.
Has havoc been released with this pre?
Yes. Huh
says in the docs if you dont own pro or industrial, physics wont work in editor or runtime
hmm yeah it does look like they added a few "ENABLE_TRANSFORM_V1" branches to the physics code. I'm surprised their aren't more diffs actually.
Havoc?
also GameObjectConversionSystem seems to have been removed, got a lot of disableautocreation for those but gotta just prune it completely now
Licence warning pop-up: adding the com.havok.physics package in your project without the Unity Pro, Enterprise or Unity Industrial Collection license will prevent you from simulating Havok Physics in the editor and builds.
Huh, I guess they removed the free tier then.
i didnt even get around to testing it in exp or trying out any of the aspects(or the replacement for EFE), so many things to upgrade!
@robust scaffold yeah, sucks ๐ข
they did say that
though most people seemed to refuse to believe it ^_^'
i was hoping it was a miscommunication
Does the student pack count as pro?
Because at this rate, I'm gonna be a terminal student...
Wow, totally missed the ColliderAspect in the physics package
winning
I've been using the free tier this entire time though perfectly fine. And with 2D physics, I dont think havoc will really help in any way
but it's cool and exclusive
I can flex on the poors with my $40k student loan debt.
Oh no, looks like netcode supports transform v2. How in the world am I gonna convert the existing custom serialization code for V1 to V2 for 2D transform components.
You can disable v2 still
exception thrown by the hierarchy window if a scene entity does not have a SubScene component.
Nice. That always broke my thin client viewer.
Nah, I'm gonna have to convert to V2 anyways. Might as well do so now
i will be honest though
i am slightly concerned about the archetype size of this new transform system
IIRC L2W is optional? And 64B is 4x4 floats.
Yeah:
The new tag component PropagateLocalToWorld must be added to any entity which needs its children to inherit its full LocalToWorld matrix, instead of the more compact WorldTransform representation. This path is slightly slower, but supports additional features like PostTransformMatrix (for non-uniform scale), and interpolation by the Physics and Netcode packages.
Ah, not optional for those using the P&N packages...
yeah just saw that part about interpolation
Physics itself doesnt seem to have changed anything.
rip transform v1, i will miss that giant docs page that I admire someone had to suffer through and put together, complete with the ascii art representation
Honestly, thought it'd be worse
what happened to staticoptimizeentity ๐ค
Dead. Replaced by transform flags in baking.
yeah but the component could just nicely set the flags for me
instead of me having to write a new one!
Right, I think that's all the changelogs. Gonna head to civilization for fiber optics to download prerelease.
Todo list: TransformV2. Convert some of the last holdouts of IJC to IJEBE. See if baking actually works. Remove Distance Importance scaling (been broken for a while).
I dont quite understand why you have a LocalTransform component that has float3 float and quaternion for pos scale and rot, but isnt that kind of duplicated with the LocalToWorld's 4x4(and setting TRS.float4x4(pos,rot,scale)?
couldn't be found in the SystemRegistry. (This is likely a bug in an ILPostprocessor.)
nooooooooooooo
oh local transformations i guess
Yes but in L2W, rotation and scale are mashed together and expensive and kinda inaccurate to separate.
it's still happening
I think that's the netcode bug problem. Does it corrupt subscenes?
i dont have netcode in this library
it didnt corrupt my subscenes
i just couldn't bake it anymore
with those systems listed
Editor restart needed then?
it did
we'll see if it happens again andi 'll experiment
first time in 2 hours though
so ah, that's at least a huge improvement
see the problem i have with this seems to be
it just adds them by default and anything but manual (remove all) does nothing
Fantastic. no more needing to restart on every edit.
I think the flags ATM are still broken because it's suppose to add LTW only if the LTW flag is enabled.
I think, that's what I saw in the src back in exp land.
Latest is broken for entities which is annoying because I have that link bookmarked
getting an error but dont know the cause or how to fix it... :
Burst error BC1002: Unable to find interface method `IBezier.Lerp(System.Single& modreq(System.Runtime.InteropServices.InAttribute))` from type `object`
it occurs when i open unity - but i can clear the console and i never get the error again
very strange
it also wont take me to a line of code when i double click it
but i think i know what line it refers to
its an interface but my method restricts it to struct for the generic
If it's not persistent, I think it's fine to ignore...
should probably be unmanaged not struct
but it just seems like a generic issue maybe?
where T : struct, IBezier is what i have
ill try unmanaged didn't know that was a keyword
yes but a struct can have a class on it
where T : unmanaged, IBezier
public struct MyStruct {
public MyClass Class;
}
it won't actually fix anything unless you get a compile error
what is the error actually trying to tell me
it won't change how burst behaves, just make it so you can't accidently break it
what version of burst
how do i check ? i didn't install a package for it. im on 2022.1 so i dunno if its just built in ?
no just jobs
it'll probably be 1.7.x i think
maybe
ok i fixed it
seems every function that received IBezier has to be generic with unmanaged
kind've tedious but at least it resolved the error
so uh whats the replacement in transform v2 for euler rotations?
quaternion.Euler()
But that's not new
but if you want to always keep something in euler format? i gotta make my own mini euler component now?
Yeah I guess. But wasn't that the case in v1 as well?
no? you could have a float3 euler component that would auto get "baked" into a quaternion during runtime
i thought the whole pre rotation and post rotation for adding little modifers was also kind of novel and cool, in fact if v2 doesnt handle any of this stuff im actually super underwhelmed by it
It's a more constrained system
Oh I see, this is one of those advanced things that was described on that really long doc on the old transform system. Yeah, I never used any of that stuff. I guess now you have to write code like SetComponent(LocalTransform.FromRotation(quaternion.Euler(...)).
Converting back to euler angles to read would be a pain though
But at least now you can write an Aspect to hide all of this with a nice api
perhaps, but felt like maybe the entire ordering of data transformation/jobs might be important to the transform process, which now is my responsibility to intercept and modify? i feel like that old page really was long winded and not the best explained but it wasnt advanced at all, and that whole system was incredibly useful for me as I am quite terrible at maths outside of using helper functions
Well the new helpers in ITransformData.cs are very nice. Quite similar to the UnityEngine.Transform api.
So now you can do stuff like localTransform.InverseTransformRotation(someRotation)
Don't have to do any math.mul() calls yourself
Last I tried, it complained about the codegen types that are created for IAspect. In theory, it should work fine. Might be fixed in this release but haven't tried yet.
Actually, they might work. I was thinking of how IAspect.Lookup can't be used in IJobEntity. Or at least it couldn't in earlier 1.0 versions.
docs only show example for IJE, and on first inspection, transform systems seem to use regular typehandles. oh well maybe just as well, gotta fix all these errors first
Huh, a dev blitz for dots specifically, neat.
This place is gonna get really noisy on december 8th
We're gonna need to start pooling questions. Im still overwhelmed by 1.0 pre so I got nothing
gotta think up good issues, last blitz thing I only saw during the day so completely whiffed on a chance to ask pertinent questions
Weโre progressing towards a highly performant, customizable 3D animation system that leverages data-oriented technologies
Seems like DOTS 1.1 will be animation
- What is the status of hybrid components beyond that explicitly whitelisted by unity?
- Has there been any effort within unity to resurrect Tiny from the dead, or at least brush up the experimental graphics API that allowed DOTS direct sprite rendering?
- Any consideration to expanding the maximum entity count per chunk to 256 using v256 as enabled masks?
- Can the Hybrid Rendering / Entities Rendering team please provide an example where they synchronized GPU execution to follow CPU write using a compute buffer BeginWrite() in a job?
- There's no current plan to extend that list, although we're actively discussing alternatives.
- It's not a current priority.
- That's definitely a possibility, not in the current round of optimizations we're trying out.
- I'll get back to you.
If they ask what you're talking about for #4: https://forum.unity.com/threads/computebuffer-beginwrite.1252560/#post-7967319
Yea, just those 4 questions. IJobEntityBeginEnd pretty much fills in the codegen hole I wanted for IJC. The problems Im experiencing now is purely rendering and how DOTS just does not like to play well with custom rendering code style.
@balmy thistle re: 2) ok tiny specifically as a small lightweight runtime isnt a priority but does that also cover native 2d entities packages?
My best recommendation if you're interested in 2d (or anything in particular) is to submit it via the product portal: https://unity.com/roadmap/unity-platform/dots
Oh my god, they listened to me. No more LocalToWorldTransform, it's only called LocalTransform. I might be able to slot this comp type handle with other components without Rider's vertical alignment making everything ugly.
@robust scaffold ooo oo where did you see that mentioned about animation?
literally such a key package for me
At the very bottom. Nothing explicit but it looks like animation will be the next major push
Since I do everything 2D, I think this DOTS release is pretty much the final exciting build for the near future. Gotta have to roll my own solutions for everything now.
I wonder, does unity recommend using the transform aspect or directly accessing the transform components?
well, i suspect they'd recommend using the aspect
you are adding extra dependencies though potentially if all you're doing is reading
yop
Hrm, true. Most of the time I just need position and maybe rotation. Rarely scale. That's all inside one component LT now. WorldTransform is highly recommended to be readonly and LTW has always been.
I dont think there's any additional dependencies being added when using the transform aspect compared to direct accessing LT.
@safe lintel These are in euler rotations.
What?
Sweet
yep
some of the lines i got to delete
one thing that's left is how can i query an aspect with SystemAPI?
or have i overlooked something
I was wondering that as well. Can I just add TransformAspect to the builder?
doesnt work
says not valid
it seems i need to use EntityQueryDesc still via GetEntityQuery
Oh well, I guess LT works.
based off what i saw IJE codegen
{
All = ComponentType.Combine(
new[] { ComponentType.ReadOnly<TestComponent>(), },
Unity.Transforms.TransformAspect.RequiredComponents),
});```
kind of thing
also not burst compatible ๐ฆ
Huh, so the code gen'ed on create for IJE isnt bursted?
Oh, it's an array. No burst allowed.
yep
Oh, question 5: Will there be a AspectLookup<IAspect> type? I know there's the IAspect.Lookup but it sticks out like a sore thumb surrounded by ComponentLookup and BufferLookup variants.
Sounds like no when I asked a few weeks ago: https://forum.unity.com/threads/pain-points-with-aspects-and-ienableable-components.1355639/#post-8555357
Unity Forum
Finally got around to trying out the new Aspects and IEnableable features. I think these are some of the coolest new features added in 1.0. I'm still...
Oh yea, I felt like I saw that question asked somewhere else as well.
That's on our radar but we have to do some extra generator magic to make it work since c# does not support static interface.
Without generator magic, you would have to writeAspectLookup<MyAspect, MyAspect.Lookup>, which kinda defeats the purpose.
Oof, shame.
What is TransformAspect.Query?
Doesnt exist?
It's for the Query<TransformAspect>()
Ah yeah yeah
Anyone know how unparenting works in transform v2?
Does it update the local transform to match the world transform? Or do we still need to manually edit stuff to avoid things teleporting?
It's beautiful.
I think unparenting is removing the entity from the child buffer right? It's up to you to make sure the local doesnt wildly alter world when you unparent.
Yeah, that's what it looks like from a quick look through the code. Was kinda hoping that they would have provided a ParentAspect to handle gracefully unparenting or changing of parents. I wrote my own for v1 so I'll just need to port it.
At least ParentTransform is automatically added and removed when adding or removing a Parent. So many times I was scratching my head wondering why the parenting wasn't working, only to find out I forgot to add a LocalToParent.
Huh, is the physics body baker broken?
Im gonna try the good old remove component, clear cache, restart, and readd component to see if that fixes anything
Hrmmmmm, looks like Physics + Netcode does not allow physics bodies to have smoothed bodies.
Damn, TransformV2 really is beefy.
And that is without a parent
What is PostTransformScale? Is that automatically added to all entities?
Oh thats for non-uniform scaling
I'm curious if they will eventually support physics interpolation without LocalToWorld. Doesn't seem like it would require it since you can easily interpolate the (float3, quaternion, float) format of the WorldTransform.
I think it's just mandatory for any scale other than 1, 1, 1
Because my scale is uniform at 0.4, 0.4, 0.4
uh that seems wrong. LocalTransform and WorldTransform both have a float scale
From the new docs:
The PostTransformScale component
Transform components only support uniform scale. To render nonuniformly scaled geometry, you may use a PostTransformScale (float3x3). This will be applied in the following manner:
Do you have that little lock icon toggle on in the inspector?
Next to transform Scale
0.4, 0.4, 0.4
Try clicking that little lock
Doesnt do anything
Was curious if that changed the output of baking
Checking that enforces uniform scaling
Nope
actually I was mistaken anyways. Looks like it enforces uniform scaling on any future scaling.
Question 6: For the netcode devs. Option for dark mode netdbg viewer please.
It's added by the physics baker for scales other than 1.
Ah got it
scale ๐คข
that's kind of sad
i guess it's because it bakes scale into the collider and leaves entity at 111 instead
and adds it in post
Annoying because rendering requires scale.
Ya know, off all the things they baked, physics body really shouldnt be baked. At least key parts like layers.
This is one feature I wish I could use from Latios' framework. But them introducing their own transform variant breaks compatibility with netcode and that's a no-go for me.
Strange warnings. All entities clearly have scene section component
oh good
^
Should be harmless, is that actually causing any problems?
I want to add a Material to the RenderMeshArray. Can I do that using a Baker and how can I get access to that shared component?
why do we need to use TempJob if we pass native array to the job instead of just Temp
Can I still stay at TransformV1? Lots of things breaking. ๐ฅฒ
my step through debugger is really buggy when checking job code
jumping all over the place
kind've a pain when trying to debug stuff
What version are you on? What's breaking?
1.0.0-pre.15. CharacterController is breaking
Baking seems to be fixed, largely
Lots of warnings but warnings don't block compilation
๐
Not doing anything from what I can tell. I've just cleared all warnings whenever I press play.
Well no, netcode + physics causes baker to break if the physics component is interpolated.
I don't have either ๐
Well you're good then.
I disabled physics interpolation and I saw 0 difference in graphics so eh.
work done
back to 1.0 let's go
been thinking about aspects all day, whether i love or hate them ^_^'
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.
[Worker1] Exception thrown during SubScene import: System.ArgumentException: __UnmanagedPostProcessorOutput__220684074 must already be filtered by ComponentSystemBase or ISystem
same previous issue unfortunately
so subscene issues aren't completely solved
EntitiesJournaling: Failed to resolve system handle for global system version 112085.
UnityEngine.Debug:LogError (object)
Unity.Entities.EntitiesJournaling/JournalingState:GetSystemHandle (Unity.Entities.EntityComponentStore*,uint) (at Library/PackageCache/com.unity.entities@1.0.0-pre.15/Unity.Entities/Journaling/EntitiesJournaling+State.cs:501)
new one when i turned on journaling outside of play mode
oh no, back to every recompile? ๐ฆ
๐ฅฒ Up until now this bug still haven getting proper fix yet at Unity 2022.2.0f1?
i didnt get it once in 2hours this morning
but now i've got it twice in 2 recompiles
But I guess it's still much better than before?
well it was this morning, it's not right this second ๐
doing a full library nuke as a longshot
Glad you like it, managed to sneak in GetXTypeHandle :3
Fun fact there's an IJobEntityChunkBeginEnd now too to get a callback of when chunk iteration begins and ends inside an IJobEntity! :3
Hehe, I remember you mentioning it quite a lot, I even gave you a sample of how to do it yourself.. Now you don't have to ๐
This has version has pretty much everything I want except default interface methods for isystem
So much code cleaned up
Wait, we dont? Could you check again? ๐
public interface ISystem
{
[RequiredMember]
void OnCreate(ref SystemState state);
[RequiredMember]
void OnDestroy(ref SystemState state);```
confirmed coming?!
๐
Whaaaaaa.... ๐ Forget i said anything hehe๐
i really need to figure out what the hell this monoscriptgenerator is
i add my own rosyln analyzer to project and it causes a bazillion warnings on it now
well ok it's coming from the actual unity engine
2022.2.0f1\Editor\Data\Tools\Unity.SourceGenerators\Unity.SourceGenerators.dll
@proud jackal Now is that possible to ecb.CreateCommandBuffer inside IJobEntity?
Fixed an issue where inspecting an Entity in play mode would mark its chunk as changed every frame.
finally!
ChangeFilter?
yeah, it doesn't screw with it anymore
nice to see my fix made it into HierarchyGameObjectChanges ๐
okkkkkkkkkkkkk
finally tracked down this source generator issue
seems like AdditionalFiles in csproj breaks source generators in rider
huge waste of time, and i have no workaround atm
Nope, closest thing is:
new MyJob {
ecb = SystemAPI.GetSingleton<ECBSystem.Singleton>().CreateCommandBuffer()
}.Schedule();
But that will now work since I fixed the issue with IJobEntity object initializers and SystemAPI. Before you had to write:
var ecb = SystemAPI.GetSingleton<ECBSystem.Singleton>().CreateCommandBuffer();
new MyJob {
ecb = ecb
}.Schedule();
Is it possible to exclude components directly in jobs ord do I have to provide a query for that?
IJobEntity?
is new physics on the new transform system?
Translation/Rotation can't be found anymore so it seems so
new physics? ๐
entities and physics are now on pre.15
adding ENABLE_TRANSFORM_V1 at least fixed the compile errors. now on to the rest
PropertyInspector moved to Unity.Entities.UI.Editor
Yeah forgot to mention that ๐
WithNone attribute
Where do I use that attribute?
on struct
oh now I get it ๐ thx
Unity Physics is on Transform_V2 with the pre-release package.
ah cool, time to change then ๐
Does the new Physics version handle Colliders in parent/child hierarchies? We are still on 0.51 atm.
@rotund token what dont you care for about with aspects?
also @pulsar jay i havent yet fixed all my compile errors ๐ข but my blind assumption is its the same as it was before(static yes, dynamic no), I didnt see any indication things would change and I did lobby hard for physics rigidbodies to respect the old transform system
Ah thats sad to hear. Building hitzones drives me crazy as all the enemies are getting to be some wierd multi joint physics contraptions
Also spawning objects with joints is really broken as the part are disconnected and spawn in their original position before physics moves them to their dedicated joint position
Are you experiencing this with the latest pre-release Unity Physics package?
No we are still on 0.51.1-preview.21. Thats why I asked if it gets any better
I would really like to just stick to colliders in a hierarchy and do physics checks against them
But they either get combined or unparented (even in kinematic mode)
Or is this even the latest preview version? The 1.0 is still experimental is it?
yeah my hybrid physics setup is a gigantic pita. really hoping for the animation package to return to preview asap
so say we all
I hope santa unity is listening ๐ ๐
Is it possible for components to reference other component types?
Thinking of building a generic RemoveComponentOnEntity component which can have the target component type as a value.
yeah, why not?
Can I just use a Type field? I guess I would have to store the type index?
oh this? I would not suggest that
it's not gonna be persistent between instances of game
A System.Type does not work because it is not a value type
A RemoveComponentOnEntity component would need to have the ability to store which type of component to remove
nothing stops you from doing that
just keep in mind, that data between game instances can vary for component types and indexes
The question is: When is the type index fix? Can I rely on conversion? Type field in authoring -> Type index in component?
This is still not I want since it's still keep creating command buffer at System.OnUpdate() every frame. I want to able to create command buffer inside IJobEntity.Execute()
So the only hope to reference a component type would be generics ๐ค Which dont work with code gen and would generate multiple archetypes
what generics? ๐ค
Like RemoveComponentOnEntity<PhysicsShape>
Unity 2022.2.0f1 looks like can't build android properly ๐ฅฒ
Will physics sample update to pre.15 very soon?
Each type has a stable hash which you could use, iirc you get it from the type manager, think it could work in baking, I used it back with the gameobjectconcersionsystem but havenโt updated that code yet
Thats interesting. I will look into that
If I need to make an array of differently typed structs available inside a job (as as blob), do you think it makes more sense to store this inside a blob array as a union of all types or a blob array that holds blobreferences to each other instance (that is then also a blob)
I guess another alternative would just store an array of intptrs or something inside the blobarray, but I'm pretty sure the safety system doesn't like that

Does DOTS offer any tools for dealing with generics of some description? For instance, say I have 3 different spawners, one spawns stuff in a cube, one in a triangle and one in a sphere or whatever. Is that typically a problem one solves by throwing boilerplate at the problem, that is make a new component and system for each type, or are there some tools to help with such things? I imagine interfaces don't play very well with DOTS, right? Inheritance probably doesn't, either? How do people typically approach things like this?
no inheritance, just do different systems if logic is way too different
Well, that's the thing though, they are fairly similar. Like, take the example, cube and pyramid are almost identical and sphere just needs a radius rather than 3 dimension lengths, but ultimately they're all still following the same pattern. It feels a bit silly to write out the whole thing for each of these minor variations?!
if you can make it so it depends on just variables - then can probably be merged
otherwise no, different logic = different systems
nothing wrong with it though
by separating different logic into different jobs you actually optimize stuff
Well, it's not just the system, I need entirely new components and everything
not really
You could use enums to switch between different behaviours
you can split shared data into separate components
It really depends on what you are doing imo, dots physics handles different colliders within the same system
Technically it should be possible to use generics but only with jobs that dont use code generation. E.g. IJobChunk
I could use enums, but then I feel like I'm betraying the whole idea behind ECS in a way. Right now I'm basically doing the enum approach in the baker so, at least on the outside, it looks like one script. But internally it splits up into different components and systems
they use hardcoded polymorphism
Yes
I'm assuming @oblique cosmos has a limited set of components (triangle, sphere, etc) going from his message
That's why I said it depends, it's hard to say from the outside
iirc this is how rivals does it if I remember correctly. You pass it a generic struct type that implements the execution logic for specific steps
Sorry if you've mentioned this elsewhere, can't find it in the scrollback - in what way is it breaking?
In this special case you could split it into separate jobs. One for each shape to generate spawn positions and another one that spawns at arbitrary positions
Yea, so, I'm basically just testing stuff out. So the situation is I have 3 different shapes. A cube, a pyramid and a sphere. All of them need different logic to find a spawn point inside of them and, in the case of the sphere, a different variable. But that's it, prime example of interface usage, for example. But I'm guessing that doesn't really play well with ECS?
Hm. I suppose that works, too. Right now I simply made 3 systems, put them all in the same file so I don't go insane and called it a day
I guess merging those systems and just making different jobs would be another way to go ๐ค
By which I mean way more sensible, for some reason I just didn't think of it lol
you could also do the same just with static methods
having a static spawnAtPositions(NativaArray ...) method and call it in each of the 3
so at least you dont have redundant code
but still have the boilerplate of the 3 jobs/systems
Well, right now I'm already using a static method for each of the calculations, so it's essentially one line either way and technically no repetition on that one :P
Hm. Well, I mostly just came here to figure out whether I'm crazy or whether that's just how people do things. Looks like it's just how people do things, so I suppose my question is answered
Was just curious if any of such conveniences have survived the ECS treatment, but I didn't really expected them to, since that's kinda antithetical to the whole point
https://forum.unity.com/threads/reactive-system-generic-way.919997/ this thread is interesting concerning generic systems
Unity Forum
I have been looking into SystemStateComponent for creating a "Reactive System" in order to listen to structural entity changes ( Component was added,...
I tried to implement my own simple version of it but stopped after realising it wont work with IJobEntity
I just got a burst error in AddSharedComponent ๐ฌ
Is this an ecs bug?
(0,0): Burst error BC1051: Invalid managed type found for the field `EqualFn` of the struct `Unity.Entities.FastEquality.TypeInfo`.: the type `System.Delegate` is a managed type and is not supported
You might want to look at this: https://forum.unity.com/threads/sources-included-polymorphism-in-dots-now-with-source-generators.1264616/
Disclaimer: I made this before joining unity, so this isn't an official/supported Unity tool or anything like that. I also haven't tested it with 1.0, but it might still be working since it doesn't really have anything to do with entities
Does 1.0 pre15 appear in the package manager yet? (Iโm traveling and just on mobile) Kinda wondering if dots addressables is out but just hidden visibility on the package manager, seems weโre getting kinda close to release but the absence of dots addressables is a bit sus given there was talk of it being included in 1.0 rollout
If you're talking about the Mesh or Convex Hull ShapeType in the Physics Shape component then yeah it's supposed to also include the children's Mesh Filter to generate the collision in 1.0.
Yeah I am afraid of that, too. Thats why we didnt switch yet. I have my own AddressableEntities system which heavily relies on runtime conversion. So I would love to know if it can be replaced with the official solution before switching
Ah I have seen this post before. Good to knwo you work at Unity now. Would be interesting to get sth similar officially supported.
Otherwise I am to anxious to use it / maintain it throughout the ecs version changes ๐ฌ
That is really a big problem for us. Sometimes you just need an object to consist of multiple colliders without merging them. E.g. for hitzones
I think I just ask in other way. Will ecs sample update to pre.15 very soon? New ecs sample update should able to help me fix all the breaking changes. For now I will stay at V1.
Does the shared component have managed types?
It has a BlobAssetReference
Thats the full stacktrace
public struct SplineBlobHolder : ISharedComponentData
{
public BlobAssetReference<SplineBlobAsset> splineBlobReference;
}
just that
Ah, you are on 0.51?
yes. Is this a known bug?
Where are you calling AddComponentShared?
from IJobEntity
Are you burst compiling it?
Yes
yes
You cannot reference shared components in a burst compiled method in 0.51
only 1.0+ supports unmanaged shared components
Oh I see. Thx for clearing that up
Weโve included the content manager and content delivery systems as part of the Entities pre-release package. https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/content-management.html
Oh no. Ugh, gonna figure out how to do this as well then. I just barely figured out how to conduct a hybrid scene switch as well...
looking forward to seeing your creations!
Is there a way to inject a Material created by authoring into the world's RenderMeshArray during Baking phase? Or am I looking at picking it up on the first frame of ECS runtime and inject it via ISystemBase?
Currently looks like it's very barebone. Any plan to further improve it to make it much easier to use and also provide content visualization something like addressable group? And also implement something like addressable build to ccd that will auto upload content to ccd after finish building.
what exactly are you trying to accomplish here?
Firstly I'm far from set in stone in my opinion about this and I have absolutely no issue for reading, it's an elegant system and my concern is more fundamental with writing and what it implies.
Over the years I've been slowly drifting towards ensuring only a single system is responsible for writing to a component. Many reads, 1 write.
Long term I have found this to be a much easier to maintain, develop and debugging experience.
Aspects, when writing is allowed, seem to promote the opposite.
What would you say the benefits are in having a single system which writes a particular component?
Much easier to debug where values are set. Journalling has greatly helped in this regard but it's still just easier to debug if it's only 1 place you know the data is being set.
It mostly eliminates ordering issues. No accidental write, read, write, read throughout the world. All systems reading will read the same value and I have complete control over timing, I know always when and where something will be set.
Refactoring is easier, only 1 place to care about if I need to change behaviour.
Timing issues have been the biggest large project multi developer issue we've been facing. Large parts of the project just write/read without much though and anecdotally the features that have strict ownership over components have had significantly less issues long term.
Do you ever find it restricting or difficult to work with?
Personally no, but I think a lot of people would
I could imagine having to create components types just to cache writes in order to collect them later on
for example if you wanted to intercept all the places throughout the frame where people might want to write transforms
I should clarify, it's not everything. I have plenty of components that have multi writers but these are usually for triggering behaviour elsewhere in the project.
Like I have this very thorough cleanup/destroy pipeline where every entity must go through for cleanup throughout all my libraries. I only have 1 single DestroyEntity in the entire project and you can only trigger it by setting a byte to 1 on EntityDestroy component.
I'm not sure I see how aspects necessarily change the approach - you don't want people writing transforms mid-frame, you don't want them using aspects either
in both cases you have to have an alternative state-change-collecting component that you resolve later on and actually apply the transform
Funny enough, I've been thinking a lot about transforms last few days and wondering if I could make it single write but i can't think of a way to do this without effectively building objects into the project
(deleted off topic babble)
I like the concept of aspects but frankly I find myself never using them. Direct access of the specific component I need is what I'm finding most used.
One thing I find Aspects good at is to provide a container for several component types, which can then be "passed around" as parameter to functions that need to read/write those components. Instead of having functions taking 12 components by ref, you can just have functions that take an Aspect containing these 12 components as parameter.
A practical example would be writing a state machine for "Enemy AI". Each state would have its own separate function taking the EnemyAspect as parameter. EnemyAspect can then contain all the component data that any state update might need access to, and so state functions are free to operate on that data. Here we're assuming that we're dealing with a case where an archetype-based state machine would be a poor choice
In practice there have been few cases where I've felt like Aspects were necessary, but those few cases would've involved a hellish amount of boilerplate and maintenance costs if Aspects didn't exist
Some years ago when dots was only starting I remember recommendations to not access data we don't use. Sometimes even filtering could be better then accessing everything in your world, of course depending on scale. Aspect as I understand would trigger all 12 components to gather from chunks, which sounds not as performance by default (sorry me for appealing to this). So maybe dealing with aspects in this way isn't the best case.
you don't use aspects that access smth you don't need ๐ค
that's kind of why I don't really like Transform aspect
This is true most of the time, but there'll also be other times were the performance costs of trying to set things up for idiomatic ECS iteration will actually outweigh its benefits. It may be because it involves too many structural changes all the time, or because it involves too many jobs to schedule, or because it is checking for changes all the time, etc...
Basically, there's a point where structural changes and job scheduling costs become a much bigger evil than imperfect memory access patterns
Yes, and if we dealing with not 50 not 500 and not even 50 000 entities but with millions we starting to write manual accurate things because even filtering chunks became sensible.
Also i wondering is it possible to turn codegen to generate only those parts of Aspect that actually was used in particular job?
transform aspect definitely solves one of the biggest issues that < 1.0 had
but there are a bunch of what feels like incomplete features in transform v2 atm
so i'm trying to reserve judgement until those are (hopefully) resolved
(staticoptimizeentity is gone with no viable replacement as far as i can see as TransformUsageFlags currently don't work except for ManualOverride, so we just have giant archetypes atm)
I have a "ghost" material that I want to inject into the array so that I can instantiate another item, but swap out the material so that it looks like a ghost representation. I just want to have that material loaded in the barrel beforehand.
Currently I just created a managed IComponentData that holds a reference to that material which is assembled during baking. Then in an ISystemBase I have a job that looks for that managed component, and then EntityManager.GetAllUniqueSharedComponentsManaged<RenderMeshArray>() and add that material to the renderMeshArray.Materials array. If there is a simpler way, I'm all ears ๐
I have sprite rendering system and i do exactly the same to get materials to proceed rendering and I want to know better way. Today I've seen this link mention somewhere on forum or in discord. Maybe this way we can hold managed object reference as unmanaged components https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/content-management.html
Once I update the renderMeshArray.Materials array, how do I write that shared component back? Do I just cycle all the entities it's bound to and update them one by one? Or is there a easier, global way I can just modify that shared component to reflect the new Material[]?
There is no per-EntityQuery or per-ArchetypeChunk operations to set shared component, so I guess we can only do per-entity setting. But yes, while after changing SCD entities copied to another chunk, then I want to be able to move entire chunk to another SCD value.
Thx for confirming this for me. Appreciate the input.
Tried playing around with the content management tools and I'm way over my head. Please send a note to the netcode folks to try and publish a sample using their package that incorporates this loading pathway. Things like predicted spawning, ghosts, and hybrid components really dont play well with asynchronous loading.
heh, i just wanted to ask if anyone has tried this new content management thingy.
seems complicated ^^
Yea. Right now I have a thread bound full scene (not subscene) load and switch which causes a 4 second lag but otherwise does everything automagically.
I have unconverted game objects, a few scenes, and entities with sprite renderer hybrid components.
i need to wrap my head around it before i convert anything with it. this is basically assetbundles for dots, right?
Maybe? I never used asset bundles outside some free assets on the store
hey everyone
i want to try pre.15, but build fails with
Shader error in 'Universal Render Pipeline/Lit': Program 'LitPassFragment', error X4567: maximum cbuffer exceeded. target has 14 slots at line 98 (on d3d11)
2022.2.16 dx12 and dx11 api enabled if that matters
Does the same error occur with DX12 disabled?
That's odd. Are you setting any constant buffers in custom rendering code? Graphics calls or command buffers?
i don't have any custom rendering code in this project
https://forum.unity.com/threads/hdrp-build-failed-error-x4567-maximum-cbuffer-exceeded.543320/
Try disabling a lot of settings?
in the debugger what colour indicates the job was using burst?
green
what version
of burst or unity?
unity
2022.1.23f
[BurstCompile]
private struct DeformJob<T> : IJobParallelFor where T : unmanaged, ISpline
{
NativeArray<float3> _vertices;
NativeArray<float3> _original;
T _s;
float _tMin;
float _tMax;
public DeformJob(in T spline, in float tMin, in float tMax, in NativeArray<float3> vertices, in NativeArray<float3> original)
{
_original = original;
_vertices = vertices;
_s = spline;
_tMin = math.clamp(math.min(tMin, tMax), 0, 1);
_tMax = math.clamp(math.max(tMin, tMax), 0, 1);
}
[BurstCompile]
public void Execute(int i)
{
Set(_s, _tMin, _tMax, _original[i], out float3 result);
_vertices[i] = result;
}
}
this is my job
var no = new NativeArray<float3>(original.Length, Allocator.TempJob);
var nv = new NativeArray<float3>(vertices.Length, Allocator.TempJob);
MemCpy(original, no);
var t1 = math.clamp(math.min(tMin, tMax), 0, 1);
var t2 = math.clamp(math.max(tMin, tMax), 0, 1);
var job = new DeformJob<T2>(spline, t1, t2, nv, no);
var handle = job.Schedule(vertices.Length, 4);
handle.Complete();
MemCpy(nv, vertices);
no.Dispose();
nv.Dispose();
like this
yeah this won't work
burst requires types of be explicitly defined
new DeformJob<int>(spline, t1, t2, nv, no);
would be fine
damn
i guess i can do an overload method instead with the type defined then
you need to somewhere in your project explicitly define each variation of the generic job
there are a few tricks you can do
i could do a swtich statement on the generic type to cast to the precise type
{
public virtual Job<T> Job { get; }
public struct Job<T> : IJob {
public void Execute()
{
}
}
}```
is my current workaround for this
like this perhaps ? case Bezier b: job = new DeformJob<Bezier>();
If the leak detection is part of the allocator in the future, that would mean that it would also detect leaking blob asset references, right?
iirc they didn't have dispose sentinels in the past
is this part of entities i don't seem to have that available built in for jobs
hmm it might be
i honestly not sure if it does anything special
simply having the implementation somewhere is good enough
yeh it seems its part of entities so i might wait for 2022.2
in an attribute is just a nice place
ill use a simple switch for now
and remind myself to change it when entities is fully done ๐
Not sure if this is what you implied, but turns out you can just do it in one go on a query basis using this signature:
public void SetSharedComponentManaged<T>(EntityQuery query, T componentData) where T : struct, ISharedComponentData {...}
I'm getting strange behavior. Can you show me how you modified the renderMeshArray.Materials array in the shared component? Each time to change it's size by adding my own Material reference and write that back to all entities that hold it (either individually or using query), all the meshes that appear in scene disappear and their MaterialMeshInfo indicies all become negative numbers, and the shared component they have have null reference to Materials!
Ya know, after staring at the docs for netcode custom templates for a few hours, i think I now know what it's doing. Kinda. Lack of linters or any sort of code coloring is pain. My previous 2d variants for transform (needed to convert from V1 to V2) was broken because I forgot a semicolon and has been broken for weeks.
With no error. It's pain
Are blob references somehow being magically auto discarded?
Because I thought that's not a thing
however
Debug.Log(AbilityNodes[i].IsCreated);
AbilityNodes[i].Dispose();
What's going on here?
I know right. They say you have to manually manage lifetimes of blob assets (like when I clone a collider) yet its automatically discarded when I overwrite the reference. No clue honestly.
depends how you created them
BlobBuilder.CreateBlobAssetReference
Runtime
are you using a blob asset store
No blob asset store
The builder allocator is is temp and the blob is persistent
are you writing back the disposed blob?
Obviously baked blob colliders are reference counted but even runtime blob assets seem to be automatically disposed.
pretty sure they're not
i dispose plenty of blobs without issue
I can't see how they are either, they just allocate memory
where T : unmanaged
{
#if !NET_DOTS
[Properties.CreateProperty]
#endif
internal BlobAssetReferenceData m_data;```
blob asset reference
doesn't hold a pointer to it's data
I've been cloning colliders to overwrite their filters and disposing the old ones. Not the original colliders from baking but 2 clones away. Yet I can not dispose of them strangely.
I mean it kind of does, that struct has a pointer
Oh you mean the data of the reference
var a = default(BlobAssetReference<int>)
var a = b;
var c = b;
a.Dispose();
what does c hold?
I wish to add a Material into the RenderMeshArray. However, after I apply the new material array to renderMeshArray.Materials and then write that back to each entity that had the original shared component. All the meshes disappear, and each of their MaterialMeshInfo component shows negative indices and their RenderMeshArray shared component shows a NULL reference to the Materials array.
What am I not understanding here? Is this a bug, or is there something I need to oversee when writing the new array?
And will blob colliders without reference trigger the leak detector?
they never used to be tracked i'm not sure now
from my test yesterday, at least tempjob is tracked on normal leak detection but tracking disappears when you put full stack trace on
i do not believe they will be though
I'm creating a blob, that has a blob array. Then I'm creating a bunch more blobs, and adding their references to that blob array
Gotta go back to my cloner script and see if I can dispose of things properly
They are only being disposed once, since I'm logging it and not disposing it anywhere else
Something is definitely breaking somehow
If I dispose of the blobs unity crashes

and it crashes in a really weird spot too
I if I don't dispose it everything is fine, although I have no idea if it's leaking
Are there any issues with storing a blob asset reference inside a blob?
definitely
How would I store a pointer inside a blob then? as an IntPtr?
blobptr
I thought that's only if the memory is in the same blob
It's not
It's a separate blob
thats all a blob can reference
Why can't it store a memory address?
e.g. create blob1, create blob2.
blob1 has a field BlobAssetReference<Blob2Type> reference, set that to blob2
look at BlobBuilderArray.CreateBlobAssetReference
You mean BlobBuilder.CreateBlobAssetReference?
I think maybe the issue is I'm copying the blob, although I'm still confused why that would be an issue
Since the data would be the same, including the memory address of the referenced blob I want to dispose
wait
you have a list of blobassetreferences
so your blobassetreferences in this list also in the blobasset?
I have one blob with a BlobArray<BlobAssetReference<T>>
but the "parent" blob is not in that array
if that's what you meant
The weird thing is, I also have other blobs that have blob asset references in them, and they work fine and dispose fine without issue
e.g.
Maybe the issue is that its in a blobarray somehow? Although I don't see how that would matter
yeah i was about to say that blob objects move their memory
when creating
they put everything in the same block
But the blob asset reference in that screenshot is also in that block
a blobarray is just "multiple" blocks
This also seems to work fine, even if it's kind of weird
as long as the blob ptr is allocated to the correct size initially casting it back to the fake header size seems to work fine
I initially misunderstood what blobptrs are for, so maybe Ill just use them instead of blob asset references (inside of blobs)
I'm assuming the "ptr" is also disposed together with the entire blob (since the "ptr" in this case is just a place inside the allocated memory block for that blob asset)
I have a lot of nested data structures
so restrictive
what do you mean?
do you only dispose this once at end?
I dispose it when the client or server shuts down
(and create it when the client or server starts)
i just wrote my own simple memory allocator for this
https://gitlab.com/tertle/com.bovinelabs.core/-/blob/master/BovineLabs.Core/Memory/MemoryAllocator.cs
Reference<T> (basically clone of blobassetreference)
and just use a custom memory allocator
then just dispose that
rather than every element
So like a collection of pointers?
don't have the annoying blob ref limits etc
You mean that you can't copy any blob data?
I guess the difference to your version is that it's not all in one block
unless you use a single struct
without any pointers
I just mean that that's kind of the reason blobs have these weird restrictions
Whether or not they make sense is a different question I guess
I don't really mind them at this point
@rotund token any idea why disposing the blob crashes unity though? I have no idea why
It has to be disposing the wrong memory for some reason
Huh, interesting. In a more simple example unity actually detects that I am doing stuff that isn't allowed
I guess through 28 different layers of generics that detection breaks
I'm very confused why my other blob asset references inside blobs aren't causing any issues then...
And I also don't fully understand why storing a pointer inside a blob isn't allowed. I understand it breaks the "a blob is a single memory block thing", but that pointer should still be valid
for some reason my custom baked component disappears from entity when i close subscene, is this the expected behavior? it was different in 0.17 
replacing TransformAspect with LocalTransform helped, but .. why lol
Can someone please help me figure out how to inject my own material into the RenderMeshArray?
@rotund tokensorry for ping again - i did some changes with my generics thinking this would fix it but now i get an error about boxing a value type to a managed object
JobHandle handle;
switch (spline)
{
case Bezier b:
handle = new DeformJob<Bezier>(b, t1, t2, nv, no).Schedule(vertices.Length, 4);
break;
case LineSegment l:
handle = new DeformJob<LineSegment>(l, t1, t2, nv, no).Schedule(vertices.Length, 4);
break;
default: return;
}
Thought this would work because im specifically defining the type?