#archived-dots
1 messages ยท Page 1 of 1 (latest)
AFAIK Project Settings -> Scripting Define Symbols -> Add line: UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP
I created a new project with unity 2022.2b1 and almost all the entites packages have some sort of exception being thrown
I created a new project in 2022.2a17 and didnt have this issue at all
what changed?
2022 is not suitable version
@rotund token do you happen to know this error might be related to?
This is me trying to load external assembly with IJobEntityBatch system
public partial class ModSystem : SystemBase
{
private EntityQuery _query;
protected override void OnCreate()
{
_query = GetEntityQuery(ComponentType.ReadOnly<RotatingCube>(), ComponentType.ReadWrite<Rotation>());
}
protected override void OnUpdate()
{
Dependency = new RotateJob
{
rotHandle = GetComponentTypeHandle<Rotation>(),
rcHandle = GetComponentTypeHandle<RotatingCube>(),
delta = Time.DeltaTime
}.ScheduleParallel(_query, Dependency);
}
private struct RotateJob : IJobEntityBatch
{
public ComponentTypeHandle<Rotation> rotHandle;
[ReadOnly] public ComponentTypeHandle<RotatingCube> rcHandle;
public float delta;
public void Execute(ArchetypeChunk batchInChunk, int batchIndex)
{
var rotations = batchInChunk.GetNativeArray(rotHandle);
var rcs = batchInChunk.GetNativeArray(rcHandle);
for (int i = 0; i < rotations.Length; i++)
{
var rc = rcs[i];
var rot = rotations[i];
rot.Value = math.mul(rot.Value, quaternion.RotateX(rc.speed * delta));
rotations[i] = rot;
}
}
}
}
I guess it's related to burst not being loaded
welp, judging by official burst docs
I literally have no other way
but enforce modders to use Editor to build mods
kek
what were you plans then when it wasn't the editor?
my own XML parser
aaaand JIT compilation, kek
Oh I've seen this
did you tell burst to load the new dll
(sounds like you might have realised this)
currently I am having trouble to even build mod dll
importing Assembly-CSharp
causes errors
not sure if that's the case though
Soooo, Burst manual has this script for building mod
public static void BuildGame()
{
string modName = "TestMod";
string projectFolder = Path.Combine(Application.dataPath, "..");
string buildFolder = Path.Combine(projectFolder, "PluginTemp");
// Get filename.
string path = EditorUtility.SaveFolderPanel("Choose Final Mod Location", "", "");
FileUtil.DeleteFileOrDirectory(buildFolder);
Directory.CreateDirectory(buildFolder);
// Build player.
var report = BuildPipeline.BuildPlayer(new[] { "Assets/Scenes/SampleScene.unity" }, Path.Combine(buildFolder, $"{modName}.exe"), BuildTarget.StandaloneWindows64, BuildOptions.Development);
if (report.summary.result == UnityEditor.Build.Reporting.BuildResult.Succeeded)
{
// Copy Managed library
var managedDest = Path.Combine(path, $"{modName}_Managed.dll");
var managedSrc = Path.Combine(buildFolder, $"{modName}_Data/Managed/{modName}_Managed.dll");
FileUtil.DeleteFileOrDirectory(managedDest);
if (!File.Exists(managedDest)) // Managed side not unloaded
FileUtil.CopyFileOrDirectory(managedSrc, managedDest);
else
Debug.LogWarning($"Couldn't update manged dll, {managedDest} is it currently in use?");
// Copy Burst library
var burstedDest = Path.Combine(path, $"{modName}_win_x86_64.dll");
var burstedSrc = Path.Combine(buildFolder, $"{modName}_Data/Plugins/x86_64/lib_burst_generated.dll");
FileUtil.DeleteFileOrDirectory(burstedDest);
if (!File.Exists(burstedDest))
FileUtil.CopyFileOrDirectory(burstedSrc, burstedDest);
else
Debug.LogWarning($"Couldn't update bursted dll, {burstedDest} is it currently in use?");
}
}
but I'm confused
_Managed.dll
where is it even supposed to be
huh
It works
For some reason Manual has some very weird path errors xD
but mod works
loaded assembly
which even loaded all systems normally
one system*
so, now I need to test Harmony patching
of bursted code
Well this is a roller-coaster
hehehe
and patch indeed works
also what is most fun - I can test it as modder right from editor
Confirmed its executing as burst?
Just hook up a profiler
whether it's bursted
Or add a conditional pass with burst discard that debugs something different in burst or mono
oh well, looks like burst gets discarded
Did you pass the dll to the burst method that it requires
[HarmonyPatch("RotateCubeSystem_LambdaJob_0_Job", "OriginalLambdaBody")]
public static class PatchRotatingSystem
{
public static void Postfix(float ___delta, ref Rotation rot, in RotatingCube rc)
{
rot.Value = math.mul(rot.Value, quaternion.RotateZ(-rc.speed * ___delta));
}
}
yeah, I load both
but
oh wait
maybe I should apply [BurstCompile] to patch
nah, didn't help
I'm not sure why that would patch the burst job instead of the mono
i'm not super familiar with harmony but from what i understand it patches .net methods at runtime
but you need to precompile burst
[HarmonyPatch("RotateCubeSystem_LambdaJob_0_Job", "OriginalLambdaBody")]
[BurstCompile]
public static class PatchRotatingSystem
{
[BurstCompile]
public static void Postfix(float ___delta, ref Rotation rot, in RotatingCube rc)
{
rot.Value = math.mul(rot.Value, quaternion.RotateZ(-rc.speed * ___delta));
}
}
I tried this
I assume it compiles that method for jobs, right?
you can't pass structs into function pointers in burst
hmm
harmony does not support patching native methods
so i just don't see how this would ever work?
no
aren't generic jobs work like this?
you have to register all generic jobs in advanced
this is the whole restriction behind generics and burst
not sure how much that helps you though
i always imagined modding with entities/burst to simply be writing your own new burst jobs, using write groups to override existing behaviour and loading them with BurstRuntime.LoadAdditionalLibrary(burstedAssembly)
certainly it's an option, but mostly ppl just want to modify some existing behaviour
so that everyone else who relies on this behaviour
can keep on relying on it
i don't see why overriding existing behaviour with write groups would be any different for other users
ECS kind of makes it better though
since it's all just data
so it makes no different what modified it
sometimes write groups don't exist
there's Just no tag on job, since I'd never even think someone would want to override it
but here we go
that seems to be up to the developer, i.e. you, to decide ๐
well yeah, but in normal mono Harmony brutforced it
so you could patch literally anything
This city deserves a better class of modder
anyway this is all just a vision from me, i don't think of it as modding more collaborative development
that's until someone tries to implement anime cat girls with superpowers into your game
that's why Unity needs to make runtime recompilation possible
maybe just make some static method to manually call it
i can't see burst being used outside the editor anytime soon
or ever
big difference between aot and jit code
I never used il2cpp tbh
I'd need a little bit of research before I can test
and that would be delayed till tomorrow
it was kind of a rhetorical question
as far as i'm aware you need something like BepInEx
Does Harmony work with il2cpp? It sounds like it needs access to the IL
it doesn't as far as i'm aware, it's an IL patcher
Yeah I'd be surprised
so i'm just thinking out loud here..
is there much of a difference between say passing in ComponentDataFromEntity<LocalToWorld>, as an example
compared to first firing a job that iterates the LTW's and fills an array with the values, and passing that in
It's pretty fast ๐ The query part of this article has more info on how it is implemented. TL;DR most relationship queries are just as cheap as regular ECS queries https://ajmmertens.medium.com/building-games-in-ecs-with-entity-relationships-657275ba2c6c
For simple wildcard queries all the ECS has to do is "find all tables with (Effect, *)" which is an O(1) operation, and then it can just iterate the list
I don't get it though
Does it mean you need to know relationship during compile time
Or are queries can be generalized somehow?
Nope! Everything (including component registration, query creation) is done at runtime
When a component (or relationship) is first added to an entity, an index is created for it that stores all tables for that component
But how so you query through relationship?
Do you just create a loop of
Uugh
For example
Likes With Entity as value argument?
Ah no, that would be slow. What happens is internally I translate a relationship pair (for example, (Likes, Cars)) to a component id
I can then add that component id (which is actually a relationship pair) to an entity
This blog has more info on how the pair is packed into a component id https://ajmmertens.medium.com/doing-a-lot-with-a-little-ecs-identifiers-25a72bd2647, the TL;DR is that I use a single 64bit int to encode two 32bit ids
So all it actually is just double tag generic component?
Basically uugh
Relationship<T0,T1>
Yep that's right ๐ The ECS storage doesn't really need to know about relationships, it just works with ids. You could emulate that part with generics (or templates in C++)
I can definitely see the benefits of using it
Wonder though whether this can already be implemented
In unity ECS
Things get a bit, but not much, more complex with queries. I want to be able to query for (Likes, *), even though I never add (Likes, *) to an entity. Another thing outside of the storage that is a bit harder is cleanup: if you delete a parent entity, you want to delete all entities with a (ChildOf, parent) relationship
I remember seeing smth about generic component
Gotta read about it
But you said it's tag
Meanwhile Parent is actually value
Unless it's some hardcoded singleton
Right, so, both ids that are encoded in a pair are actually entity ids
Components, relationships, parents, normal entities, all have entity ids
Entity ids are always runtime, which is why I can add (ChildOf, parent) to an entity
It lets you do lots of cool stuff. Like, what if you could add a Serializable tag to your component, so you could query all entities with serializable components
Relationship<Likes, Entity> after all
Meaning it would be not just pair
But a tag + struct
So total size of such component is 8 bytes
I even feel like if generic components is a thing it actually might work, kek
Yeah, but the nice thing about keeping it entity ids is that you don't need to know about anything at compile time ๐
Relationships can also contain data:
e.set<Position, Begin>({0, 0});
e.set<Position, End>({10, 20});
But
It kind of inlines it all to basic struct
So in the end
You can't add multiple of( likes, entity) pair
I can ๐
I mean in Unity ECS
Ahh right. Yeah before relationships I had the same problem
Well, currently
This all can be solved through dynamic buffer component
Just call it
Likes
That's true, but you'd be missing out on indexing
As a wrapper of entity
Say I want to find all entities with (Eats, Apples). I'd have to iterate all entities with (Eats, *)
I honestly just don't see how indexing of actual entity would work in unity
Since from what I understand
Types are resolved only once
Not dynamically
And if you actually remember type as id
So entity is removed
And now type id is corrupt
Yep, that's where cleanup comes in. When an entity is deleted, I delete all references to that entity
Or...
Since unity ecs using pair of ints
Index and Version
Maybe this will just keep creating new ids
But I don't see how quering it would be fast
Since you'd need to get new query every time
As each new component id creates new archetype
Smth for Unity to crack I guess
Hah yes ๐ You're exactly listing the problems one by one that need to be solved
They can be solved though
Tbh
This is a fun one, since this means that if you delete a parent entity, you need to delete archetypes with children for that parent
There is already similar filtering
With shared components
You can filter by value
But shared components are always considered managed
And they create way too many double archetypes for their implementation
yes, you can do similar things with that
in my implementation shared components are implemented through relationships, they kind of sit at the same (archetype) level
But that makes filtering way slower
It'll have to check per entity
Meanwhile current implementation checks by chunk
btw, if you want to play around with this stuff, try https://bit.ly/3oqPCD0
relationships are checked per archetype/table
they're similar to components, like:
entity Likes = world.entity();
entity Bob = world.entity();
entity Alice = world.entity();
Bob.set<Position>({10, 20}); // bob is in archetype [Position]
Bob.add(Likes, Alice); // bob is in archetype [Position, (Likes, Alice)]
Yeah, I get that part
Value is transformed into type id
Exactly how shared components work
And actually
They say they work on unmanaged version of shared component
So maybe it would it
All right, my fun with Harmony patching continues
turns out last time I checked I forgot to import bursted library
kek
into mod project
Welp
turns out
you still can't patch bursted methods
you end up with only unbursted part being patched
so... it works when you disable burst
but not when it's on
that is a very sad constraint
@harsh quiver How are the relationships modeled in memory then? This all sounds nice to me but I'm also expecting a lot of iterations on fragmented memory with lots of random access.
Yeah good question. On the storage/archetype level relationships don't really exist. It just knows of ids that can be associated with a datatype (components) or not (tags). A relationship pair like (Likes, Alice) is packed into a regular component id which is treated by the storage like any other component/tag
So in theory relationships are just as fast/slow as working with regular components.
The caveat is that relationship pairs can contain regular entities, of which there can be a lot. An application that's a heavy user of relationships will see increased archetype fragmentation
There are a couple of ways to deal with that, some framework side some application side:
- make your archetype creation fast and overhead low (some flecs apps run with 50-500k archetypes)
- use features that reduce fragmentation, like component enabling/disabling (bitset based, I believe dots has a similar feature)
- use non-fragmenting relationships (a special kind of relationship that does not fragment but is slower to iterate)
A big storage upgrade I've been working on separates tables from archetypes, where a table only stores components, archetypes store the id lists for components & tags, and multiple archetypes can index into the same table.
You still get archetype fragmentation, but tables (where it matters most, since they store the data) don't get fragmented by tags
That way you can have your cake and eat it too: pure component queries can iterate big unfragmented chunks of memory, while query for tags/relationship pairs eat a slight indexing overhead
(sorry for the wall of text, it's a simple question with a complex answer :p)
don't be sorry, i appreciate it ๐
the most basic problem I have in ECS is a target relationship. entity can have another entity as target. both entities have a position, get the distance of these targets. highly random memory access job to calculate that data.
worst of all, no simd
can always split into several stages: grab data, iterate over grabbed data, write data
all will be lined up good for cache
Right, so this is a common use case: have a Transform system (or similar) use a Position component from the entity itself as well as from its parent. Here the fragmenting relationship behavior is actually desirable, since all children for a parent pare packed in the same table. This means you can reuse the same parent's Position component for the entire table, which means you can do SIMD again
It's not perfect, you can have a degenerate case with lots of parents and tiny child tables
But even if you only have a handful of entities in a table, it'll perform slightly better than 100% random access
Something else you can leverage here is that because you're likely iterating cached query results (I'm assuming dots does this), you can sort cached tables breadth-first based on the scene graph, which ensures parent Position components are processed before children. The sorting of tables is almost free
hm, i fail to see the similarity between parent/child. a target can change and the target position can change. otherwise it would be possible to cache or duplicate the data for better access patterns
that won't make anything faster ๐ you just split the work load
Oh true, but what I meant is the cache of a query, which maintains a list of matched tables
yeah entities doesn't have that ๐ afaik it doesn't even have caching in that sense
Say you have a table with ids [Position, (ChildOf, some_parent)]. If you want to transform all entities in that table, you only need to fetch the parent's Position once
Oh really? That'd surprise me
Cached queries make a lot of sense for an archetype based ECS, even more so if you don't have relationships which means the list of archetypes is very stable
some time ago i tested effect entities and to my surprise having lots of entities slowed down the whole system. tertle then told me entities has to evaluate every archetype and chunk for the queries. so pretty sure, no caching, otherwise this wouldn't happen i think
so just creating like 10mil entities in 1 archetype slowed down every system. even though no system worked on the 10 mil entities
that's weird, trying to think of anything that could cause that
yep, i was pretty perplexed too. didn't think this would happen
even if queries aren't cached, a system query doesn't have to look at individual entities, it just needs to match archetypes
maybe it's memory fragmentation. like relevant chunk A/B/C, lots of D chunks that don't do anything and then relevant chunks E/F/G
afaik it also checks chunks (for whatever reason)
maybe the job system gets flooded with a job per chunk
idk, don't know dots that well
in any case, that doesn't happen in my code, so the relationship stuff doesn't suffer from it :p
in a small set of use cases relationships can improve cache efficiency as it lets you build instancing-like behavior on the CPU
e.g. loading a single shared component inherited from a prefab puts a lot less pressure on the CPU cache than having to load a private copy for each iterated entity
I heavily rely on that in this project https://flecs.dev/city where most of the component data is shared across prefabs
(not as impressive as the unity megacity demo :p but you gotta start somewhere as a solo dev)
hmmm
what I figured
in case you need some entity-entity relationship with random access
pretty cool stuff. what code language is most of this city demo? flecs itself is c++ and i see all this browser stuff ๐
ah, nvm
btw. can i access this dashboard for the city demo?
That project is almost all C with a bit of JS glue code. Flecs is a C core with a C++ binding
You can, but for now you need to run it on your local machine
if you run the city demo as a desktop app and go to https://www.flecs.dev/explorer/, it should connect to the demo
at some point I'll figure out how to run both in the same browser tab, but not there yet
how do you fragment your tables? same as entities with 16k chunks?
Nope, I don't chunk my tables
It wouldn't scale for me, I need to be able to support hundreds of thousands of tables. If each table is at least the size of one chunk, that'd blow up in memory very quickly
oh so how do you handle adding/removing to those tables?
Each component vector is a separate array. When I move an entity out of a table, I iterate each vector, and move the last element into the entity's old spot
Table insertion is a simple append to each vector
this is fast path for it, not a lot of stuff going on: https://github.com/SanderMertens/flecs/blob/master/src/table.c#L1699
so having a million entities would involve a memcpy when the vector capacity exceeds?
Yep, that's the tradeoff
I've been working on a pluggable storage prototype where you could do something custom for extreme cases like these (even use chunks if you wanted to)
but that's still a few months out
it could make sense to use chunked storages for large tables, and regular storages for small ones
i see, yeah when its modular enough i dont see much downsides. for low entity amounts its even preferred
the lack of modularity sucks in entities.
having a single table with 1m entities is rare though :p I'm already happy if I see a table with a few thousand entities
to be fair, modularity without giving up perf is hard
haha, tertle and me do that all the time. he's now up to 100mil test cases
oh yeah, it's not hard to create a table with 1 million entities, but I haven't seen it yet in actual applications heh
(not that these are realistic in game scenarios) we just have fun with it
as soon as I start writing ECS code I stop caring about fragmentation and I'm adding/removing components left and right ๐
with your approach adding/removing comps doesn't change archetypes right? afaik they are decoupled in flecs
in the new table vs. archetype design adding/removing comps would change archetype, but not table
I'm still working on it though, so by default adding/removing does change tables
because one of the big issues in entities is removing a comp needs a memcpy of all entity data in that archetype
which is a big performance problem
Hm really? it's not like I haven't seen this be an issue, but it doesn't come up a lot. It can become a problem for big components, or components that are complex to move
Though yeah if you're generating add/remove's for 1m entities each frame that would definitely bring everything down to a crawl
wouldn't even need that much. adding something like an event comp on 250k is already a huge spike
Part of the new storage design I'm working on is to allow for storages that can be indexed by "table index" (the row of the entity in the table) and entity id. The latter would make it possible to have a single storage per world per type, which you wouldn't have to move when an entity changes archetype
yeah true. does dots support bulk add/remove operations?
that's the only way I could make that work performantly in flecs I think
it does. remove is quite fast obviously. adding can also have the, too much data in a single frame problem
allocating so much data is just a general problem
in the best case you add a component to all entities in a table (or matching a query), and the target tables are empty
in that case you can just move the comp arrays (or chunks in the case of dots)
something I've also been toying with is the idea to keep track of destination archetype while enqueueing commands
that way if you have 10 commands enqueued for the same entity, you'd first move it to the right archetype, then apply the commands
vs. having to do 10 archetype moves
sounds like a good way to handle it
lots of ideas, very little time :p
has FLECS been tried with unity, sounds really interesting
it has, in all sorts of creative ways heh
there's a C# binding in development, though I don't think it's quite ready yet
somebody also just posted a project today that reads in a Unity scene file and converts it to a flecs scene prefabs and all, which was .. surprising
Surprisingly yes #729773810953355355 message but don't quote me on how usable it is, I think it's still very early days. I believe it is using the Forge
interesting to hear a different approach to ecs though.. i remember reading the DOD book that unity shared way back, some guy discussing in detail the benefits of DOD and ECS, and how it can be thought of in terms of a database access kindof mechanic.. was really eye opening actually and laid out the case for DOD/ECS really well
ah i don't have access, is this your own discord server?
dm me an invite if it is ๐
I did build a toy renderer which is used by this https://flecs.dev/city and a few other demo projects, but my render coding skills are nothing short of unimpressive :p I'm hoping someone more qualified will some day pick up the renderer and turn it into something decent heh
DM'd
hah, that is really nice
I spent three weeks trying to get the ssao to work and it's still glitchy as hell
bloom is not that hard, just blur & combine
the ssao is let's say "finely tuned" for this scene :p don't try it for anything else
how about physics? that natural progression i guess is a full pipeline with maybe a c++ api or something right
even just bolting together some existing solutions i guess, if they're fast and modular etc
Yeah, I've made some attempts at that but they're kind of at the same level of the renderer heh. I'm trying to develop a bunch of modules (these ones https://github.com/SanderMertens/flecs#flecs-hub) that when combined can be used as an engine
That's still waay far off though, I'm happy if it'll ever be sufficient for a gamejam
The physics module has some basic features, like it can populate an octree from ECS data
No rigidbody physics or anything close to it
really cool stuff ๐
it's okay, I'm having fun with it ^^ more than anything I'm trying things out that I'd like to see in a game engine but not sure if they're possible
like single-line imports of ECS modules. It should be possible to make a 3D app headless by un-importing the renderer module
lot of interesting problems around how you order systems imported from different modules (I've seen some dots features like system groups for this, pretty cool)
another moonshot idea I'm trying out is if I can build a renderer that uses ECS queries to batch entities for different render pipelines
like, the render pass for solid objects matches entities with Rgb, the render pass for transparent objects matches entities with Rgba
ahh interesting
i was just looking at the Forge, i hadn't seen that before, so it's using Flecs as it's built in ECS implementation
yup yup ^^ not sure how many people actually use it though :p the Forge is more of a toolkit where you use what you want
still cool they took the effort to integrate it
yeah definitely, it's great to see independent toolsets being developed that in fact are competitive with top level products
Blender probably being the greatest of all examples of that in many ways
blender is awesome (though I'm Dutch so definitely biased)
hehe, ton roosondal is like the prophet i think
haha he is :p
Those new geometry nodes look awesome.. I wish I could do something like that in ECS. Like a node-based approach to generating an ECS scene graph
regards dod/ecs, i genuinely think it's going to be a game changer over the next ten years, largely due to how much more efficient it is, compared to how wasteful the 'traditional' oop approach so often is, in terms of energy/resource utilization etc.. we're moving into a world of carbon credits and energy i think is going to be increasingly precious.. if you have a platform that users can use that is reliable and can produce applications that cater to that level of efficiency etc, i think you'll be ready for the new world
ok two weeks
absolutely, it is
but i believe it's basically going to be a requirement, pretty soon
the old world of oop will soon be gone ๐
i think maybe a world with the best of both.. the benefits of an oop layer over an ecs foundation
Agreed. What's funny is I use ECS in my day job but not for a game. I use it to construct a huge graph in realtime from real-life objects that once they're loaded you can do all sorts of fun stuff with. I have no idea how I would've done anything close to it without ECS, and not even just because of perf
Just not having to deal with fixed type hierarches that put in stone what an object can and can't have is liberating
usability is still a bit of a problem though
ECS libraries need to get their * together when it comes to behavior that only matches single entities
I'm also hearing from a lot of folks that not having native language support for it can be a barrier
how do you mean?
singleton
ah right yeh
Like what if you have a system that only matches a specific boss in your game. It's totally possible with todays libraries, but gosh I have to write a system with an interface that's clearly optimized for iterating multiple entities, need to make sure I'm matching all the right components, probably need to introduce a tag specific to that boss so I don't accidentally match the wrong thing
Vs. here's a class with an update() method, go
There's sometimes this sense that if you use inheritance or have a system that's coupled to an entity the ECS code isn't pure enough
which leads to people pretending that a MeleeUnit isn't a subclass of Unit (it is) or that the DragonAttackBehavior system isn't tightly coupled with the dragon boss at level 2 (it is)
right yeh that makes sense
(also, I only know a handful of ECS libraries, so maybe dots has better solutions for this that I'm not aware of)
it's time for cpu creators to utilize the logic of ecs on a hardware level ๐
i have to say i have a liiiitle bit of trepidation when i think about what unity is doing and look back to the end times of flash..
i think unity are still kindof keeping one foot in the old world and one foot in the new, which was kinda what killed flash really
deprecation of the npapi killed flash
actionscript started leveraging more low level access, there were even tools to write super fast native c code and leverage it etc
but ultimately, the html5 revolution just left it behind
Do you guys know whether it's possible to build separate Burst library for each built assembly in project?
interesting that just the battery life consideration was a big factor, and that was then.. even more important now
basically so that Player's burst lib and actual project's burst lib are separate
I'm not sure if you can split it per assembly, though the editor actually splits every job into its own dll
But you can load more than 1 burst dll at runtime
it's only required for mod project
I tried to load original project's burst plugin
but it resulted in tons of exceptions
lemme boot it and show
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
public static void Load()
{
var path = Path.Combine(Application.dataPath, "Reference/UnityECSModTestBurst.dll");
Debug.Log(path);
if (File.Exists(path))
{
BurstRuntime.LoadAdditionalLibrary(path);
Debug.Log("Loaded reference burst");
}
else
{
Debug.LogError("Didn't load reference burst, file doesn't exist");
}
}
here how I load it
and here what I get ๐ด
xD
here first errors
what I assume: original project's build compiled it all into 1 library
and now it is having trouble Editor's player burst libraries
which unity editor version works with entities 0.51-preview32? I can't seem to add the entities package anymore without errors
I don't use anything prior to unity 2021.3.6f1
I cant seem to import the package without entities forcing v1.7.2 of burst, when the docs claim it will install 1.6.4 (which I installed ahead of time)
What version are you using then?
as that seems to be the majority of conflics
at this time, using 2022.2.a17
I tried the beta, but it was worse
I also tried 2021.3, 2022.1.8, and 2022.2b1 with similar issues regarding packages. Neither seems to allow for the correct package anymore
2021.3.4+ works
I use this
but it has some weird bug with android builder
I cant import without the console screaming at me saying there's 50+ ambiguous references... importing the correct package has not even allowed me to change the version number because entities requires a newer package than the one described on their docs
I also have tried 2021.3.6f1 with the same results
last week I created a project and imported everything entities related without issue in 2022.2.a17.... but now I cant
and how exactly
first thing added is entites
are you installing DOTS packages
com.unity.entites
through package manager or manifest?
package manager
try manifest
"com.unity.burst": "1.7.3",
"com.unity.rendering.hybrid" : "0.51.0-preview.32",
you can add these 2 lines
and you'll get all dependencies resolved
for you
this will give you all required ECS + Jobs + Burst packages
without Physics though
what version of collections and mathematics are you using?
Still having issues
can you show your manifest?
Some of the version numbers are not even correct because the package manager shows a different version
why are you defining packages manually?
you probably have some of them wrong
remove all dots related packages
but those 2 sent
im just going to create a new project and send that manifest
sir
just create new project
and add to manifest those 2 lines I sent you
this will give you all you need for Dots
when you create project
pick URP/HDRP template
I imagine the problem is using that version of Collections
I had the correct versions described on the DOTS docs page, but adding entities package auto resolves to a newer version
I tried manually setting the version afterwards using the package manager with no success
@rustic rain here's the manifest I got when creating a new project in 2021.3.6f1 (the one you use)
now just add those 2 lines to the top
don't even touch package manager
ok that worked
how
something must be messed up with the package manager
it's weird, because all the packages relating to burst/mathematics/collections/entities is the same version on the other projects that have issues
all these packages are preview
package manager doesn't work with them
well that's wack
it is
no idea why they made it the way it is
older version worked fine with preview packages
Debug.Log works inside Burstified jobs
AOT is what burst uses in builds, and JIT in editor afaik
yeah, but if you import dll of build into editor
JIT won't work either
and that is a problem for modding
I am trying to solve
huh yeah that is an issue
Try the Synchronous Compilation setting under the Jobs tab. No idea if that will change anything for builds tho
Also, instead of using compiled mods, you could try hot-loading source code instead
oof
I wouldn't want to make game open source this way
besides
sharing source code this way would be even more pain
you would not need to opensource you game. Just an API wrapper that interfaces with the mods and your game
ahem, hot loading source code is not supported at all
for burst
kek
besides
that's not the problem
final game that loads mod does work with burst (I think)
the problem is related to smth else
it's mod project
once you loaded assembly of game build
nothing of burst works in editor for mod project
meaning big scaled projects will be impossible to run in editor
for modders
what kind of errors?
assembly names aren't
compiled mods should fall under an entirely unique assembly that is unique to that mod
yeah, and for some reason they thought that it would have _Managed suffix
From the looks of it, Unity is loading an Assembly as expected, and then loading it using Activator
Then change how the editor script reads names to the compiled .dlls
sir, I did it long time ago
Once again, it's Modder's experience that is my concern
because as modder you can't get bursted game assembly
thus if you try to test some mechanic that relies on existing one which potentially is heavy
you'll end up testing in 0.1fps conditions
Just checked
mod assembly loaded by game works fine
burst loads correctly
also nvm, burst does not load correctly
hmmm
how would you structure prefab database?
the way so you can easily query over them by string, change them however you want and etc
also very important - the way so you can collect them
a hashmap? ๐
well yeah, that's obvious
but I'm confused over how to manage it
I need to keep link to prefab in instantiated entities
so they can be later saved and restored by that prefab reference
I'm considering shared component
so memory overhead is 0
i use weak references
similar system that the dots shooter used to manage it's prefabs
could you elaborate?
this is just to link the actual presentation if required
i don't save this though as this exists on the prefab, prefabs (and objects in subscenes) in my save system are auto generated unique IDs using https://docs.unity3d.com/ScriptReference/GlobalObjectId.html
I can't and probably should not rely on IDs
what I would like to use is string (fixed)
because that's the best way to keep unique reference between game, modders and etc
at least I think so
not sure how having you users choose strings, "monster", is going to be more unique than guids
Because they will probably want to instantiate some prefab
in code
so? make them call your method to get an id
and pass what in for it?
nothing
how would I know then what prefab to give to them
my point is:
modder creates some prefabs that get instantiated into world as prefabs and then saved in database
Then in some trigger event or smth he wants that prefab to be instantiated and do smth with it
what would be a way to get that reference?
from the guid he was given
and what does he pass as argument to get that guid
prefab is instantiated outside of his control
var id = GetUniqueID();
DataBase.RegisterPrefab(id, myprefab);
user does what the fuck they like
it's just written into world
that's the point
there is no prefab for user
he is not the one writing to database
so the prefabs already exist?
yes
then i dont see the problem at all
i thought the problem was you wanted modders to be able to add prefabs
var prefab = DataBase.GetPrefab(id);
they don't know id
that's up to you
that's why I want to have string/prefab
how is string any more useful than an ID
they dont know the string ^_^'
string is just an id
because I still don't see how user would get an ID of prefab
because as for string
user will manually write it
your string is ID
yes
they can manually write an int the same way they can manually write a string
do they not have numbers on their keyboards
but there are supposed to be many modders
so the odds they pick same numbers
welp, kind of high
well, the best I see is just keep another hash
for string/id
but that's just extra step
^
Modder is supposed to be able to create prefabs, even without assembly
so game loads those prefabs and uses them automatically (or not)
but modder does not have any reference to that prefab
i just went through this with you
i was providing a solution to have users create prefabs
then you said, users are not creating prefabs
they already exist
Modder creates prefabs and serializes them so then game loads them
but he is not meant to have control over loading process
in which case ^
thats all you need
i don't get it
you just need a way for a user to register a unique id to a prefab
string
a string is an id
i dont care if your id is a string, int, long, texture, or biometrics
id does not mean int
I kind of assumed it is, kek
hmm
when game object prefab is getting converted
I guess prefab is not taken in account in any way?
conversion systems probably just process it without any regards for prefab
i love quoting out of context
๐
that weakreference script is a blast from the past. tertle, can you remind me why they were setting it up like that?
During conversion is it possible to get reference to actual target world?
I have extension fields in it I would like to fill
During conversion
I don't really want to create additional system with query
Welp, seems like I do need it
Sadge
Probably to not worry about cross scene references
Back when you get to register all your ghosts (I'm not sure this is the case anymore)
Are entity references in fields resolved during conversion?
Basically if I create Entity in conversion system
that will have component that references other entity
after it's copied into actual world
are references remapped?
are these other entities in the conversion world?
if so yes things should remap
I need to create copy of entity, add prefab tag to it
And save it to other entity as field in comp
all will be created in conversion system
is this runtime conversion?
subscene too
both
I'm also still can't figure out how to resolve it all correctly
I want to have GO prefabs with special authoring component, which will be responsible for solving copies
so if let's say you spawn 10 GOs with same authoring component's value
only 1 copy of them all will be written as prefab in World
and this also for subscenes
so once world is started and running, all existing entities that are spawned from prefab will have it's link
so that I can restore them later during save/load
based of these prefabs
Is updating in [UpdateInGroup(typeof(InitializationSystemGroup))] ok?
Does it update same way as in editor?
yeah
so in short it's just a system that updates before simulation?
yes
btw, can it be bursted?
These attributes are somehwat confusing
since some of them say BurstCompatible
other say structuralmethod
should be fine in burst
bruh
InvalidOperationException: SolvePrefabsJob.query.__impl uses unsafe Pointers which is not allowed. Unsafe Pointers can lead to crashes and no safety against race conditions can be provided.
why EntityQuery methods have BurstCompatible attributes
if safety checks won't even let you use them in jobs
hmmm.
Wonder if I should rely on Transform parenting system
or just work with world coordinates
even if they are wonky and huge
burst compatible
does not mean job/thread safe
these were all made burst compatible for ISystem
hmmm
Do I need to specify every method for BurstCompile or?
For some reason simply tagging struct as BurstCompile doesn't work
in ISystem
oh man I start to really enjoy fully unmanaged ECS world
no need for any references between systems
just do EntityManager extension
and do event entity
for ISystem you need to tag the struct but also the OnUpdate method
tagging OnUpdate actually makes that method compile bursted
while tagging the ISystem struct just gives burst a hint where it needs to look to compile a method
it's too costly for burst to simply try inspect every method in a project to see if it needs compiling
no
well if you put it on those methods then it probably would
i've never actually tried though tbh
i usually have managed code or unburstable code in OnCreate
like GetEntityQuery is not burstable
yeah, it's ok
I heard it's supposedly possible to debug jobs with breakpoints nowadays, do I need to do some special setup to make them work? Because just putting a breakpoint doesn't seem to trigger it. I'm using Rider.
To add to above,, disabling Burst Compilation makes it work properly, but I was under the impression that "Native Debug Mode Compilation" would do something similar for me
NativeDebugger
tertle said VS has one
I haven't tried it yet
Oh right, Native. I see the issue now, that explains why it doesn't work on Rider's normal debugger
oh god, treating shared components as managed feels awful
so many workarounds
I feel terrible
Hey guys, just getting started with Unity & DOTS. Tried following the new ECS project video (https://www.youtube.com/watch?v=m_ZDL2X9jvM&t=1s ) to get started and I can't get a baisc 3d object to convert and render in my game window in play mode. Using Unity 2021.3.6f1 and Hybrid Renderer 0.51.0-preview.32
Based on the DOTS hierearchy, the object is being converted correctly, but I don't think its rendering.
Anyone have any ideas?
๐ฌ Join our Discord community: https://tmg.dev/Discord ๐ฌ
๐ป My Game Development Setup: https://tmg.dev/GameDevPC ๐ป
๐ธ My Camera Gear: https://tmg.dev/CameraGear ๐ธ
๐ฎ Let me know what other topics you want to learn about ๐ฎ
โ Time stamps for key topics โ
- 0:00 - Entities 0.50
- 0:47 - A Word of Caution on ECS
- 1:29 - Upgrade Prerequisites
- 2:28 ...
What are you calling from it? I'm not aware of any sync points.
between scheduling of jobs
nah, just extension field
I won't be able to check anything though, because I already moved everything to callback events that assign data instead
huh, well, I dunno. Just calling World is not a sync point. It just returns you the unmanaged world object
in general, only certain methods have sync points from EntityManager and some forms of schedule like with change filter. most are quite obvious though
and when not obvious, running the game will give you errors when you rely on schedules
It returns Managed world
tbh
I'm not sure what actually causes errors at this point
so I'll just leave it behind until I face it again, kek
the managed world is mostly a wrapper afaik
hehe
xD
Has anyone else come across this error Assets\Scripts\FlowFieldGridStuff\CalculateCellCost.cs(10,5): error SGICE002: Seeing this error indicates a bug in the dots compiler. We'd appreciate a bug report (About->Report a Bug...). Thnx! <3 System.IO.IOException: Cannot create 'Unity Projects\LOR Tower Defence Test Scene\Temp\GeneratedCode\Assembly-CSharp' because a file or directory with the same name already exists.
it appears my project is completely broke now it won't compile anything and I don't know what to do ๐
I'd close unity and nuke the temp folder
ok I think its fixed now thanks
Is casting to IEnumerable<T> burst compatible?
I kind of don't want to write utility method for literally all native containers out there
try it out
Close unity
a rename the project folder to not have spaces in the name
delete the Temp folder
try to reopen the prject
I think it fixed itself but if it happens again I'll try that, thanks
You don't need to close unity to fix this error
Just load up the temp / code generated folder
Delete the files in that
Reimport a script to trigger a recompile
For some reason the code gen is creating files instead of folders sometimes blocking the folders being created
ok, that's good to know
Is there a safe way to write to an ISystemStateComponent collected from CDFE which was plugged into an IJobEntityBatchWithIndex.ScheduleParallel()?
I get error that that CDFE<StateComponent> is not declared as ReadOnly, container does not support parallel writing.
Is that something I can "make" it support? Or I have to schedule single?
if you have 2 separate threads writing to the same entity
it's just not safe
so that's why it's prevented by default
If I want to get around it, I'd need to use NativeDisableForParallelRestriction type deal?
yes
you're telling unity that you promise you aren't doing something unsafe
but it's up to you to ensure that
And say another thread writes to it at the same time, will it silently overwrite, or will it throw exceptions?
there will be no safety for you
the result will be undefined
in theory you could end up with half the value from 1 write and half from the other write
unity will not tell you this is broken
you have to be certain this situation can't happen
i.e. you should never do this unless you only map 1:1
if you are just writing randomly then this is not safe
I see, yeah best not to mess with that then.
if you had like single fields to modify, you could do things with interlocked etc to write safely in parallel
but you need to be comfortable with what you're doing otherwise turning off safety is a really easy way to cause yourself rare random bugs that are extremely hard to track down
interlocked etc, meaning lock (myField) { // execute write here } type deal?
I think this is new for me. Can you give me more info?
microsoft do a better than i ever would
Woah, narly!
So here is the part in the job that I need to write back. How would I perform this Interlocked technique on this?
var treeState = unitStateComponents[directive.TargetTree];
treeState.health = math.max(0, treeState.health - toolPower);
unitStateComponents[directive.TargetTree] = treeState;
will never work
not with the max
you'd have to remove the max
and have another job later apply it
in the time you read
Read: treeState.health
Execute: math.max(0, treeState.health - toolPower);
Write from another thread: treeState.health
Write this thread: treeState.health
I see
firstly you need a custom extension for ComponentDataFromEntity that will return the value by ref/pointer
then call Interlocked.Add(ptr, -toolpower)
and it would safely sum all threads
then you'd need a second job to go over all healths and do a max(0) on them
I think I'll just chain jobs, Schedule Parallel all the calculations, and Schedule Single (dependency on parallel completion) to apply changes in calculations.
I don't suppose anyone knows how I use a CollisionFilter so that a raycast or an overlapsphere only hits on specific groups
I've got the raycast sort of working correctly by getting the filter from environment entity's
but the overlapsphere I need it to exclude the environment but I'm not sure how I set it up to do that
if the environment in its own layer?
yeah
does physics entity's actually use the layers?
I thought it only used the belongs to and Collides with Collisionfilter thing
they are the layers
so its something in the way I have it setup
I have the environment that collides with both enemies and environments
and I have enemies that only collide with the environment
so if I get the collisionfilter from the enemies then that means that cast should only collide with the environment? ๐
so I probably need to either create a new object that only collides with enemies or manually create a collisionfilter but the filter is kind of confusing because it uses uint
I wish I could get the names of what the values are because they don't seem to correspond to what they should
I think I did it 
I created an entiy and it had to belong to the environment and only collide with enemy's
Isn't the Burst Inspector supposed to show pieces of your original code in comments? Currently I have a simple Entities.ForEach and the Burst Inspector ASM is >10k lines, so I'm not really sure where my ForEach is or how I can locate it
I find all sorts of code gen stuff for grabbing components from chunks but I can't find the actual code that I wrote
hmm
I assume there's no ReadOnly version of array or lists in native collections?
btw, is accessing field as ref is that simple?
ref var galaxy = ref World.galaxy;
there is totally a NativeArray<T>.ReadOnly
oh
yes :)
ref is pretty cool. best feature in modern c#
I have a question, is there any tutorial or something that showcases how Joints work with DOTS and Unity Physics?
samples
Ugh. Back and forth, back and forth for days and weeks now. I think I might roll my own 2d physics engine as well. That way I no longer have to touch GOs at all
you can use 3D engine tho
just set up constaints
and should be good
Sliding across surface stability. Dots Physics doesnt have that
It's pretty noticable in that DOTS UI video with the 2d sample game. The enemies bunched together would vibrate in position against each other due to the lack of stable collisions.
And plus performance. Why model 3d physics mesh when 2d is what is needed
performance difference is not that big between 3d and 2d physics. depends on shape I guess. usually a bunch of standard shapes is enough to model something
Just circles and squares. A bunch of them but just those 2
Maybe polygons but I can make them out of a bunch of squares. Tilemap colliders
well, tbh
then it doesn't matter really. but what's your issue, the sliding or more?
just the sliding. I know Havoc has contact welding which will probably solve the issue but Im also dipping my toes into multiplayer. This is just a proof of concept project where I'm just touching upon various areas of game dev for a surface level understanding
Ya know, I wonder what's going on in Unity DOTS team. They've gone back to radio silence on many of the forum posts. Except for netcode though. They were still active even before 0.50.
Or they could just be on summer vacation. The europeans have those strange things.
It is hot in europe during summer, kek
Inside an Entities.ForEach(), is it bad to then call a static function and pass the components as arguments?
not at all
it will be inlined
in burst at least
I personally do it for like 80% of all logic, xD
Thanks dude
Hi everyone, I currently have an issue with entity generation. When I try to generate it with a script (the script get mesh and materials to generate an entity with this), it just doesn't render at all (I'm running the script on an empty GameObject).
I'm running on 2021.3.6f1 with experimental packages:
- entities
- hybrid renderer
- unity physics
All packages are version 0.51.0-preview32.
Any advice would be greatly appreciated
Here my script```cs
public class WorldManager : MonoBehaviour
{
[SerializeField] private Mesh unitMesh;
[SerializeField] private Material unitMaterial;
void Start()
{
float3 position = Random.insideUnitSphere * new float3(100f, 100f, 100f);
quaternion rotation = quaternion.Euler(0f, 0f, 0f);
float3 scale = Vector3.one;
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
EntityArchetype archetype = entityManager.CreateArchetype(
typeof(Translation),
typeof(Rotation),
typeof(RenderMesh),
typeof(RenderBounds),
typeof(LocalToWorld)
);
unitMesh.bounds.ToAABB();
Entity myEntity = entityManager.CreateEntity(archetype);
entityManager.AddComponentData(myEntity, new Translation
{
Value = new float3(2f, 0f, 4f)
});
entityManager.AddSharedComponentData(myEntity, new RenderMesh
{
mesh = unitMesh,
material = unitMaterial
});
}```
try using utility method
RenderMeshUtility I think it's called
it will add all required components itself
Relatively new to Unity here. Is DOTS available and ready for production?
I heard it got canceled or something but maybe that is bad info
Entities is still in preproduction - but 1.0 release is coming to a later release in 2022.2 beta. Burst & Job System that ships with the editor are ready for production
All the Unity news lately has been confusing to me
So, I have all the components with RenderMeshUtility, but it doesn't render
system relationship in hierarchy ? I don't have it
window-Dots-hierarchy
Anyone else have issues with unity using a lot of RAM? Each time assemblies are reloaded it seems to use more
Just read the DOTS forum. All info is stickied
Brrruuuuh
Feels so bad having no 2d transform
Now I'm between 2 fires:
- Make 2d transform and renderer
- Make it all on 3d through constraints with very little chance to easily refactor it
Is there actually a reason you're sticking with entities? It doesn't really seem to meet the needs of your project atm @rustic rain
What is it giving you? From what I understand you're mostly hybrid and using 2d
With scaling capabilities
You can still write a large simulation with burst and jobs without entities
No hybrid
Oh you scraped all that?
So confusing ๐ฉ
There's runner game with cannon and there's space tycoon
Cannon is done
Tycoon is in progress
Ok, for those who encounter the same issue, I was doing wrong on many points
First: I used a simple 3D template. We need URP or HDRP for the SRP(Scriptable Render Pipeline)
Second: I used basic material, we need to create material in the URP and NOT using default material
Third: I'm braindead
Thx @rustic rain for you help, you were really helpful
Is there a built in way to detect when entity came/left into/from camera view? If not, can someone give me some pointers on how to go about this?
it's a shame there is currently no easy way to hook into HR culling as far as i'm aware to get this info
but you can just do your own frustrum culling if you need
Shit. I was afraid someone was gonna say that. Ok, how would one do their own frustrum culling. What formulas/API do I need for this?
FrustumPlanes in Unity.Rendering has methods for you
pretty straight forward
FrustumPlanes.FromCamera(Camera camera, NativeArray<float4> planes)
then just call
IntersectResult FrustumPlanes.Intersect(NativeArray<float4> cullingPlanes, AABB a)
to do a check
Awesome thanks.
Hey, thanks for showing me this. Although it wasn't needed then, I sure ended up needing it now since we can't lock structs and all ๐
hmmm
I am doing a UI-World connection in which I want to create UI data after certain action
but what if Entity gets destroyed, on which this UI is based
is there some kind of way to have callback?
or simply checking whether Entity is legit on every update is the way?
you can create your own 'callback'
but apart from that yeah you need to check
i have a standard destroy/cleanup pipeline
that every entity goes through
and things can check if an entity is going to be destroyed and do cleanup on it
but even this can become a complicated mess at times
well yeah, that would require creating quite a lot of systems for callbacks
I guess it would be easier to just check every frame whether it's valid
while bursted it's pretty inexpensive
glad I learnt how to use ISystem
kek
hmmm
I just figured an interesting approach to handling UI and fields
can make some Component with float field and also attach VisualElement to it (text for example)
and then if that float field is written - other system will rewrite it as string to text object, while filtering change version
UI systems will be responsible for creating such queries
I guess they can be separated with shared component of value of certain screen reference hash
so by filtering you can find any singleton entity
I have a need to generate a bunch of dynamic physics objects but with random scales.
These objects need to be spawned at runtime from a prefab because they are networked ghosts.
Because Unity bakes in the scale at authoring time for dynamic physics objects I need to create these prefabs at authoring time, so there could be quite a few.
It'd be nice If I could automate this process to create a bunch of baked prefabs to leverage the authoring systems.
Has anyone done this before, i.e. baking prefabs from an authoring script during conversion? especially in a NetCode context.
why can't you just author what scale component you need and then run a job on your entities setting scale randomly?
do you mean scale them during authoring?
no, just assign the component
and then during instantiation
you set the value
that won't update the collider
composite scale?
sure that works?
(see I thought it did but I can't see how it can since I see no references in code except in physics smoothing)
(the CreateRigidBodies job does not have a reference to any scale)
well, composite scale does exist for some reason, kek
and it's automatically added to entities with colliders
so I'd guess the easiest would be - just test it
well its a transform component not physics
and yeah its only used as part of smoothing, so yeah not sure
If I could do it at runtime that'd be a lot easier but I'm pretty sure the scale is baked into the physics geometry during conversion
TBH its probably easier to manually create a few variations with different scales and randomly choose from those.
I'm not big brain enough to go toe to toe with the DOTS gods like you guys XD
Have you tried composite scale tho?
I highly doubt Unity added whole damn another scale component just to adjust drawing
It's a pain working with two already
Let alone 3
why don't you just create them at runtime as needed?
as long as client/server both add the physics components the same way should be fine?
I assume components version filtering only works for chunks?
Meaning if one entity has changed whole chunk will pass?
Not a good thing in my case since it will probably recreate whole UI
you just use change filtering as a broadphase
you nearly always have to check individually entities yourself after this
I could probably do this but I have no idea how to modify the collider to apply the scale.
I'm sure the conversion scripts can probably help but it might be entering too difficult to bother territory.
I'll definitely consider it though.
hmm
and how can I filter individual entity?
I'm really interested in trying to make this UI elements + Entities integration
for every named VisualElement there will be created entity with attached object
and by adding special components you can manipulate how values will be applied to those objects
I've generated a bunch of voxel chunk entities from scratch but none of them have proper lighting/shading/shadows. Anyone know why this could be? They each have their correct components and component data when compared to test-gameobjects that I've then turned to entities that DO have proper lighting. Any ideas? Thanks.
mostly Text I guess
ugh, unity's gonna make me implement my own sprite renderer arent they
we can combine our efforts
im gonna give hybrid renderer a poke but last time I checked, it had enormous overhead
like 3-4 ms per frame rendering nothing.
what I think of it is
all you need is make a object dictionary
every time you convert object
with sprite renderer
you check whether sprite already belongs to some material
if it is
you just assign that material
I literally render flat unlit textures. I roll my own lighting system. I just need a texture lookup
I'm also rolling my own physics system in order to decouple the need for a game object entirely. However, I still need a sprite renderer.
just gotta figure what MTB properties belong to that shader
so in short it'll be:
grab all entities that belong to same atlas (material), grab their MTB (sprite UV) and then just pass that array to Instanced draw call
using quad as mesh
no need for custom SRP
just for that
in fact
Unity already rolled their implementation of it
you can look up sources on github
Oh yea, hybrid has a sprite renderer implementation. Guess i can just copy and kinda customize
[Mirrored from UPM, not affiliated with Unity Technologies.] ๐ฆ 2D Entities is a package that provides tools to work with 2D content in Project Tiny. - com.unity.2d.entities/ConvertSpriteRenderer.cs...
no
it's different
it's for project Tiny afaik
yea unity tiny uses bgfx as its backend for rendering