#archived-dots
1 messages Β· Page 66 of 1
but it crashes in both editor (mono) and build (il2cpp)
so... yeah π
@mint iron so this is in a generic class (non system), inside a non-generic-system, which is instantiated dynamically via reflection
so it might be related
but i cant even get the job to show up even if i move it outside of the damn class
like i put it inside of a namespace only, no nested types
could it be because im using [NativeDisableUnsafePtr] attribute or w/e its called?
wait no, i take that back, i had a compilation error π
yeah its the generic in wrapper
doesnt work
@mint iron thanks
i still cant get it to compile the full job
even if i move it outside tho
show me the code?
haha
you'll get it sorted, simplify! π
i was losing my mind yesterday trying to figure out why my job wasnt working
spent a few hours trying to get this to execute with burst, or even get picked up by the burst compiler, but no luck
i will keep digging later
i might ping you later if that is okey :p
im really really stuck
problem turned out to be, i had a 'Result' field in my Job struct, i was trying to write to from within the job and read it as a return value. but you cant do that.
im doing some really nasty stuff with manually allocated memory and such
that i pass to the job
ill be at my workstation in 10 minutes or so
convinced wife i need to do something important π
yeah that's probably why every official statement seems to be warning people about staying the hell away from unsafe, stressing saftey checks because its a huge can of worms potentially, and hard to debug in burst.
@mint iron yeah i know they keep saying stuff like this, but reality is that a lot of us do need to do use that
oh yeah, i find it super interesting, am glad they for now are giving us the option, i hope it stays that way and they dont try and force people to be safe
like what im trying to do does not fit perfectly to their ECS model, the way i need the data arranged in memory for delta compression and stuff
i cant do that directly on top of the chunk memory
i need to get the data out of the entities in a bit-packed and well defined format that my delta compressor understands
i just wish they had a 'disable all our safety checks because i know what im doing' mode
you'd think those checks would also safe guard from some edge cases they know they won't support as well (just guessing)
yeah maybe
@mint iron at my workstation now, lets see
(if you time?)
https://hastebin.com/umefenudem.cpp here is the full job definition, and wrapper class
its instantiated like this inside of the containing system (SerializerSystem):
protected override void OnCreateManager() {
_componentGroup = GetComponentGroup(
_replicationModel.ComponentTypes.Concat(new ComponentType[] { ComponentType.Create<NetworkedEntity>(), ComponentType.Create<NetworkedOwner>(), ComponentType.Create<NetworkedDirty>() }).ToArray()
);
{
// initialize serializer array
_serializers = new Serializer[_replicationModel.ComponentModels.Length];
// create serializers via reflection
for (Int32 i = 0; i < _serializers.Length; ++i) {
_serializers[i] = (Serializer)Activator.CreateInstance(typeof(Serializer<>).MakeGenericType(_replicationModel.ComponentModels[i].Type.GetManagedType()), _replicationModel.ComponentModels[i]);
}
}
}
I like your namespace π
burst inspector gives me this
first thing i tried is moving the job to the system itself, so out of the nested class
it does not help
burst inspector still will NOT pick it up
even removing the whole ReadField method does not help
but you don't even have BurstCompile tag there?
@dull copper oh sorry, it doesnt change if i add it, i removed it before
still wont show up
okey so added back burst tag
and put it outside of the wrapper class
still will NOT show up
and crashes editor whenever i run it
I'd try some minimal repro case, see what in that breaks it
removing the native memory pointer doesnt help either
if it's something that should work by design with it, file bug report with it
what version of unity are you on
2018.3.2
released yday or something
could it be because it's a nested generic job, instead of a generic system with a job on it?
mmm i was gonna just get it to show up in my inspector but IJobChunk interface is different for me it seems
namespace Unity.Entities
{
[JobProducerType(typeof (JobChunkExtensions.JobChunkLiveFilter_Process<>))]
public interface IJobChunk
{
void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex);
}
}
maybe ijobchunk doesnt support burst?
i got it to compile now
its because it cant resolve the generic types when its instantiated via reflection
i added a Job<Health> test = new Job<Health>();
and then that shows up
so... thats annoying as hell
then i need to code gen a long list of jobs type
lets see burst vs non burst speedup then
yeah it still hard crashes lol
sigh
even crashes when i try to show the LLVM IR for some of the jobs
π¦
for me it really doesn't like your generic class definition as soon as i comment out public class Serializer // <T0> : Serializer where T0 : struct, IComponentData it shows in inspector
weird
but this method
static void ReadField(ValueUnion* buffer, Byte* dirtyFields, Byte* addr, ReplicationFieldInfo field) {
var current = &buffer[field.Index];
switch (field.Type) {
case ReplicationFieldType.Int32: {
var val = *(Int32*)(addr + field.Offset);
if (val != current->Int32) {
current->Int32 = val;
dirtyFields[field.Offset] = 1;
}
}
break;
case ReplicationFieldType.Float: {
var val = *(Single*)(addr + field.Offset);
if (val != current->Float) {
current->Float = val;
dirtyFields[field.Offset] = 1;
}
}
break;
case ReplicationFieldType.Mathematics_Float3: {
var val = *(float3*)(addr + field.Offset);
if (val.Equals(current->Mathematics_Float3) == false) {
current->Mathematics_Float3 = val;
dirtyFields[field.Offset] = 1;
}
}
break;
case ReplicationFieldType.Mathematics_Quaternion: {
var val = *(quaternion*)(addr + field.Offset);
if (val.Equals(current->Mathematics_Quaternion) == false) {
current->Mathematics_Quaternion = val;
dirtyFields[field.Offset] = 1;
}
}
break;
}
}
is what crashes it atm
comment out that and im good, run it, and it explodes
i know the code is valid, because it does run without burst, both in mono and il2cpp
thats progress!
var val = *(float3*)(addr + field.Offset);
if (val.Equals(current->Mathematics_Float3) == false) {
current->Mathematics_Float3 = val;
dirtyFields[field.Offset] = 1;
}
its the switch case for float3
which crashes it
ahh yep
it doesnt even suppoer instance calls on blittable structs on the stack?
actually i think it's this line
var val = *(float3*)(addr + field.Offset);
because without the if case, then i think that line gets eliminated
but if i do this:
var val = *(float3*)(addr + field.Offset);
current->Mathematics_Float3 = val;
dirtyFields[field.Offset] = 1;
still hard crashes
deleted the quat/float3 serializers, just wanna see perf vs non burst
I'll setup a small repro case and report a bug
feels like something is wrong here
some performance tests
to serialize 100k entities with ~30 fields (mixed float/int) each:
non-burst: 3.5ms
burst: 1.9ms
that seems like a worthwhile boost
this fully saturating 16 cores tho π
but yeah decent speedup for sure
@mint iron thanks for the help btw
np π
@trail burrow was it you who asked about this:
vs this:
I found a workaround (by accident) on how to force Unity to do that
just noticed it while fixing something totally diffferent
tbh, I don't know why they don't setup it like this by default, it totally should put all packages to your solution for pure convenience (instead of making you rely on metadata)
anyway, how you do this is bit hacky and not that nice for project where you want to update the packages constantly, but if you work on specific package version and try to figure things out, having it on same unity solution is golden
so, here's how it works:
- go to your projects `Library/PackageCache` -folder and move `com.unity.entities@0.0.12-preview.23` etc under your project `Packages` -folder
- while still in `Packages` -folder, open manifest.json and remove the entry to entities package from the json file (any package folder found under Packages will automatically be picked up and you want the pacman to pick your local package instead of the one from cache)
- open project again and open any script file through it, it will regen the solution and now all ECS related packages are also in your solution```
or simpler version would be just
```- don't install Entities through package manager at all, make sure it's not in your manifest
- copy entities package into your projects Packages folder from some other project's cache or from your user/appdata's package cache
- open unity editor and open any script file through it```
in case you need to update the entities package, you can just do the latter version..
huge downside of all this is that when you actually use local package, you can't see through package manager that there could be a newer version for it (as local package always overrides everything for it)
np
in case of entities package, this brings all Unity.Entities and Unity.Transform packages to solution
you can repeat the same thing obviously for all packages you need it to work like that
would probably be nice to pick actually all these Entities dependencies there too
so you'd get full burst, jobs, collections, mathematics there too
so, like this
that's with those
that should help debugging and figuring these out a lot π
I just wish I had realized this earlier
Haha ye, it's convenient to have it all in the solution
have just opened individual files so far for these
but you can't jump around the code then with IDE
oh, you also need com.unity.test-framework.performance apparently too if you do this, but then again, I think that was requirement on 2018.3 already (testing this on 2019.1)
also may want to add com.unity.rendering.hybrid π
@dull copper ha
bit offtopic but I sometimes wonder if Unitys own HDRP team is aware you can place custom packages in Packages folder
I'm going to skip that for now
they always put them in some other folder and then put relative link to manifest for the file
The baby is doing his best to destroy the family iPad but at least he's not bothering me
they've done this for FPS Sample, Book of the Dead environment and Fontainebleau demo
#CheapToys
Yes but iPads are pretty resilient
@dull copper Hi, just read your message about moving packages to /Packages.
Not sure if it has changed or not but you won't be able to update any package inside that folder (at least it was like that last time I tried)
It's like not using packages at all
@knotty radish that hasn't changed, that is what I tried to warn as being a huge downside of all this π
I did notice that on 2019.1, pacman can still see the other versions but you can't update to them as long as you use local package
Missed that part haha
but the main thing here is that if you want to debug or even learn how entities internals work, you really benefit from having these included on your solution
as otherwise you'll only get metadata with VS when you try to follow up what part does what and you can't trace things back so far
if there's some better way on getting these included on your solution, I'm sure many would love to know, I just discovered this hacky workaround today so shared it π
Yes, for my own packages that's what I do. I have a Unity project looking for a local package and with that I have access to that package through VS
So either you put the package inside Packages or you put it somewhere else and just add the path in the manifest
yeah
or add git repo path there
that works now as well
(as long as the git repo is in package format)
I dunno how well the live updates work on the git thing tho, haven't used it much
I actually use file approach for manully cloned git folder for SRP
but that's mainly because I can control git directly for that then
Doesn't really work since when it pulls the repo the commit sha will be saved inside the manifest
So you would not be able to update that package
unless you wipe the hash manually?
Exactly
I could swear I read how that worked (and probably quoted on the forums too) but never did that myself π
yeah, in that case, it would be nice to be able to control it a bit better
I can see benefits from it not automatically updating
but "git pull" would be nice option for it
Yeah
re: Packages folder, of course if you update the contents inside that folder yourself, they will be used as is as that's in that case the actual files used in your project
(just clarifying that if others read this)
I also used that technique in order to fix something in the Addressable package until unity do the fix on their side
yeah, I did same today for visual effects graph on 5.2.3-preview as it doesn't work on 2019.1.0a13
there's small API change
Unity has actually planned having some option on pacman for moving the thing as local package for modifications
I hope they let you also update those later on if they are things that pacman lists normally
For anyone working on mac and on latest versions of ECS / Burst, know that VS latest update do not have the correct C# SDK which is 4.7.2, you need to update mono yourself then change default mono target in VS preferences to make it work.
@knotty radish I had that on windows few weeks/month ago as well
The difference is that on windows you have VS Installer where you can easily download that SDK
Don't have that on mac :/
my VS just directed me to a MS website for installer, I swear π
(I know there should be or used to be built-in option for that)
It's not a really big issue since in the next update of VS Mac it will have the new SDK, it's just that at the moment it's not here yet
Hi guys :)
I was just trying to build and run ecs samples (that I renamed Hello World because I have several).
But it seems like I have something missing for burst. I can see burst is downloaded (PM and on the disk). So do I miss something?
@gusty comet you have visual studio's c++ toolchain installed?
I'm not 100% sure it's requirement for Burst but have seen people having issues building with Burst without it
@dull copper Yeap 2017 installed
oh wait maybe I still havent installed C++ tools on this one :0
I mean, you have the c++ toolchain installed along with 2017?
it's not there by default
had some llvm problem because of it last time
you have to separately select it
Seems like I didn't, going to try again after the update ^^
I always have that on my end as I need c++ for other things + I use IL2CPP which also requires it π
Yeah can't you download MSVC++ compiler whitout VS?
it's part of the VS installer
you should be able to run the installer on preinstalled VS2017 and just add things with it
I'm using VS Code at the office (probably gonna swithc back to neovim/linux), had to reinstall VS just for that because I was in a hurry x)
@dull copper That did the work thanks π
cool, lucky guess π
anyone know if burst plays nicely with extension methods?
@mint iron it's just a static method call so yes, assuming you obay the other limitations for Burst then np
Somebody has been through the last ECS update? HLOD was already there before so that was maybe already the case. But I'm not sure (currently reading source code) if nested lodgroup is supported. Or is it simply going to use the Parent attribut?
Oh well I guess it's not supported :
if (parentLodGroup.ParentGroup != Entity.Null)
throw new System.NotImplementedException("Deep HLOD is not supported yet");
@gusty comet you probably know you now need Hybrid Renderer for the rendering stuff on ECS
Yeah that's the code source from it, seems like I can use nested lodgroup, just not with HLOD strategy
And I think that the ParentMask allow me to tell that the group is gonna replace a specific lod level from the parent
Sounds nice ^^ I need to try it on a test project now
@dull copper Maybe you did try something like that?
nah, I only played briefly with the conversion tool
been investigating other things lately
What's the status on bubbling error/exception info out of burst code. I see that it won't compile with a string arg in your exception.
Looks like its just interpolated strings and ToString() it doesn't like.
that blog post contains a snippet that lists all Job Safe APIs from Unity
Weβre now up to 301 job-safe APIs, but many of them are private or internal to Unity and so must be called indirectly via a public API.
Oh nice he's posted a new blog lets take a look... I guess this will change as Unity moves more perf critical engine code to the C# side. You're going to have to keep some API's closed when you have this huge barrier to cross as well
Going to be a weird time when they do that, because it'll be the same problem in reverse.
hello there, anyone tried to use the new WorldDiffer feature?
i have 2 different worlds, one with a lot of entities and the other is just empty. But when I call the UpdateDiff method it returns a zeroed WorldDiff struct
var worldDiff = WorldDiffer.UpdateDiff(m_SimulationWorld, m_StateWorld, Unity.Collections.Allocator.TempJob);
Guys, just to be sure. exception on Deep HLOD not supported occur when I try to add 3 level of group lod. Even whitout HLOD tag, is that normal?
managed to get the WorldDiffer working, you have to add an EntityGuid component to the entities that you want to map in the diff
entityManager.SetComponentData(entity, new EntityGuid { a = (ulong)entity.Index, b = (ulong)entity.Version });
Hey guys.
Updated to p23 and now EntityCommandBuffer.AddSharedComponent doesn't accept SharedComponentData with entities (why ever). Wouldn't be bad for me, if I wouldn't transport my reference to my GameObject with it. What I'm actually doing: my UI has a button for a skill. When pressing the button, I create a SkillActivatedData SCD and add a GameObject prefab reference to the SCD. Now a different system will take this SCD and the player, check if he has enough energy and actionpoints to do the skill. If so, it creates a SkillData (different data, this time with the actual effect, time, damage values,...) and takes the GameObject reference to visualize the effect. That's not working anymore :<
Anyone has a workaround for me or can tell me how you're handling this kind of problem?
gawd, spent far too long tryign to figure out why burst was giving the error 'System.NotSupportedException: The `try` construction is not supported by burst when i wasn't using that construction. Turns out it gives you that misleading error when you use a 'foreach', which was in some innocuous down line math library :S
Do someone know if there is (I think I saw it) an attribute to say update the system if a component has been modified (a shared component in my case) ?
oh wow, I didn't realize they wiped almost all old ECS examples out on latest sample update
there's only Boids and new HelloECS (3 samples) now
probably for the good too, old samples were kinda just stuffed there
this video goes through the new sample https://www.youtube.com/watch?v=j8Ba1E5ZgrA
Unity just updated their entity-component-system and added a new sample project! I go through the new project and talk through what some of the new changes a...
yeah definitely the right choice to remove deprecated samples ^^
Okay I gues I shouldn't have wanted to use the full API the first time on a case like that but... how do I do a jobsystem using CombineMeshes ? Let's say I have a entity with a list of childs (entities) with a tag to activate the job and them it check the list of childs and combine their MeshRender to create a new mesh and put it inside the main entity.
I'm trying to do/follow the ECS videos on the Unity learning portal... I don't have "Mesh Instance Renderer Component" and I can't find what package it's included with. Does anyone here know?
@thorn wing hey you want to get the Hybrid Renderer package and use the RenderMeshComponent instead
Just found this in the ECS sample project, is any idea if it's the latest version?
"com.unity.rendering.hybrid": "0.0.1-preview.3",
yeah, that should be the latest one
@thorn wing Package Manager should offer you latest versions
Unity.Rendering isn't in the Package Manager, as far as I can see
Oh, no, it is. as "Hybrid Renderer" ..
yeah, that's the one
they moved all rendering stuff out from Entities package
old and new rendering things are now at Hybrid package
@thorn wing https://bintray.com/unity/ you can check here both the stable and staging packages and what version the latest is
Hey guys,
I have some troubles with procedural meshes. I have a lot of different meshes that I want to merge (as a part of the LODs system), at some specific moments (player actions and AI). I was hoping to use some burst optimized jobs. but modifying shared component, especially in a job isn't really the best idea ever. I guess I could create some components with some blittable array (btw is there still no support for that stuff from Unity?) and having a custom rendering system. But I don't really want to cut myself from ecs updates. So I'm using MeshRenderer with a bunch of entities specially to manage the LODs System but it doesn't seems like it's possible to use combine meshes and update the RenderMesh component inside a job. Or I'm wrong? Well what would be a good approach of this problem?
Thanks π
Hey @gusty comet , I haven't played too much with the new rendering system lately, but CombineMeshes may not be thread safe - I'll have to look at it further
if you could store the vertices in a NativeArray and then construct the mesh that might work π€
@coarse turtle it doesn't need to be thread safe. It's a readonly process. So yeah your guess would be having a custom mesh + a convertion system i guess?
Btw Γ native array? I can't have them inside a component right?
I've been following the videos, and then found this post https://software.intel.com/en-us/articles/get-started-with-the-unity-entity-component-system-ecs-c-sharp-job-system-and-burst-compiler
I've got the code the same, but in MovementSystem, on line 41 I'm getting an error for 'this'. Saying cannot convert from MovementSystem to int
If I put this: JobHandle moveHandle = movementJob.Schedule(this);
Instead of this: JobHandle moveHandle = movementJob.Schedule(this, 64, inputDeps);
It compiles.
iirc the batch count was removed in some version, that's why
Yeah, in 0.0.11
IJobProcessComponentData.Schedule function no longers takes the number of batch iteration count. Batch iteration count is now always implicit to be the size of a whole chunk. This requires changing all code using IJobProcessComponentData.
thanks
@thorn wing if you see old tutorials, you see a lot of [Inject] in them, that is going away in the future too
so don't rely on it too much if you are learning Unity's ECS for future use
that being said, Unity itself still uses that in the "new" Hybrid Renderer :p
they tell others it's going away, yet they keep releasing their own packets that rely on it. that's not the right way to show example to others :p
Difficult sifting through stuff, finding the most up to date info... feel like I'm getting in too early
GDC will likely be their next big push so all the deprecated things COULD be gone by then. Would help with the sifting
That is purely a guess though
I really think the main limiting factor atm is Unity's own systems relying on it
```cs
// code
```
doesn't want to do it in an edit
Btw, I highly recommend going through the forums and viewing the code snippets posted there
you can start piecing together the structure and the new APIs
and since [Inject] is going away sometime, the ComponentGroup API
isn't going to change too much, so you probably want to switch to using that
@gusty comet you can have a NativeArray in a SharedComponent instead - sorry I missed the question
Well I'm not going to spam shared component for fun x) it's already a problem to have a render mesh as a shared component, for my case.
Unity's visual scripting is ECS/DOTS based now
@urban rivet is there a thread or blog post about this ?
@knotty radish there's a forum thread
π€ π€ π€
Also. Everytime I see DOTS I dont see Data Oriented Tech Stack but rather Damage Over Time 'S'
With Unity quickly moving to DOTS (Data Oriented Technical Stacks - our ECS framework) we had to reconsider our original VS release strategy. We are now stopping development on our monobehavior solution and moving to VS for DOTS exclusively. This will enable the team to focus on one tech and improve our overall long term velocity.
Before making this decision, we asked ourselves about the consequences for our monobehaviour users. We came to the conclusion that since good monobehaviour VS solutions exist already in the Asset Store, we had to prioritize DOTS. It is very important to provide a way for non-programmers to interact with ECS. There are a lots of tools we will need to rebuild for DOTS and VS will be a big part of it.
Unfortunately this will delay our first release to public that was scheduled for 2019.2. In the meantime, we are going to share regular incremental releases with the community through the DOTS forum. These will be bleeding edge releases that will have issues and that are not intended for production use. We will be sharing current state of work to be fully transparent and to gather your feedback.
The overall goals remain unchanged and VS will still be a non-programmer friendly way to create script in Unity.
I'm sure you will have many questions, so please ask away! ```
Ah
Interesting to see the stopping of the GO for Visual scripting
Im not surprised, just interesting
I'm sure they'll talk more about this change at GDC
Yea
or at least have some new target for it
Same deal as last year. Lots of "OOoooooh" but more info is done in March
Thanks!
Curious if we will see the arrays and strings problem sorted by then π
Strings are already "solved" in the new version
Oh?!
Then all that is left is arrays (unless that is solved) then I wont need to reinvent the wheel converting an API level json to an arbitrary entity
Well Arrays could also be used with DynamicBuffer but I would opt for refactor from scratch for a use case like yours
My case scenario: I unfortunately dont have control over what is sent to me via json object
(Not saying it's easy or it won't take long to do, just saying what's best case for the thing you are building)
As for the string support. Which version is this?
It's a way to use strings not something handling strings by default
And it's the last version so v23
Ah so not package managered yet
I just looked?
I assumed it was the staging packages that you manually edit the json
nah, it's on main
Hmmm
make sure you set package manager to show previews
"com.unity.entities": "0.0.12-preview.23"
but you should still see it if you have any entities package installed
these are the latest things on regular registry: ```json
{
"dependencies": {
"com.unity.burst": "0.2.4-preview.41",
"com.unity.collections": "0.0.9-preview.11",
"com.unity.entities": "0.0.12-preview.23",
"com.unity.jobs": "0.0.7-preview.6",
"com.unity.mathematics": "0.0.12-preview.19",
"com.unity.rendering.hybrid": "0.0.1-preview.3",
"com.unity.test-framework.performance": "0.1.50-preview",
you need to add that rendering.hybrid manually to manifest atm I think
at least I didn't see it listed today
I saw the hybrid rendering in the package manager so it should work
you also need that test framework now with preview.23 or you get some errors
I could swear I saw the Hybrid Renderer listed when it released
but I didn't see it today (could be 2019.1 related thing)
I actually grabbed the hybrid in the manager
However, It looks like I will need to manually edit the json for preview 23
As it says Im up to date with 21
2019.1a14 ... assuming that is the latest alpha atm
2019 beta is out
But you should see everything if you have preview packages shown in the package manager
all 2019.1's should show it
I'll double check in a few mins
they upped the min engine version on preview.22 from 2018.2 to 2018.3
Do you have the registry targeting staging ?
you don't need staging for this
that snippet I just posted is working on my end
but staging has the same packages (and tad newer mathematics)
Also, this is what I need IComponentData to be able to handle ;)
public struct APIMessage : IComponentData {
public string type;
public Data data;
public struct Data {
public string id;
public InternalData[] randomBlobs;
public struct InternalData {
public int[] something;
}
}
}
something like that.
Can't handle list of list at the moment, need to find another way (not sure it will ever change)
Would it be feasible assuming randomBlobs wasnt an array?
Still likely would break on "something"
Yeah you could put a buffer on that entity and have an array of Data (without randomBlobs being an array)
Then you would fetch APIMessage and the Buffer (which are on the same Entity)
@knotty radish any docs on how one would utilize strings in p23?
Unless you meant the NativeStrings π€
// If you need to store the text of "War and Peace" in a single object, you've come to the wrong place.
Looooool
Interestingly NativeString64 is not blittable
While NativeStringView is
Haven't seen any docs yet
So far have yet to find any string support that is really viable atm 
At the very least, no where that I can do it without using "unsafe"
Since NativeStringView needs a char*
Doesn't NativeString512 or NativeString4096 fit your needs ?
Hum it's inside Entities package
Doesnt entail that it is blittable though
I dont see a reason for it not to be
Debug.Log(UnsafeUtility.IsBlittable<NativeStringView>());
Debug.Log(UnsafeUtility.IsBlittable<NativeString64>());
Debug.Log(UnsafeUtility.IsBlittable<NativeString512>());
Debug.Log(UnsafeUtility.IsBlittable<NativeString4096>());
True
False
False
False
And as I mentioned, NativeStringView is blittable, but the only way to actually set it, is to be in unsafe context, which seems like a weird requirement to use a string :\
Understandably it is doing unsafe context in the backend, but on this level it probably shouldnt be needed
I think Words.cs give a little bit of explanation about these things
Words should be usable in a IComponentData struct
Yeah but it may not work inside a job
(since it's using a singleton from somewhere else)
But at least in a system update loop it will work
That would be a ECS solution while not being jobifiable
Im a little sad there is not an implicit conversion between string and say NativeStringView
The words/NativeStrings are not serializable 
Hmmm is there an ECS equivalent to JsonUtility?
@solar ridge ECS package tests seem to use JsonSerializer.Serialize()
dunno if that really helps anything
also don't ask me where that is from (JsonSerializer they use), just saw they use it π
They get it from their Properties namespace. π€
So... It has to be a reference type to use that
but... that means it works completely against IComponentData
Confused...
public static string Serialize<TContainer>(TContainer container, JsonPropertyVisitor visitor = null) where TContainer : class, IPropertyContainer;
public static string Serialize<TContainer>(ref TContainer container, JsonPropertyVisitor visitor = null) where TContainer : struct, IPropertyContainer;
Deserialize
That is my current issue
public static T Deserialize<T>(string json) where T : class, IPropertyContainer, new()
My other option is:
public static ObjectContainer Deserialize(string json)
JsonUtility was nice as I could just create the structure and be done, but with this NativeStringView not having either serializable nor an implicit conversion from string, things get really iffy with json
have a look at the json.net plugin https://assetstore.unity.com/packages/tools/input-management/json-net-for-unity-11347
or DataContractJsonSerializer. It probably wouldn't work out of the box because its quite strict but you can customize it if you own the objects or are willing to wrap the unity ones. https://blogs.msdn.microsoft.com/carlosfigueira/2011/09/05/wcf-extensibility-serialization-callbacks/
public static class JsonSerializer
{
public static string Serialize<T>(T value) where T : class
{
var serializer = new DataContractJsonSerializer(typeof(T));
using (var stream = new MemoryStream())
{
serializer.WriteObject(stream, value);
return Encoding.UTF8.GetString(stream.ToArray());
}
}
public static T Deserialize<T>(string json) where T : class
{
using (var stream = new MemoryStream(Encoding.Unicode.GetBytes(json)))
{
var serializer = new DataContractJsonSerializer(typeof(T));
return serializer.ReadObject(stream) as T;
}
}
}```
This post is part of a series about WCF extensibility points. For a list of all previous posts and planned future ones, go to the index page. Continuing on the topic about serialization, the serialization callbacks are methods which, when tagged appropriately, are called by t...
The Extensibility is nice, however most of the examples there have backing fields. You can not have backing string fields :\
Interestingly IDataContractSurrogate doesnt exist according to rider?
I can find it by "shift+shift" find in project, but it wont use it oddly
Shift+shift?
rider shortcut
Okay, feeling dumb again: "rider"?
Jetbrains Rider
IDE from jetbrains
Oh, okay thanks.
(The superior IDE)
Oh no I'm using the inferior one AGAIN?
Loool
Use what you want
But in this case
Which version of unity are you using atm?
if 2019.1b, mind checking to see if implementing "IDataContractSurrogate" compiles for you?
I'm still going through the release notes for 2018.3...
Hmm "CodeTypeDeclaration" ... does unity roll its own variant of DataContractJsonSerializer? 
That isnt good...
- Add preliminary support for burst AOT settings in the player settings```
that's from new burst package which still is on staging (and seems to require editor side change too so need to wait for next beta or two)
well, that's not really ECS news but I guess it can be seen related π
that AOT thing is needed now when apple started to reject Burst compiled things as they had burst compiled things on separate file or something
Ok. So my plan to remap the string I get from a json to the ECS NativeStringView is failing thus far because it seems The DataContractSerializer is different in unity from this msdn doc https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.json.datacontractjsonserializer?view=netframework-4.7.2
Newtonsoft is the answer I think for my solution π€
Curiously, in WordStorage: kMaxEntries. Is that the number of strings that can exist in total across the board? Because if you have 100k entities all storing a string, then I will hit that EXTREMELY quickly
hey everyone, this isn't really an ECS question but more about job system and IJobParallelFor
so I'm trying to run a jobified marching cubes (marching tetrahedra really) on a NativeArray<float> which is basically an unrolled 3D density texture
so every Execute() of this job is calculating the triangles to output for that voxel. each voxel is broken into 6 tetrahedra, and each tetrahedra could contain 0, 1, or 2 triangles
so each Execute() needs to return between 0 and 12 triangles, but I haven't had any luck finding the right NativeContainer yet
I'm about to just allocate a NativeArray<Vector3> (vertices) and a NativeArray<int> (triangle indices) to worst-case size, 36 * voxelCount
but that seems super wasteful
I thought I would be able to add to a NativeList<> from multiple threads if it was [WriteOnly] but apparently not
I can accomplish what I want with 2x NativeQueue<>.Concurrent, but then I can only Enqueue
I saw a code sample online where the author appears to implicitly cast a NativeQueue<> to a NativeQueue<>.Concurrent when initializing a job struct
but that throws an error in my environment (2018.3.4f1, com.unity.collections 0.0.9-preview.11)
so if I could figure out how to convert back and forth between a NativeQueue<>.Concurrent and a regular NativeQueue<> that would solve my issue
the same script imported into my project throws the same error
it seems this was supported in an older version of com.unity.entities π
as of com.unity.entities 0.0.12-preview.23
YOu may want to check to see if there is a "GetConcurrent"
I thought they removed the implicit conversion
@chrome pawn

@solar ridge as long as you're around I have 2 quick questions
I would like to access NativeQueue<>.Concurrent.Length but obv can't so I think what I'll do is increment a thread-safe counter every time I enqueue
is this still the correct way to do a thread-safe counter?
also, where did you hear about removal of the implicit conversion? I want to keep up to date with API changes like that but it seems like there' s still so much undocumented stuff
Mm it was one of the changes a while back. I remember aeeing it on the forums
it looks like Unity.Rendering got dropped from com.unity.entities as well?
it's now in Hybrid Renderer
after updating to com.unity.entities 0.0.12-preview.23 it seems Unity.Rendering and MeshInstanceRenderer etc are gone
ah thanks
@chrome pawn https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/ReleaseNotes.md read the upgrade guide part
it describes the relevant changes
Hi guys π Just wondering if you knew where I should start to search for my problem : no entities when I build.
Well at least I think it is my problem x)
@gusty comet do you rely on some editor only scripts?
one case where that would happen is like if you get the active scene in editor using gameobject scene -> entities conversion tool but get the original scene via editor only api
Most of my code start with bootstrap π’ and I was able to get a debug message to be sure that the boostrap function started @dull copper
can you roll back in version control to see where it still worked?
could help in narrowing down on the root cause
I guess I could try step by step yeah, a bit old school but always good ^^ I didn't test it before so that's gonna take a bit of time, thanks @dull copper
I'd really just check the first commit before and after the jump to preview.23 really
as that's the most likely place here if you've upgraded to .23 recently
Tiny getting C# on next release:
We are kicking it into high gear when it comes to C# support and are we working hard to bring it to users as soon as possible. However, this means we will be focusing all of our efforts and will not be releasing anymore updates until C# arrives.```
<https://forum.unity.com/threads/0-14-1-preview-release-and-an-update-about-c.621769/>
nice, it sounds like there's distance to cover so they need the space to do it
I don't really care about Tiny myself (it's nice but doesn't really concern my projects), main reason I want them to get this done however is because I suspect that we don't really see full ECS scene editor before they get Tiny merged it
(because it would make sense that they expanded on what they have on Tiny for the editor instead of building two duplicate systems and then tried to merge them together)
I've got an interest in open world rendering again using unity terrain so I think probably, I'll need to do that convert to ecs stuff
I don't think unity terrain works in pure ECS yet
I mean all the junk that will go on it, rocks, villages etc
Getting this error
when trying to create an instance of this tiny system:
public class ChangedSystem<T> : JobComponentSystem where T : struct, IComponentData {
struct Job : IJobProcessComponentDataWithEntity<T> {
public void Execute(Entity entity, int index, ref T c0) {
Debug.Log(entity);
}
}
protected override JobHandle OnUpdate(JobHandle inputDeps) {
Job job = new Job();
return job.Schedule(this, inputDeps);
}
}
like this: _world.CreateManager<NetCode.ChangedSystem<Health>>()
i mean...
i have no idea
@dull copper any idea? π
got it running by making it non-generic
doesn't do what i need anyway so its not useful
lol
i've been able to get generic jobs to work but they have to be instantiated to a static somewhere for the system to find them and compile, i guess to be able to pull out the types being substituted in.
Be nice if [BurstCompile] took a name parameter
@dull copper you have any idea how to solve this in a good way: https://forum.unity.com/threads/fastest-way-to-find-which-entities-had-a-component-changed.624607/#post-4187287 read my last two posts
im comming up against a hard wall performance wise
not really no :/ I've also had some detours again, should get back to learning ECS better soon
@trail burrow without knowing anything, you know how hybrid stuff limits things on the main thread?
could there be any clue there to force something similar to happen on other threads?
I have zero clue on what I'm talking about here, just throwing out random thoughts π
If you've got Joachim in your thread I'm sure an answer will come, it seems like your use case is a perfect candidate to get them thinking
Yeah I just can't get it to be fast enough, I want to be proven wrong, because it'd be great to port this to the ECS
filter could handle it if change of component adds a component
seems a bit of a hack though
@urban rivet having to do a unique component per change to another component
is... well... hacky doesnt do it justice π
lol but I'm used to using Unity you see.
do you need to explicitly dispose of Allocator.Temp native containers? i just realized i wasn't disposing of some, and it wasn't throwing up leak errors.
yes
(atleast for me, I need to dispose them manually, even if they are Temp containers, or else my debug console will get filled...)
https://forum.unity.com/threads/burst-compiler-crash-stack-empty.625759/ anyone have a clue?
var is definately the right kind, of course?
what does the assembly say?
I'd assume but Unity does need to write some types for the compiler to infer, or I read about this, so it's best to check if it's really what you're expecting.
it took me a year to make peace with var being fine
Var just means use the type of the assignment expression
I just can't make this code Burst compile
Been turning this code inside out
It simply will not compile
What type is your c field?
@soft nova boolean
i did get it executing in burst
but performance is identical/worse in burst
which seems...weird af
anyone have some examples of how to use DynamicBuffer<T>
@mint iron not much more to it than that
buffer can then be used like a list of sorts
okay, i meant without entities, creating/destroying your own. it seemed like header was all protected and yeah, started building an imposter but wondering if there's something im missing.
@mint iron can you even use it without entities?
you kind of can, but it seems like its not intended.
if you want to make your own buffer you can do something like this: http://hatebin.com/mgwwccwskm
awesome, thanks
What in the world is an entity component system
What is that link
wikipedia lol
Itβs broken
mm works for me
Hmm
in any case, the first para is most important and ill just paste it here
Entityβcomponentβsystem (ECS) is an architectural pattern that is mostly used in game development. ECS follows the composition over inheritance principle that allows greater flexibility in defining entities where every object in a game's scene is an entity (e.g. enemies, bullets, vehicles, etc.). Every entity consists of one or more components which add behavior or functionality. Therefore, the behavior of an entity can be changed at runtime by adding or removing components. This eliminates the ambiguity problems of deep and wide inheritance hierarchies that are difficult to understand, maintain and extend. Common ECS approaches are highly compatible and often combined with data-oriented design techniques.
Um ok
key points
Entityβcomponentβsystem (ECS) is an architectural pattern
ECS follows the composition over inheritance principle
and with Unity's ECS, the last sentence too
god i wish they would expose the low level chunk byte data to us
i.e. the internal calls they use to calculate offsets and such
for various component types in a chunk, etc.
a bit of a noob question i suppose:
is there a way to write a system that'll loop over all entities that have both a Rigidbody2D and a IDataComponent (while accessing/changing data for both) without using Inject?
my initial try was:
- create a component group in OnCreateManager for the two types
- loop over entities
but i'm at a bit of a loss as to how to get the reference to the rigidbody through the entity
ForEach((Rigidbody2D rigidbody, ref YourComponent yourComponent) =>
{
// do something
});
^ for the simplest way
Ofcourse i get an answer right as i leave home :P
Thanks a lot, will try as soon as i can
(im honestly having trouble understanding which info about UECS is up to date online so im asking probably stupid questions)
Hello!
I'm messing around with the ECS System and trying to make a few knights fight each other. I made a system that selects a target. Now I'm trying to get the Knights to move to their targets.
public class MovementSystem : ComponentSystem
{
private struct Filter
{
public NavMeshAgent NavMeshAgent;
public TargetComponent TargetComponent;
}
protected override void OnUpdate()
{
var entities = GetEntities<Filter>();
Debug.Log(entities.Length);
}
}
But I don't get my any matching Entities. If I only filter on NavMeshAgent, it works as expected.
[Serializable]
public struct Target: IComponentData
{
//public int index;
public Entity entity;
}
[UnityEngine.DisallowMultipleComponent]
public class TargetComponent : ComponentDataWrapper<Target> { }
looking at Unitys ECS related talks at upcoming GDC, saw these:
https://schedule.gdconf.com/session/follow-the-dots-presenting-the-2019-roadmap-presented-by-unity-technologies/865465
https://schedule.gdconf.com/session/connecting-the-dots-the-unity-data-oriented-technology-stack-presented-by-unity-technologies/865473
https://schedule.gdconf.com/session/creating-instant-games-with-dots-project-tiny-presented-by-unity-technologies/865468
from first one: Join Martin Gram, the Product Manager for our Data-Oriented Technology Stack (DOTS), and guests as they spotlight the latest DOTS features. They will also unveil some exciting high-level systems coming your way in 2019.
HPC# Physics pls π
That and .... rendering / networking and we should be pretty solid yes?
Networking has a semi demo already
navigation is still missing too
Ah yes
like, basic pathfinding etc
There is a forum post
Where there is a basic system working, but yes
Navi built in would be niiiiiice
I could imagine people doing some A* in no time if they need it now
I think physics first would likely be more prominant
Just because of the logic for avoidance may derive from that as well
Not saying physics is needed, but just that it would be the likely flow
it's one of the basic things most people do need before they can jump to pure ECS
even if you don't do simulations, most games rely on queries (raycasts/sweeps)
Yeah. I made a geometry wars clone a few years qgo and used a navmesh for input and pathing
So I can see many uses within ecs context
Physics > Navigation > Networking is my guess on how they will prioritize
the existing NavMesh navigation works in burst, at least everything within UnityEngine.Experimental.AI
so you should be able to use NavMeshQuery to pathfind in ECS
@mint iron that namespace doesnt give me a lot of confidence π
haha yeah
i guess all of ECS is experimental though
it actually worked really well for me when i tested it, but there's a few gaps still, like NavMesh.FindClosestEdge has no equivilent. I had to cache the triangulation and manually map all the outside edges.
Unity is hosting a Visual Scripting roundtable at GDC where we will be showing our first DOTS build and discus current direction. We have space for 10 participants and are mostly looking for experienced developers (people with VS experience, not necessarily programmers) this time around.
Wow, 10
well, even 10 is pretty much if you are going to have a discussion
I'm not 100% convinced it's good to hear mainly people who use node graphs though
but I guess that doesn't rule out programmers
just discussing the usability is one thing but without knowing the technical side, it's hard to make reasonable requests
all I hope for their VS is to provide all the means to keep the graphs clean
I wrote a bit about this on the forum thread too
I don't really plan to use their VS but if they provide tools to keep things clean, it will just make it way better experience for everyone
(and give people less reasons to call VS a spaghetti mess)
I agree with everything π
I may end up using it if ECS is actually a massive pain without it, but I can't imagine that being the case
also it'd be nice to be able to make a bundle of nodes that could be dropped into an editor field/location that has a defined behaviour
like, an editor window that has custom buttons that are literally just node bundles
but this is my editor tools brain thinking
It be nice to be able to create back end tools for front end Vs regardless if you are a programmer or not :-)
Especially if used in say an event like setup
Pardon me for a question that could have been asked a bazillion times, but can we expect ECS out of preview in 2019 or 2020?
they targeted 1.0.0 for the Entities Burst package for this summer originally but better really wait for GDC for their updated plan (they should reveal some new stuff related to this as well)
that being said, Entities package is just one part of the puzzle, we still need those ECS'fied libraries to fully utilize this + full ECS editor (which may or may not happen before 1.0.0)
Dont know if it was enities. I think it was 1.0 burst for the summer
oh right, it was for burst, I missed that line, my bad
yeah, this makes more sense
Which summer is "this summer"? πΆ
well, it was for Burst only (remembered it wrong)
that sounds feasible
I'd want them to support different instruction sets on the same platform tho, they've said they want to do it but it doesn't seem like huge priority
I'd want to use AVX on CPUs that support it and drop to SSE2 on CPUs that don't even support current default (SSE4)
I can animate so many sexy boxes
Current main pain point: vegetation rendering in HDRP (and no Vegetation Studio Pro doesn't work at all with it atm)
@urban rivet didn't the author share SG or ASE nodes for it?
but.. these will be broken on 5.3+ π
hope they merge the custom node soon
so much for having any grass before next friday deadline
as for "he did" I know cos I was the one requesting it
I'm just sulking due to HDRP node stuff π
sulks even more
How do I access entity/entities in a system that is not directly running on them? For example if I had a turret and my turret system need to find all entities with the "turretTarget" component how would I do that?
GetComponentsInChildren (it will also find components on self)
Err @urban rivet is that in ECS? Or are you talking about GameObjects?
Looool
No worries
Was about to say! I have more to learn tonight then! Thought they had released another version
I was stuffing my face not even reading anything π¦ haha
That would be an "interesting" solution though
You do a lot of work on here and the forums so a mistake everynow and again is perfectly fine :-)
It would be
I enjoyed your writeups on ECS btw
Thanks for teaching me more about it π
Hey man! We are all learning this wonderous new tech together π the more we share the better
Im amazed at what some have already accomplished
I find it absolutely amazing, very impressive performance
I am looking forward to the ecs scene converter + samples to dig through
Yeaah! Hopefully new docs in March but we shall see
it'll be interesting to see perf in a large open world
World handling suggestions from unity is a small request I have now. More so how to use them appropriately
As I can make a world... but to make it tick is.... interesting
I guess that's partly why vegetation seems to be so long coming with terrain? currently it's stuck in the dark ages
Yeaaa
Terrain I remember in my bachelors course. It was entertaining as that was just starting to be unity5
The concept is neat, but not a lot to do there
But lots of things this year and hopefully that includes terrain for ya :-) Im interested in the Visual scripting, animation genlock support, and audio dsp after ecs.... LOTS of potential
this year sees the foundation of it being deterministic
that means in addition to performance by default, you are looking at networking by default, especially with physics
Yeeep. That one may be a tricky one just due to a component of that out of your control. Hardware for ecs is rather static. Network lines can be in flux
There are ways to mitigate issues, but I would NOT want to be the designer of that system
And if the graph stuff turns out good then people will just click together networked games that run really well. I would have called you crazy 5 years ago
Yeeeeeaa!
I remember showing a teacher events in Unity and he was like whaaaa! So I kind of want to go back and show him VS
Games in the future will have an intersting boom I think
Also as an aside, something I havent tested just yet in Unity as I have been away for the weekend, passing delegates to jobs.
Delegates themselves are non blittable, but the pointer associated with them is... can anyone see something going wrong with using a delegate this way that I should be aware of? See FunctionPointer<T>
Where T is your delegate type
i was wondering the same thing :S it seems to work fine but maybe does something evil im not sure
here's my generic jobs as functions experiment https://github.com/imxzjv/UnityBurstFunctions
Hi guys, do you have some sample about world serialization? I saw something in SerializeUtilityHybrid but I don't understand, it seems that they use a game object to save shared components
@gusty comet you might want to read 5argon's blog: https://gametorrahod.com/unity-ecs-serializing-ecs-data-252231e5b16d
I haven't personally played around with world serialization yet, hoping I can do that soon π
do static methods, marked to be aggressively in-lined (and called from jobs ofc) get compiled by burst?
@latent walrus you 'dont'
If you are talking about parenting, the attach system. If you are meaning something like a linked list relation, then it sounds iffy
Thanks @coarse turtle π
I found the Unit Test about serializing, which was good enough but having a blog post is damn cool !
Btw everyone, I was wondering how the shared components were working (I mean how do the know that they are shared). It seems like there is some hash code, does that means that a RenderMesh with the same Mesh (ptr) and same Material(ptr) get the same Hashcode and so is the same component?
@solar ridge is there somewhere I can read about the attach system? I can't seem to find anything
@winter veldt https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/Documentation~/transform_system.md
It goes into some detail but basically you register the entity to be manipulated by this by adding Attach or removing attach. Then it works in relative to parent positions as it would normally
anyone having trouble with GetComponentGroup()? When I call it in OnUpdate() method in a system it seems to exit the OnUpdate() loop completely, mysteriously
I'm able to get my component through entityManager.GetAllEntities(), but really want to be able to just get the components directly instead...
i think you only want to use getcomponentgroup in oncreatemanager or onstartrunning
heh not sure how to paste code but anyway I recall GetComponentGroup() is expensive and should only be done once and then cached
that makes sense, but I'm still confused why it would just stop execution of OnUpdate()... originally I had it in OnCreateManager() but had a race condition with entities not being registered until after OnCreateManager() and I just wanted to get something going. Will have to figure out a different approach π
@full stirrup thanks!
hmm it shouldnt really matter if the entity exists or not, if it has the components that fits the declared ComponentGroup, it should show up in OnUpdate, unless I'm misunderstanding
To properly paste code you want to hit tilde key 3 times on its own line with cs right after it to signify c# then on the next line you start your code, then at the very last line, on its own line, do 3 tilde again so it ends up like this,
```cs
void Start()
{
Whatevs();
}
```
which then would make this.
void Start()
{
Whatevs();
}
lets see
protected override void OnCreateManager()
{
var query = new EntityArchetypeQuery
{
All = new ComponentType[]{ typeof(Behaviour), typeof(Target), typeof(Character)},
None = new ComponentType[]{ typeof(Dead)}
};
attackGroup = GetComponentGroup(query);
}
hmm
make sure there is no space between the 3 tilde and the cs
thanks
Typically though, when it comes to smaller blocks of code, it is fine, but when I want to do bigger ones, I just go to hastebin and then link to it.
yeah i thought it would autoformat it, anyway thanks π
No worries, but yeah, pretty much just blocks it out and adds syntax highlighting.
How do I add the pixel perfect component for the newest beta build?
It's not in the package manager.
@scenic pelican you have package manager set to show the preview packages?
also not really an ECS issue π
What version of Unity do people use for ECS dev?
@scenic pelican
gif from newest 2019.2 alpha but even 2018.2 should have the preview packages toggle there
2018.2 actually doesn't it just shows everything by default
so if it exists, it should show
2018.2:
i don't see pixelperfect, it may not be available for 2018.2
no wait I take that back
there at the top
Hi everyone, very happy to have such a channel here
does anyone know if there is something like AddOrReplaceComponent?
that adds the component in case the entity does not have it and otherwise replaces it?
I would love an AddOrReplaceComponent
Did the Monobehaviour/GameObject system have AddOrReplaceComponent? You can always extend it with your own, right?
why do people struggle with ECS
it makes way more sense than the OOP game object, component system pattern
likely because it's in its infancy in unity and the code can be extremely different
I can think of many reasons:
- programming courses tend to teach OOP right after basics are down, nobody teaches ECS on those (unless you really seek for ECS content specifically).
- having done OOP for years, swapping the model in head can take some time, but this really applies to all new tools and systems you adapt
- ECS principles are relatively simple, I'd argue there isn't really notable difference conceptually in difficulty but in Unity's case, it's really more about how you should use their specific thing so that you get most out of it
- in Unity ECS, it's currently a constantly moving target so finding relevant info is hard when even Unity's own code uses things that are going away etc
I don't struggle with ECS, I just can't afford to change my main codebase for it until it's settled down a bit
it's a big game, imagne the pain of refactor for no reason that I can avoid
As someone coming from zero programming background even with a couple years fooling around with unity and learning c# there are a lot of things about ECS that I find hard to understand.
Recently I tried to replicate the new Boids sample for instance. I tried to do it without multiple sharedcomponentgroups. But now I'm getting errors about NativeArrays lasting longer than 4 frames or being disposed when jobs are trying to access them.
In the sample, they seem to be switching back and forth between componentgroup filters of half the entitys, and disposing them without calling complete. It's not super clear why I can't do the same thing without the second filter by waiting to the next frame starts to dispose.
Maybe that's because I'm not experienced or a real programmer but there's extremely little documentation up to date for me to reason this out without just trial and error.
I've now fixed the errors using Complete() but i still get errors when i exit while the job is running. Where would I even look to figure out how to cleanly end a running job and dispose the arrays without error?
Things like this are what I've struggled with anyway.
Awesome feedback
Noob question: Blank project with Unity 2019.1.0a10 and Entities 0.0.012-preview.23, any idea why I get the error: Library\PackageCache\com.unity.jobs@0.0.7-preview.6\Editor\JobsMenu.cs(43,60): error CS0117: 'NativeLeakDetectionMode' does not contain a definition for 'EnabledWithStackTrace'
@near gulch like others said i think largely because it's early days, and the core api seems to have only recently settled
along those lines, @blazing mural you're not alone π i've been writing ecs style code with my own little framework for years now and the unity system still took me at least a week or two to get used to. and i still struggle with certain things with it. as it matures and things are built to support it, i guess this will be mitigated
i've been recommending to most people to check out a couple of unite videos, they clarified a lot of things for me
one is where acton gave a great talk on data oriented design. i had to watch a few bits several times but it's a good way to get inside his head, so to speak
March 23, 1:00pm (San Francisco) - Mike Acton demonstrates best practices for component design to achieve a high degree of parallelism, minimum synchronizati...
and then this one
Come take a look at the past, present, and future of the Entity Component System (ECS) API. Software engineer, Aria Bonczek from the Unity Data-Oriented Desi...
the title speaks for itself but in short it goes over why certain things are being changed and helped me make the connections between the more confusing low and high level bits
another thing you can look at outside the examples are things like TransformSystem - i have to keep reminding myself a lot of the core stuff is being built on this now and we can fully inspect it π
Daddy here π
Hi Dad
How do I decide if something goes to onUpdate or OnStartRunning?
think it was RequireForUpdate(ComponentGroup)? someone will have to chime in on that
Might not be what you are asking for either lel
As I understand onStartRunning is run when the system starts up every frame and OnUpdate when it is updated
And I am asking myself what goes where
Ah not exactly what i thought then
Thanks anyways
ah no I was wrong, onStartRunning is not run every frame
only at the beginning
well then the question is, what is the difference between onCreateManager and onStartRunning (which code should go where)
In the Component or Shared Component DataWrapper Constructs if I put my class name then all of the non-blittable vars (and no blittable ones ofc) will be stored in the ComponentDataType Type instantiated? Am I someone close to understanding this?
Wanting to get a basic non-hybrid implementation going to take care of the persistent, non-persistent, data handling as well as pretty much everything but what has to be front end at some point
I'm relieved to have to look no further for DLL file API ideas and SQL implementations, and I need the Overhead cut back badly, ECS is an awesome way to go btw Unity Team, thank you guys
@junior fjord
OnCreateManager is literally construction, more or less the same so when you start the game; this is called because your EntityManager is now created.
OnStartRunning is when a filter meets the systems need. So for example you have a system that runs on Position and Selection, but all your entities have Position, this wont run. Then when you add Selection to an entity this runs because that entity now has Position and Selection
ah, that brings a good question I had
I want to create a data matrix of around 30,000 spryte Objects that are ever changing and use keep that matrix updated
BUT I have other elements that are also sprytes, how can I reference only the ones I need
depends how you need that, theres been discussion on how to manage 'value changed' on the forums somewhere
If you had one matrix system that controlled the whole thing, you would need sub systems that would control individual sprites
ok, but I can't get them by name or tag? because they have no unique elements other than that size and pixel data
then separate your sprites by different component types
Adding an empty ComponentData is considered tagging
I know I can't get the sprite but I want to store there vector data
That's enough to go on thank you, best way to learn it is to try it a lot until I get
one final question though would be will this store all of the variables until a system picks them up ```using System;
using Unity.Entities;
[Serializable]
public struct Pos_Data : ISharedComponentData
{
public float screenPositionX;
public float screenpositionY;
public float velocityX;
public float velocityY;
public float delta;
}
public class PLAYERPOS_0_COMP : SharedComponentDataWrapper<Pos_Data> { }```
and I think I need to make this an IComponent, remember telling myself that for some reason
Might need to change it, think you can change shared component data in a component system and it would affect the references for other systems but id go see what happens
@full stirrup thank you so much
It's very exciting, I isolated the input data via a web tutorial and I'm already getting 5ms improvement
dont forget that you can burst some of your jobs
tough for one thread to loop over input data flags every half a second or so
: O
I'm going to be in the API for weeks, this is a godsend honestly, you'll undoubtly see me again in a few days with more noob questions
it's like a low level "Living" database, when prefab implementation happens it's going to change the industry
Prefab implementation?
You mean setting up prefabs and instantiating?
It was somewhere in the API which I just have to get through all the errata and I can wrap my head around this
exactly what I needn't for my application, matrix based procedural gen, not scene dependant more open world
I'm going to benchmark memory and time stats and may do a blog when I get everything changed over
Entities vs. GameObjects
Our goal is to be able to make entities editable just like GameObjects are. Scenes are either full of Entities or full of GameObjects. Right now we have no tooling for editing Entities without GameObjects. So in the future we want to:
Display & edit Entities in Hierarchy window and Inspector window.
Save Scene / Open Scene / Prefabs for Entities.
Pretty sure you can do that right now somewhat
{
public GameObject Prefab;
}
public class ObjectTypeComponent : SharedComponentDataWrapper<ObjectType>{}```
It has to be hybrid styled so you add that to a game object in the scene and provide the prefab you want to use. I havent tried it to loop through some count of how many to spawn but used it to spawn individual prefabs around
The way I am using it at the moment is on multiple "spawners"... Since EntityManager has .Instantiate and its like EntityManager.Instantiate(spawner[0].Prefab)
It will probably improve
@urban rivet miss me? π
good news #1 from the ecs gang is here.... I hope tertle & 5argon will show up as well
Hi guys π Do you know how to convert an entity to a gameobject? The GameObjectEntity component doesn't allow me to set the entity and the entity manager π¦
adding GameObjectEntity to a gameobject identifies that gameobject as an entity
to do it in reverse I guess you would remove that component but i doubt thats going to have a good effect at runtime
@timmeh Yeah, those videos are very helpful, I've watched them both to death trying to learn while rebuilding the Boids sample, and I feel better with ECS in general, but I lack a lot of the knowledge that I guess most have when he explains things as "simple" or "straightforward" when talking about the hash map and things like that. I'm learning from trial and error as well though so hopefully it'll click a little more as I keep going.
No I mean that I have an entity and I want it to become a gameobject. Right now I have to create a gameobject and add componentdata manually. I'd like to just say : Hey! This is my entity, use it please.
Haven't used ECS much (yet), but IIRC you can send an existing entity to a manager to instantiate a copy?
The way I'd do it then would be to use a tag component to mark it as a prefab, ie. not simulated or rendered, and you could query for it. Or just disable it, if you manage that some other way.
Scenario, every entity has a ValueComponent that has an int on it. What would be the jobified way to get the largest Value from all of these and provide the entity in return? 
Send a NativeList of these ValueComponents and remove them each time you find one which is lower than the current highest value ?
NativeList you cant remove the same as you can a List
Create the job with the NatliveList, complete it and then you have your entity (the only one remaining in the list)
Hey all! Hopefully quick question -- is there a convenient way to mass-add components to an entity? I'd ideally like some way I can make component "packages" to ensure that I don't miss out on any components (or can more easily apply components to multiple entities that share similar properties).
There is a removeandswapback, is it not enough ?
Not actually familiar with that -- fairly new to ECS in general.
THat was in reference to my previous inquiry
Ahh. Got it. π
Mass add components to an entity, you can create entities with archetypes
that will add the tags but no data backing, so you will still need to call SetData on each component
You can also create/add/etc in a CommandBuffer
which will do a playback at a barrier
IE EndOfFrameBarrier
that way you wont invalidate any chunks in the middle all of the sudden
Soaryn there is a way to do a foreach over all entities with X component and you could test if the last entity had a greater value. Canβt give a code snippet at this time though.
Foreach is usually the lambda on the main thread
Also, foreach is not burst compileable
Another interesting question: Is there a way to get an entity from a ArchetypeChunk when using IJobChunk? π€
So how would I start a system in the second frame instead of the first for example (I want the system to only start after the CopyInitialTransformFromGameObject is run)
Why exactly do you need to start a system after this?
Understandably you want the effects to happen from the copyinitial, but ... not sure why the wait is necessary
I have "Humans" and every Humans needs a Goal. In OnStartRunning I want to filter out all "Workshops" (directly copy their positions to a NativeArray in my ComponentSystem since their positions never change)
And then the system just assigns a MoveTo Component to ever Human that does not have one (and it finds the destination from the cached NativeArrays)
Problem is, if I do this in OnStartRunning, the System caches the initial positions of the Workshops which are (0, 0, 0) instead of the position it would get after CopyInitialTransformFromGameObject is run
if there is a better way to do this please tell me!
I would actually work on the assumption the goals can change. (even though in your case they dont)
This thread while is on getting one entity they are getting all of that entity type: https://forum.unity.com/threads/how-get-one-specific-entity.619438
It would clean somethings: 1) You no longer cache the data twice, 2) this allows you to have moveable goals.
To fix your problem though...
OnCreate have it set enabled to false
have another system that after EndOfFrame enable it once
You would then have a frame delayer in a sense, but it isnt my recommended choice
As again, the caching sounds ... odd
@solar ridge Thanks for the suggestion. Why do you say cache the data twice? I only cache it once right?
You cache the data that is already stored else where and referenced through the entity id
so technically you have duplicate data,
I did this since it feeled bad to allocate an array on every frame for all the mine positions and copy all of them, allthough this will be exactly the same thing for most of the game
Here is the code snippet. Will need some editing to work for what you need.
But I am going to do it as you suggested for now thanks... just somehow feels like needless work
Partially, but if you make systems more independent it is closer to DDD or DOD
Also what do I do if my FindGoalSystem runs before CopyInitialTransform. Then also in the first frame all Humans would be assigned a wrong position
Rather than have intertwined dependencies
DDD or DOD?
ah ok
Soaryn if you look back in the project channel and you will find the code snippet not an image.
But still, if I then cache the positions in OnUpdate instead of onStartRunning I would still cache the wrong positions for my job if CopyInitialTransform didn't run before
Well... for now you could use [UpdateAfter()] on your system
but I think the problem, as odd as it sounds, needs to be refined. I'm not sure of many solutions @storm ravine may be better at pathing / goal finding since a nifty little rts looking game is in their wheelhouse
Biggest oddity I have with the current gen system is the Hybrid approach. It is good for prototyping, but I'd stay away from most of it for end work. Just because of how influx everything is
I want to say Pure ECS all the way, but that doesnt fit everyone's needs
I mean I am just at the bare start, I can refine the problem π I am happy about any suggestion
I have the Humans (they have Human component) and I want them if they don't currently have a goal to get a Goal by a system somehow
So just know, allocating a NativeArray everyframe is actually ok
later on they will decide which mine is best for them exactly etc
As long as it's lifespan is <4 frames
Ah! In that case. There are a couple solutions
System assigning goal : Any Human who does not have a goal tag gets one; ignore goal tagged humans
System cleaning the tags: Goals met or goals invalid
Also note, there have been many talks on whether or not it is advisable to add/remove tags runtime for performance and I think it wound up being too dependent on call frequency. In this case, it should be fine to add/remove as much as you'd like
Yes that is what I am doing I guess. The FindGoalSystem assigns a "Goal" tag and the MoveTo component which then directly sends the human in the right direction
which led me here since all humans went to (0, 0, 0) π
because CopyInitialTransform had not yet run
but probably the best solution is to actually use UpdateAfter and cache the positions in OnUpdate instead of OnStartRunning as you said
Also check the goals for the tag copy
I think that tag is removed from the entity
so you can check when it has been applied
Would have been nicer without any dependence at all, especially since the dependence is only needed for the first frame of the game π
which solves your original dilemma
There is an IJob that is run "RemoveCopyInitialTransformFromGameObjectComponent"
So I'd assume "CopyInitialTransformFromGameObject" no longer exists after frame one
which case you can subtractive search with "CopyInitialTransformFromGameObject"
yes I think the problem is that I never know how much performance something costs. Using UpdateAfter or doing a subtractive search as you said all give me a bad feeling since I think I am potentially loosing performance for something that is only needed in the first frame
No no
but that is very premature optimiziation I guess π
Every entity at the start has "CopyInitialTransformFromGameObject". After first frame, that component is gone
much like the Goal component we were talking about
so when you search for viable goals
search for goals that DONT have that component on it
exactly but I will always do the subtractive search, so unity will in every frame have one more condition to check on the archetypes
It will only do those searches if everything matches
Yes I should search for
Has(Goal) AND HasNot(CopyInitialTransform)
erm no
HasNot(Goal) AND HasNot(CopyInitialTransform)
Errr....
Search for [Human][No-Goal]
For [Human][No-Goal] Find [GoalTarget][No-CopyInitial]
then add the appropriate toggles for each
Note, you can have a LOT of IJobProcessComponents running
There is a lot of early optimization for a system that has a lot more optimization than gameobjects
What do you mean by For [Human][No-Goal] Find [GoalTarget][No-CopyInitial]
As I understood it I should search form
[Human]&&[No-Goal]&&[NoCopyInitial], right?
Your human isnt the thing with CopyInitial right?
ah right no it isn't!
You are looking at the goals that you have set with CopyInnitial
So you will need 2 lists
1 of viable humans, 1 of viable goals
I'd actually recommend
Getting viable goals first
and then pass that list to the human job
first human there gets the goal
all humans there would get one of the goals as I thought it
ok, so now I will
in OnUpdate: search for [IsGoal] &&[NoCopyInitialTransform], copy their stuff to native arrays and pass them to the job using goalGroup.GetComponentDataArray
and then have an IJobProcessComponentDataWithEntity that searches for [Human]&&[NotHasGoal]
how do you mean that? my current code is like this:
mineGroup = GetComponentGroup(typeof(Mine), typeof(Position));
Debug.Log("Whatsup");
var entity_array = mineGroup.GetEntityArray();
mines = new NativeArray<Entity>(entity_array.Length, Allocator.Persistent);
entity_array.CopyTo(mines);
var positions = mineGroup.GetComponentDataArray<Position>();
mine_positions = new NativeArray<Position>(positions.Length, Allocator.Persistent);
positions.CopyTo(mine_positions);
nevermind that would work, but you will need the entity of the goals too
Goal == Mine for now (later other Goal types will be added)
so you don't readd them to anyone else
ah of course it will not be persistent anymore, but TempJob
And Tag them with [Taken] or something
Ah but there can be many Humans in one Goal (think of Goal like a gold mine for now :D)
thanks for all the help!
Yep yep
Does anyone know how I would pass a subtractive to GetComponentGroup?
Ah I found it, nevermind
Do I remember right that there was already something implemented for using navigation meshes in the ECS? If so, where do I find it?
if it is jobbified isn't it ecs ready?
Is the hierarchy available for ECS yet?
can someone explain how the Any component query is useful? how is specifying a component may or may not have certain components handy, isnt that the same as not including them in an archetype query?
@safe lintel I think it has to has at least one of the components
so it has to have any one them
ahh
basically it is Component 1 OR Component 2
thanks, that would make more sense than what I had thought
@toxic mural if you mean like for transforms yes
you make 2 entities then you make an 3rd proxy entity that has an attached component specifying the parent and the child
Oh. No there is nothing except the entity debugger atm
Backend work first, then front end support
Right right. True. Thanks.
ECS is like this itch in the back of my mind, I keep wanting to dive into it but also want to wait until its 1.0
I remember seeing some Unite video that showed editor integrations that I thought was 2019.2 so I'm hoping it wont be much longer
Oh hrm
I think that was Unity Tiny
Which is not QUITE what you want
Burst 1.0 was slated for this year
I think 19.2
But that is not ECS
As I'd imagine all the big (was it 7?) need to be done before 1.0
Good point. And really the last thing my project needs is another "hey lets start over but with a new paradigm" again
It just sounds so cool though
You can use some ecs components now to help the backend of your code a lot
Im using it now for an entire API listener system to allow for entities to be created based on external json API calls
Ah cool
But I think they say somewhere that you should not use it for production
Talk to @storm ravine about that. He has a forum post on the fact that you CAN do it
or only use it for production if you just are starting out and plan to release end of 2019 earliest
I took that as an hint that we can hope for the full features end of 2019
It is not built for production, but it is code
so use it at your leisure in this case
Example
yeah the second part of what I said was more important π
That was a lot easier to calculate in jobs and ECS than gameobjects
The cubes there? no
But what I meant was that they hinted that it maybe released end of 2019
Most of my stuff is closed source sadly
They hinted many times throughout the past 3 years ECS
so I wouldnt take hints very far π
Oddly... it is for a twitch reactionary notifier
Someone subs/cheers make cubes with smaller cubes
these cubes can then be absorbed by absorbers
I am a partner on twitch.
I don't really see what is happening there?
There are so many it looks like static in the gif π€£
a lot of cubes orbiting the center of the sphere?
nice π
Better indication of frames
Each cube is moving towards their origin point
to them it seems like 0,0,0 but for everything else it may not be
You can use ECS in production π all depends on skills and requirements π
YOU can use it in production because in your homeland, cars are made of wood and steel
+bottles and bits of stuff
And bears with vodka π

