#archived-dots
1 messages ยท Page 30 of 1
but rendermesh no longer used at runtime
and it's just an array now
i'm assuming with all submeshes in it
(again havent tested it, don't quote me)
the meshe's I have are completely separate just the same level childs to a main empty game object
cool
Did anyone manage to make a build work which uses net code as a client? I tried windows and android and both get exception on connecting.
this system isn't running, i think because these queries are empty - is that normal?
normally it runs fine but i've just changed the ordering of some stuff and it's not running this system
If all of the queries in a system are empty it wont run, you can override this with [UpdateAlways], at least this is how it working in 0.51 and prior
Maybe its [AlwaysUpdate], I dunno
Thanks yeah it's 0.51.. i thought it would run unless RequireForUpdate was used.. thanks
Does anyone here use PlasticSCM?
I've just converted all my authoring scrips to use bakers and now Unity is crashing with stack overflow which appears to be caused by PlasticSCM
this behaviour is inverted in 1.0
system will always run by default
I'd stick with github in future to be honest
PlasticSCM seems good for artists/designers
If GitHub had a decent way to backup large files then I would do that
But LFS is dogshit
you get 10GB LFS instead of 1GB on github
My game is in a very trippy place in a good way: https://www.youtube.com/watch?v=0iNV3jJkRp8&t=1m36s
Stuff's about to get VERY VERY VERY FUN!
We run a guild. Opportunity: I can teach you how to make games for free better they teach at expensive universities. If you help us, you get revshare.
#1 Senna NA mastery I saw no hate ever in arcades. Choose love. Also #1 world in Starcraft/Broodwar/Warcraft3/Diablo2/C&C3/...
How do I mitigate the collision from being sticky? How can I make it bounce you off?
1m 36s
ok thanks noted
i can't really see what you mean sorry..
My ship when it hits the wall should bounce off
From 1 m 36 seconds to about 1 minute 42 seconds it gets "STUCK" to the wall
I saw it happen before, but I forget how to fix it
ahhh i see now
it's almost as if it's clipping through and then getting stuck, which is quite common
if you can reproduce the problem easily, maybe try increasing iterations just to diagnose if that fixes it
I think it has to do with convex hull or something
Anyway, no big. I think its a new one since the space station I added is "static" and immovable.
Its a pretty cool show off video too
is the space station using a convex hull or mesh collider
yeah the sense of scale is nice
Static mesh
When I add in experience/random loot/random events/ inventory, it's gonna get SICK
surprisingly space games and trading games like Sid Mier Pirates and Elite Dangerous do not have random events like Oregon Trail or Final Fantasy.
Space gets boring and random events non stop will spice this game up hardcore.
Random events combos with proceedurally generated galaxy
I can't wait til next friday's patch, gonna be sick
THANKS COW!
ty tertle,enzi, korn, etc, we about to start making bak
bank
yeah it looks like it could have a lot of scope for nice space travel gameplay
k i need some sleep, laters folks!
I have multiplayer and everyone who helped, if you see me making money, just ask for some if you ever need it
Good Night MidnightCow, gonna go see family myself. I pray everyone has productive devving.
you too ๐
I used plastic for a few years and now we are switching back to git.
Plastic has some amazing features but it still lacks real cross platform support (Mac client lacks many features) and we also had some strange issues recently.
well cross platform isn't a concern for me really
but what other strange issues did you have?
i've been loosely investigating it for pre-production
because git just is not good for artists
we run a second svn server for them which i would like to get rid of
Indeed you will have a lot less issues and problems with plastic thatโs absolutely true.
But we had some issues with projects locally corrupted (devs needed to check out a fresh repository and we couldnโt really repair it or understand why it happened)
Overall itโs rare, and most likely you will be more productive with plastic
that'd be kind of unacceptable
did you use git integration with it?
or just full plastic
You mean that it works with both? (Like a double sync)?
well it supports gitserver right?
Any tool in the Git ecosystem can now be directly used to connect to Plastic SCM using their native Git functionalities.
Ok that was some time ago when we tried, but it was utterly broken
I think its come a long way, at least the Unity integration has come a long way
because i will have a rebellion if devs can't use their existing tooling
If you donโt use lfs it might work, but if you use lfs when we tried it didnโt work at all.
i really want devs to have existing git workflow, while having artists on gluon
That sounds like a really cool idea, let me know if that works
Glad you like it, we usually disabled it as it was just too much of a hassle with the checkouts.
Have you already tested with a simple project with git + lfs and the sync?
not in like 2 years
it's just in my, todo list of pre-production work
but we're not officially in pre-production yet and i'd rather work in entities in my spare time ๐
i just randomly do some reading here and there
so until i can allocate myself some time at work to investigate it, it's going to sit there
Yep, that sound very familiar.
Overall plastic is great, but I just prefer git, also pricing is a little cheaper with git and you have more choices for hosting.
hmm somehow missed CreateAfter CreateBefore
Now that we have system entities, has anyone found an easy way of authoring these from the editor?
authoring what?
these are created during world creation
which is runtime
A pretty common case for me is that I have some system specific settings that I want to author in the editor. It was always hard to communicate config data to systems from the editor since systems don't have an inspector, but maybe now with system entities it is easier somehow?
nah, not a thing sadly
I'd love that feature too
what I suggest - use settings inside entities
if it's not possible
store them on singleton game object
which will be retrieven from system
That's what I did previously, just convert monobehaviours to singleton entities that has the settings. But I'd like them to end up on the new system entities now instead.
nah, not a good idea
at least
no need for that
why?
not sure whether chunk GC is implemented
but by creating new arhcetype
you make your world a little bit slower
so might as well just store each on their own
instead of combining into another achetype
and end up with 3 archetypes total
that will be a thing until there will be archetype GC
my settings are completely unmanaged, so no need to gc
I talk about chunk GC
it's not a thing yet afaik
so every new archetype you create
will there
slowing iterations down
You mean that each new archetype will have it's own chunk?
it will have at least 1 chunk, yes
well that still applies to system entities I guess. But they are the recommended way to store system state.
yeah, it is generally a good idea
but since they exist
they don't waste chunk space for nothing
meanwhile moving entities from 1 to another
will
My hope is that in the future unity will handle system entities a bit different to avoid the chunk fragmentation issue.
maybe not store them in chunks, but just some kind of large unmanaged array or something.
the best thing - entity
this way you'll have live conversion
so you can change settings during runtime
That would require the settings to end up on singleton entities tho right?
yeah
so we are on the same page. I just wish they could end up on the system entity instead of a separate entity. That would clarify to which system they belong.
entity data is global and doesn't belong to any system
for example if you have singleton component Gravity which is by default only used by GravitySystem
That doesn't mean smth else wouldn't want to use it too
In 1.0.0-exp8 they added system entities. It is a entity created automatically for each system, where you are supposed to store system state instead of inside the system class/struct. So those entities indeed belong to a system.
Not sure whether system entities are like regular entity that will create new archetype per new system entity
nah, it's all same archetype
there it is
well yes, it is the same archetype as long as you don't add any components to them, they will all have the same default components.
I mean that's because nothing was added to it
Can you use Query in a static function that is called locally in an ISystem? or will that break code gen
I think It will break it, but I have not tested.
/// <remarks> Not working in Entities.ForEach, IJobEntity, Utility methods, and Aspects</remarks>
Using query for structural changes is really annoying atm imo
how so?
should be alright when you use EntityQueryBuilder. afaik there's no codegen behind it
I meant the SystemAPI.Query API
you are meant to use ECB for that
chunks get invalid with structural changes during iteration
I mean Entities.ForEach could do it so I'm sure it's possible
Did EntityQuery change since 0.51?
I thought they were tied to specific world
meanwhile now it seems they aren't
Ideally the codegen would create an ECB automatically, give you a reference to it in the foreach parameter, and then call playback at the end
e.g. with SystemAPI.Query.WithECB
or something like that
the entitymanager defines which world is queried.
yeah, but I'm fairly certain you could do
query.CalculateEntityCount()
without any EM or World as argument
hm, true
public int CalculateEntityCount() => _GetImpl()->CalculateEntityCount();
still is
๐ค
so queries must live in the world/entitymanager.
{
SyncFilterTypes();
var ecs = _Access->EntityComponentStore;
var mask = _Access->EntityQueryManager->GetEntityQueryMask(_QueryData, ecs);
return ChunkIterationUtility.CalculateEntityCountInEntityArray((Entity*)entityArray.GetUnsafeReadOnlyPtr(), entityArray.Length, _QueryData, ecs, ref mask, ref _Filter);
}```
yeah makes sense that GetEntityQuery goes through the local EntityManager
then I don't get it
how can it can be created
without any World reference
or EM reference
yet contain it
EntityQueryBuilder is new
and doesn't use any World/EM reference
{
desc.FinalizeQueryInternal();
ref var handles = ref EntityQueries;
// TODO: https://jira.unity3d.com/browse/DOTS-6524 CompareQuery sorts each component array in the builder
// every time it's called. That sort could be moved outside this loop, or into
// EntityQueryBuilder.FinalizeQuery(), to avoid doing it every time.
for (var i = 0; i != handles.Length; i++)
{
var query = handles[i];
if (query.CompareQuery(desc))
{
return query;
}
}
var newQuery = EntityManager.CreateEntityQuery(desc);
AddReaderWriters(newQuery);
AfterQueryCreated(newQuery);
return newQuery;
}```
You pass it to Build
always tied to EntityManager
Using [RequireMatchingQueriesForUpdate] on a system that only contains SystemAPI.Query calls should be fine right? Since the code gen turns that into type handles
I'd recommend using RequireAny manually
one of devs mentioned
that they want to get rid of cached queries
that are stored internally through GetEntityQuery
I mean the query still needs to exist somewhere on the system, even if you use RequireAny
That's a massive pain with the Query API, since you can't get it from that
that's why I recommend manual dependency building
How does that solve writing the query twice
(once in the EntityQuery, once in the foreach Query request)
I'd guess it uses same query
and they will be equal
considering there's the same Pipeline rn
for creating them
I still need to define the types twice, that's my issue
Ideally this isn't something the end user needs to worry about, and code gen will use RequireAny for a system that defines [RequireMatchingQueriesForUpdate]
any proposed change?
not sure what's the downside of cached queries ๐ค
they are not obvious
you don't get to know why your system runs
unless you researched through code
that GetEntityQuery actually creates a requirment to run
It doesn't anymore by default
but it still caches it
yeah, well, they wanted to make it kind of automagic and that's pretty much always the downside of that, something not being really obvious
Hey everyone. I'm thinking to make a sort of a dictionary to search for entities by a specific value. Like
var ents = EntityDictionary.GetWhere( e=>e.Comp.Value == 2);
- Is there any solutions out of the box for that?
- If not, how would you approach this?
that can even be burst compatible
- no
as for how to
- create temporary entity query of chosen component or use existing one
- get chunks list from it
- get type handle of your comp
- iterate over all just like IJobChunk
- add entities to list that you will return later
So, just through iteration, huh? I thought more in the direction of a HashMaps with component value as a key and entity list as a value. Each time the value is changed the entity is moved to other "cell". Is this viable in dots? Or iteration would work better?
hashmaps are same thing, just a bit faster
but they have a downside
you need to track your component's value somehow
and update your hashmap
Yeah, I didn't thought about that. That would be a chore.
if your values are not spread widely
you might just SharedComponent
this way all entities of same value will be stored in their own separate chunks
from another value
Hm... I'll look into it. Thanks.
One more question. Can component store a NativeHashMap? And if not, where better to store it to have access from the systems? Separate system?
not sure anymore
ever since they made native collections unmanaged
I think you can store anything on comps
anyway
just try
it'll error on play
if component is invalid
or even during compilation
Ok, I'll try. It's just became even more convoluted since 1.0 where they said they recommend to remove any public fields from systems and instead use singletons.
And just above, a unity employee recommended to not use singletons and instead use a static class.
no way ๐
Ya know that hybrid discussion? The guy was saying singletons in Entities are ultimately a roundabout way to use a static class.
I didn't. And I also disagree.
Static classes are baked into C# and the best performant way to access and set singleton data sets. With no restrictions compared to using a single entity.
I do too but they do have a point. Its a lot more performant and easier on the code side.
Can I have a link to the discussion please?
anyone remembers how to get System signleton?
I've been seeing those SystemHandle params for various EM functions. No clue what they refer to. Systems can have entities?
I didnโt say singletons were a roundabout way to use a static class. I said that I thought for the situation in question, I thought static variables made more sense
Why would systems have entities? What cases would you need that?
they store pointer to systemstate
aaand I can't find how it works
Ah, I was wondering how to disable ISystems from outside the system.
yes, every system has an entity now. the systemhandle is a wrapper around an internal entity
that's really smth you should not do though
Too many entities. My hierarchy instantly gets flooded when I press play...
do you remember how to get it?
Took me a lot of time just to disable unity's built in transform sync systems because they were all internal.
World.GetSystemHandle() -> EM.GetComponentData?
from a system or someplace else?
I'd rather know both
getexistingsystem, getcomponentdata(systemhandle)
I am trying to implement similiar thingy for UI screens
World.Unmanaged.GetExistingSystemState<T>().SystemHandle``` what am i doing ๐
so, world reference, ok
World.GetExistingSystemManaged<T>().SystemHandle
or just
World.GetExistingSystem<T>()
๐ค
works on ISystems
I want to try and implement system that allows to open UI screens based of event entities
oh nice, right that's shorter
that store unmanaged reference to UI Screen
Trying to figure out though how to reference smth managed as unmanaged
first that comes to mind - index in List
nah, I use addressables assets
it's switching between screens which bothers me
because rn it caused quite too many reworks
and now system is so chunky I don't even want to develop it anymore
So I want to switch to some entity approach
but I also want it to be Burst Compatible
I'm getting a lot of compilation erros with a blank project. Is something wrong with my manifest:
{
"dependencies": {
"com.bovinelabs.event": "https://gitlab.com/tertle/com.bovinelabs.event.git#f827895246b9a01fa4dc146632a9260bbc19c64a",
"com.domybest.mybox": "https://github.com/Deadcows/MyBox.git",
"com.unity.2d.sprite": "1.0.0",
"com.unity.2d.tilemap": "1.0.0",
"com.unity.ads": "4.3.0",
"com.unity.ai.navigation": "1.1.0-pre.1",
"com.unity.analytics": "3.8.1",
"com.unity.burst": "1.7.3",
"com.unity.collab-proxy": "1.17.2",
"com.unity.entities": "1.0.0-exp.8",
"com.unity.entities.graphics": "1.0.0-exp.8",
"com.unity.ide.rider": "3.0.15",
"com.unity.ide.visualstudio": "2.0.16",
"com.unity.ide.vscode": "1.2.5",
"com.unity.inputsystem": "1.4.3",
"com.unity.physics": "1.0.0-exp.8",
"com.unity.purchasing": "4.4.1",
"com.unity.render-pipelines.universal": "14.0.3",
"com.unity.serialization": "2.0.0-exp.11",
"com.unity.test-framework": "1.1.33",
"com.unity.textmeshpro": "3.0.6",
"com.unity.timeline": "1.7.1",
"com.unity.ugui": "1.0.0",
"com.unity.xr.legacyinputhelpers": "2.1.10",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.assetbundle": "1.0.0",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.cloth": "1.0.0",
"com.unity.modules.director": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.physics2d": "1.0.0",
"com.unity.modules.screencapture": "1.0.0",
"com.unity.modules.terrain": "1.0.0",
"com.unity.modules.terrainphysics": "1.0.0",
"com.unity.modules.tilemap": "1.0.0",
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.uielements": "1.0.0",
"com.unity.modules.umbra": "1.0.0",
"com.unity.modules.unityanalytics": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
"com.unity.modules.unitywebrequestaudio": "1.0.0",
"com.unity.modules.unitywebrequesttexture": "1.0.0",
"com.unity.modules.unitywebrequestwww": "1.0.0",
"com.unity.modules.vehicles": "1.0.0",
"com.unity.modules.video": "1.0.0",
"com.unity.modules.vr": "1.0.0",
"com.unity.modules.wind": "1.0.0",
"com.unity.modules.xr": "1.0.0"
},
All of them have to do with Collections
Library/PackageCache/com.unity.collections@2.1.0-exp.4/Unity.Collections/UnsafeParallelHashSetExtensions.gen.cs(71,79): error CS0246: The type or namespace name 'UnsafeHashSet<>' could not be found (are you missing a using directive or an assembly reference?)
I've tried matching the versions of various entities-related packages, but the Collections errors persist
so would anyone know how to disconnect a entity's gameobject?,my hierachy is full of gameobjects that i can't change anything about,i would prefer to destroy them
You need to add the assembly reference.
Thanks. Thing is, there is no custom assembly definition in my blank project, but I'll look around if something like that is already here
It's been a while since I touched Unity and DOTS. Should I create a new Assembly Definition asset for every DOTS project?
Thanks, that's good enough of a starting point!
Sure...
I'm on the run to work, but what did you mean by a blank project?
I moved every single asset from an existing Entities 0.50 project into another folder, and then upgraded to Entities 1.0
Now I'm progressively incorporating the old code into the upgraded project
But after upgrading the packages aren't playing nice
what are the errors?
Huh, Burst 1.8.0 removed the mention of valuetuple support from its documentation. Did they drop support for it? Nothing in the changelog mentions no longer supporting tuples.
Stuff like this
Library/PackageCache/com.unity.collections@2.1.0-exp.4/Unity.Collections/UnsafeParallelHashSetExtensions.gen.cs(1894,86): error CS0246: The type or namespace name 'UnsafeHashSet<>' could not be found (are you missing a using directive or an assembly reference?)
they renamed a number of types
so yeah
you gotta fix it
Do I either manually edit them, or change the version of some of the dependencies?
type was quite literally renamed, not sure about the one you sent
but
for example
NativeParallelHashMap was renamed
in fact
separated into 2 differents types
for different purposes
so I had to manually go over each
That's kinda messed up that we are expected to manually edit released software
But thanks, I'll start doing that
Shouldnt need to do that....
What version of entities are you using?
hold up
I was talking about your own code
not actual package
Oh no, this is from the Collections package
"1.0.0-exp.8"
Unity version 2022.2.0b10
๐ค
What's your package manifest? Here's mine:
{
"dependencies": {
"com.unity.2d.pixel-perfect": "5.0.2",
"com.unity.2d.sprite": "1.0.0",
"com.unity.2d.spriteshape": "9.0.0-pre.1",
"com.unity.2d.tilemap": "1.0.0",
"com.unity.2d.tilemap.extras": "3.0.2",
"com.unity.burst": "1.8.0",
"com.unity.entities": "1.0.0-exp.8",
"com.unity.ide.rider": "3.0.15",
"com.unity.render-pipelines.universal": "14.0.3",
"com.unity.test-framework": "1.1.33",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.physics2d": "1.0.0",
"com.unity.modules.tilemap": "1.0.0"
}
}```
"dependencies": {
"com.bovinelabs.event": "https://gitlab.com/tertle/com.bovinelabs.event.git#f827895246b9a01fa4dc146632a9260bbc19c64a",
"com.domybest.mybox": "https://github.com/Deadcows/MyBox.git",
"com.unity.2d.sprite": "1.0.0",
"com.unity.2d.tilemap": "1.0.0",
"com.unity.ads": "4.3.0",
"com.unity.ai.navigation": "1.1.0-pre.1",
"com.unity.analytics": "3.8.1",
"com.unity.burst": "1.7.4",
"com.unity.collab-proxy": "1.17.2",
"com.unity.entities": "1.0.0-exp.8",
"com.unity.entities.graphics": "1.0.0-exp.8",
"com.unity.ide.rider": "3.0.15",
"com.unity.ide.visualstudio": "2.0.16",
"com.unity.ide.vscode": "1.2.5",
"com.unity.inputsystem": "1.4.3",
"com.unity.physics": "1.0.0-exp.8",
"com.unity.purchasing": "4.4.1",
"com.unity.render-pipelines.universal": "14.0.3",
"com.unity.serialization": "2.0.0-exp.11",
"com.unity.test-framework": "1.1.33",
"com.unity.textmeshpro": "3.0.6",
"com.unity.timeline": "1.7.1",
"com.unity.ugui": "1.0.0",
"com.unity.visualscripting": "1.7.8",
"com.unity.xr.legacyinputhelpers": "2.1.10",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.assetbundle": "1.0.0",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.cloth": "1.0.0",
"com.unity.modules.director": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.physics2d": "1.0.0",
"com.unity.modules.screencapture": "1.0.0",
"com.unity.modules.terrain": "1.0.0",
"com.unity.modules.terrainphysics": "1.0.0",
"com.unity.modules.tilemap": "1.0.0",
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.uielements": "1.0.0",
"com.unity.modules.umbra": "1.0.0",
"com.unity.modules.unityanalytics": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
"com.unity.modules.unitywebrequestaudio": "1.0.0",
"com.unity.modules.unitywebrequesttexture": "1.0.0",
"com.unity.modules.unitywebrequestwww": "1.0.0",
"com.unity.modules.vehicles": "1.0.0",
"com.unity.modules.video": "1.0.0",
"com.unity.modules.vr": "1.0.0",
"com.unity.modules.wind": "1.0.0",
"com.unity.modules.xr": "1.0.0"
},
dang, my burst is off. That's one
wait, old UGUI can be removed in 2022?
No, that's just my project. hrm.
nah, it can't
I can be removed but I dont have UI right now. I make sure my package list is as minimal as possible.
Close and reopen your project, same error?
I'm doing that right now
Welp, that solved it
@robust scaffold Thanks a ton for your support though!
@rustic rain you too
I completely forgot to do the first programming troubleshooting step, which is "turn if off and back on"
I really want to use IJE but losing out on pointers is just ugh
IJobEntity. The codegen job struct
The alternative is IJC (IJobChunk) and doing the enabled mask manually.
oh yeah, it sucks
Hrm, apparently IJE does support optional components.
Here's my automatic inspector for a ICD on an entity. Actually pretty easy to set up without having to go through manually creating a custom inspector script.
Produces this:
Always able to. I just stumbled upon it in my source code dives
I don't like it, cause I don't really want editor code in build
any idea
what they swapped Inspector<T> with?
These are all just properties, not actual fields. Without the editor in build, these are all stripped out.
And you can wrap these manually with a #if UNITY_EDITOR define anyways.
Inspector?
Any idea how?
hm. It's gone in my IDE
Subscenes?
PropertyInspector<T>
you mean if i am using subscenes?
Yea. If you want the GOs to disappear following conversion / baking, use subscenes.
i am converting them at runtime tho,how would i do that?
runtime conversion will be very soon gone
Oh, runtime conversion is currently up in the air right now. If you want to use a now deprecated solution, use ConvertToEntity monobehavior.
I highly doubt they'll be removing it entirely but C2E runtime is being deprecated and a replacement is... somewhere. Hopefully. Maybe.
private void Start()
{
grid = new DotsHexGrid<Entity>(10, 6, 1f, float3.zero);
for (int x = 0; x < grid.GetWidth(); x++)
{
for (int y = 0; y < grid.GetHeight(); y++)
{
using (BlobAssetStore blobAssetStore = new BlobAssetStore())
{
var go = Instantiate(testhex, grid.GetWorldPosition(x, y), Quaternion.identity);
var entity = GameObjectConversionUtility.ConvertGameObjectHierarchy(go, GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld,blobAssetStore));
grid.SetGridObject(x, y, entity);
Destroy(go);
}
}
}
}
any idea how to make that use subscenes?
you put game objects in subscene
and that's about it
I do but... Issue, you code it.
wdym up in the air? it's already gone in 1.0
Gone and maybe a replacement? We did see that runtime baking API that was internal and not used.
no replacement
no runtime anymore
poof
Doing this with the Baking process isnt difficult to do but difficult to explain to someone else. I recommend trying something easier as first steps into how the baking process works.
unity explicitly said they won't support runtime conversion in 1.0 and going forward as it's causing too much problems
Ugh, source? That might prove a problem for me down the line.
i think there will be hacks to do it regardless but that's the official stance
No doubt. And rolling my own wouldnt be hard. just annoying.
take a look at convertToEntity mono
source, hm, it was discussed here on discord. no idea when that was
I know it's deprecated. Just where did they said it's too much a hassle to continue supporting.
Which is why Im doing all this bullshit with companion GOs and assembly hacks to get a hybrid working. Runtime conversion solved a lot of issues.
well i am simply trying to make a Dots version of CodeMonkey's grid system,preferably to see what i can use it with,it isn't that important right now
anyways gtg,thx anyways
Ah, good luck then.
Anyone have an example using optional components in an IJE?
Alright, IJE optional components not possible. The [WithAny()] attribute only modifies the query search parameter and not any of the property field within it.
How does 2 enabled components in a single IJC work?
huh, I dont think it can
good question, you'd need to check both i think. the chunkIterator is just there to skip when both are disabled
surely can be checked with the mask
There's only 1 mask per IJC though. So the enabled state of both components are smashed together with an & operation presumably.
ok if there's really no proper way i don't know what to say, i considered it a bad feature before that ๐
the optional comp check is also so simple. chunk.Has() done. it's maybe doable with one of the RefRO/RW structs and checking for null. i dunno, the docs on it are non-existent
Yea, but it seems like the codegen IJE doesnt support that.
maybe unity should just stop codegening jobs. ๐คท there's always something and then you wonder, for whom is it?
to get the complexity what can be done in IJobChunk under 1 codegen is nearly impossible
Dont get me wrong, the codegen is sweet.
yeah it is, for very simple jobs
All of this into just this
To be fair, the first image is the header required for merging light and fov components into 1 job. And since I think I'm gonna make both L and F components into IEC, I have to split them for the enabled mask to work properly
Getting rid of the CTH<> boilerplate is the best part of the codegen.
lots of dev work for something that small is not worth it imo
and i dunno, i write such lines once. then i copy paste
even parameter names are just copy paste. LightData_ReadHandle, FovData_ReadHandle, etc...
hrm, and I cant do this since stackalloc will be inside a for loop...
yep, that won't work ๐
i think it would make sense to have an additional method, in case we want control over the outer loop
Execute turns into ExecuteSingle or smth
Yea. I wonder, how does aspects work with IEC as fields?
The more im thinking about this, the more I think IEC were a mistake...
last IJE I saw on the forum checked entities for HasComponent every time. it just hurts reading such code. use a chunk.Has ๐
heh
time will tell. since i have figured out proper change filtering i never understood IEC
it's a micro solution to a macro problem
IEC minimizes memcpy by toggling the component itself instead of relying on query chunk filtering but unless the component is being toggled off and on every other frame, is it really that much of a cost to just memcopy it?
I guess if you want to minimize refreshing Entity fields in other components, which would make the memcpy difficult to match.
well in terms of scalability 1.0 runs worse than 0.51 with the 128 cap, so they lowered the bar anyway. there's no fair comparison anymore. unity says, and i think the stance is pretty dogmatic, 128 entities in a chunk are enough and archetype size is mostly bigger than 128 bytes anyway. leaving out anything that runs on less. the worst thing of all, this hinders design. now you are basically a bad designer when you create an archetype with less than 128 bytes
To be faiiiiiiir, if you use all the transform components, the transform itself, the pretransform matrix for non-uniform scaling, and the l2w, that drops you under 128 chunk size without any additional components.
i am fair, not every entity has a LTW
yea, mine doesnt since I roll custom rendering, but generally 128 is a good upper cap while also allowing for v128 enabled bit mask operation.
sure, drop some physics on it, a LinkedEntityGroup maybe another buffer. Parent and Child. soon the 16k chunk size comes into question ๐
there is v256 though which would've been better but not supported on mobile and old pcs.
LEG is a travesty. I think it was your forum post but it really needs to be moved outside the chunk.
probably, i've been complaining about it a lot ๐
I think unity is pushing for a flattened hierarchy which is why they've largely ignored the problems with it.
everyone needs a hierarchy. at least, much sooner than IEC. yet IEC gets the core treatment
I still have trouble with that in simple gameplay stuff. For example, if I have an actor that has a lot of stuff like inventory, stats, equipment, etc, when do I start moving that stuff to other entities to improve chunk utilization or do I just not care
I think NativeX are all unmanaged now so you can add them to ICDs without issue.
I mean I can just use a dynamic buffer with size 0, which amounts to the same thing
it's really based on access patterns. things like equipment and inventory can be moved out with references. stats on the other hand should stay on the main entity.
I just meant in general when "piling on" a lot of components on a single entity
Buffers are only NativeLists, if ya want NativeHashMaps or other exotic containers it's now open season.
The item entity containing the stats is already separate, but I still need a buffer referencing them
You still get to a point where a chunk only holds a "few" entities pretty quickly
especially with the stuff you mentioned, LEG, parent, child, etc
Since I use netcode that's like another 50 components per entity
~_~
I havent tried netcode but if thats what happens, i might roll my own netcode using transport.
i use a separate stat entity but the final stats buffer is on the main entity/avatar. there's always downsides when getting those references but as long as unity stays true on their 16k chunk size, any archetype that has a capacity of <16/32 has to be optimized
I don't have very high performance requirements so its not a huge deal for me, but it does add quite a bit of overhead per entity
netcode is pretty good. i wouldn't roll your own ๐
I havent gotten that far yet so it'll probably get better by the time I do.
And how in the world does enabled components work with aspects?
Netcode is really good, it just adds quite a few components per entity
You can store within the aspect either the enabled condition of the component *or* the component itself, not both.
I still have no idea how I should be using aspects
for transforms it makes sense, but I have trouble thinking of other use cases in my project
I think it's a neat way to conglomerate the various frequently used together components.
My current use case is for two components, light and fov properties. Since Lighting and FoV go through the same rendering system (just rendered on top of each other twice), they are always used together. However, an entity could have disabled light but functioning FoV and vice versa. Or both on and both off. I'm trying to make a IJE that will marshal the data within the entities with enabled components into NativeLists for dispatch to the GPU. But doing so in a single job with IJE is surprisingly difficult.
Since I dont know how aspects will work with two enableable components. From what I can see of IJC, the enabled bit field if both components are in the same job is smashed together using an & operation which is definitely not what I want. I want an | operation.
I guess I just usually write a system that does one thing, and then I have some kind of component to signal that a thing should happen, so I the aspect wouldn't really make a lot of sense outside of the system. But that could just be that I haven't written a lot of gameplay code yet
Considering there's cap now
No need to bother until it's actually below 128
I dont think aspects can sidestep the issue of IJC merging the enabled condition of two or more enableable components. Since the for loop is based off a IJC's enabled mask and not anything inside an aspect.
Yeah but like with netcode and all the transform stuff some of my components hit like 10 entities per chunk
(granted they have some buffers that don't have internal capacity set to 0 that use up like 500 bytes or something)
i have other work to do right now :/ but i'm really interested in this multiple IEC use case
Well
The easiest optimization I use
Is moving graphics to child
But since I use pure mesh rendering, it might not be applicable for animated stuff
You can get enabled bit mask v128 from a dynamic component type handle:
from there, it's using ChunkEntityEnumerator using this mask and not the Execute version for iteration.
no i think for every enabled comp in every chunk
๐ค
Every chunk has an array of v128. One v128 for every enableable component.
Oh
Each bit inside the v128 corresponds to the enabled / disabled state of each component of the corresponding IEC.
Yes. That's the downside, the upside is "structural changes" without actually structrually changing the entity.
I mean
I don't see why 128 cap
Technically you should be able to implement any amount
hardware limitation
Yeaaaaaa. I dont know why either. There's v256 as well and in the hardware world there's also v512 but those are for supercomputing cluster CPUs.
There's some associated SIMD optimizations that take advantage of the count limit
๐ค
computers can only count up to 128 before they get confused
But enableable components break SIMD across components anyways.
Unless you're doing vpmaskset (whatever it's called) and those are for 64bit wide masks at most.
I have trouble deciding if I should use an IEC or just a tag that I add / remove for systems
with 1.0 use IEC ๐
but my chunk memory ๐ฆ
I dont get it, enabled components break SIMD / vectorization anyways. Except for the most basic of single 32bit values. All others requiring more complex structures cant be recognized by burst to vectorized across component boundaries anyways. Without manual reinterpretation to v256 and doing it by hand.
The only SIMD available will be during the checking operation and that screws over chunk size for everyone.
Is there a reason why there are a lot of operator implementations missing for half?
Half is a storage value. You're not suppose to do any math with half. Convert it back into a float then do math with it.
That's what I want the operator to do
? (float) halfValue doesnt work?
Sure it does
but half2 * half doesn't
I think it even has an implicit operator for half -> float
Yea, that's math. You must do (half2)((float2)half2 * (float)half)
that looks disgusting
It's a storage value. not a math value.
Yes, I get that. I wish the operator converted it to a float, did the math, and gave me back the half value again
Well you can do it with your own wrapper struct but the reason why it's not provided by default is because the conversion cost is non-negligible and those unfamiliar with using half sized floats dont realize that.
// masks for "All" types are AND'd together + // masks for "Any" types are OR'd with each other, then AND'd with the final result + // masks for "None" types are negated and AND'd together
hrm
Alright, smashed together slightly better but still has the issue where it's one v128 and not multiple.
Do IBufferElement have some kind of massive overhead?
It's telling me in the archetype that an entity with a buffer of 2 half2 is using 144 bytes?
what's your internalbuffercap?
I haven't set one
then it's 8
only when it's larger than the internal cap
Or does it just use a static backing array and then move everything off chunk if it exceeds that
then it will be moved outside the chunk memory
public static class ArchetypeExt
{
// ! Modified from ArchetypeChunk.GetEnabledMask<T>()
public static unsafe v128 GetEnableableBits<T>(this ArchetypeChunk chunk, ref ComponentTypeHandle<T> handle)
where T : unmanaged, IComponentData, IEnableableComponent
{
#if ENABLE_UNITY_COLLECTIONS_CHECKS
AtomicSafetyHandle.CheckReadAndThrow(handle.m_Safety);
#endif
int typeIndexInArchetype;
if (Hint.Unlikely(handle.m_LookupCache.Archetype != chunk.m_Chunk->Archetype))
{
typeIndexInArchetype = ChunkDataUtility.GetIndexInTypeArray(chunk.m_Chunk->Archetype, handle.m_TypeIndex);
if (Hint.Unlikely(typeIndexInArchetype == -1))
return new();
handle.m_LookupCache.Update(chunk.m_Chunk->Archetype, new(){ Value = typeIndexInArchetype });
}
else
typeIndexInArchetype = handle.m_LookupCache.IndexInArchetype;
return *chunk.m_Chunk->Archetype->Chunks.GetComponentEnabledMaskArrayForTypeInChunk(typeIndexInArchetype,
chunk.m_Chunk->ListIndex);
}
}``` Here's the GetEnableableBits using a CTH<> instead of a DCTH. Dont know why unity didnt provide this version.
I see
that's why a LinkedEntityGroup with default size of 8 is horrible. often you have only 2-3 elements and the rest is unused chunk space
and entity is 2 ints, so pretty big
But shouldn't it be 8 bytes if I have a buffer of 2 half2?
no, the length if the buffer is 2 but the capacity is 8
No, I mean if I set a capacity of 2
oh no there's a bit of overhead
Ah ok, that's what I was wondering
ptr, length, capacity and something else
Why static ones?
The pointer is an int64, or a long. So it takes up 8 bytes instead of the usual 4.
At least the reported 16 bytes make sense then
public struct Avatar_StatBuffer_Base : IBufferElementData
{
public byte Value;
}``` for example. the size never changes and DBs are actually quite nice for that
I mean it would still consume the same amount of chunk memory
Eh, I would actually use for that a public fixed byte Value[Avatar_StatsConfig.CONST_STATSBUFFER_BYTES]
My buffers usually stay constant, the values just change
how can i make sure that it's allocated inside the chunk?
fixed buffers, the c# version, is basically the equivalent of adding the number of fields to the struct. It is always inside the chunk.
hm, that would work then ๐
so a fixed byte Value[2] is the same as byte ValueOne; byte ValueTwo;
I changed some rider formatting settings, this has to win the prize for prettiest line of code
nice
thanks, I try
damn, wasn't aware of that ๐ yeah in that case i could change it to an icomp and save some useless variables
This was my polygon properties. NaN terminated list.
thanks man ๐ yeah i need to rewrite this
Is it faster to iterate using a pointer than indexing the array?
? They're the same thing.
I was wondering why you are using the pointer in the count function
Oh, I needed to reinterpret the float array into a float4 array. For maximum SIMD optimization.
Ah, I missed that, my bad
did anyone ever test this, when a DB is exceeded it will be moved outside the chunk. but when it gets smaller again, does it ever move back? afaik it doesn't
Yes, it does. So long as you reset the capacity to below the DB's IBC.
I forgot the method but it does.
ok cool thanks
also, make sure to use chunk.GetRequiredComponentDataPtrRO() for non-optional components in IJC.
Alright, i think this is how you use IJC with enableable components without needing to split into different jobs:
Well, it doesnt explode.
You can add more than 2 but then it's shifted outside the chunk and onto Allocator.Persistant like a NL
I know, I was only joking since things usually have 2 hands ๐
i think it's funny that IJE doesn't use chunk.GetNativeArray in the generated code but gets the ptr ๐
ptr = fast
ptr stronk
yet unity doesn't want us to use them ๐
then
ref var speedData__ref = ref InternalCompilerInterface.UnsafeGetRefToNativeArrayPtrElement<Speed>(speedData, i);```
Not really nowadays. Lots of implemented pointer functions which is really nice.
upside, no unsafe context needed
yeah, they want us to use them, but not really, but when we reaaaly want, have them
btw the fastest way to get a comp ptr from a chunk is now with GetRequiredComponentDataPtrRO/W
Yep
what, you cant set enabled / disabled property on bake? Tsk tsk, unity. Shame.
Time to hunt for the internal property to make it possible.
All lights disabled through the entity inspector because I was lazy to code an actual way at bake.
wait, you managed to disable IEC on bake?
ah, i'm looking for solutions for that
but the GetEnableableBits<T> using CTH<T> instead of DCTH works.
ok the differences are minuscule if (Hint.Unlikely(lookupCache.IndexInArchetype == -1)) return null;
are you remaking DROD? ๐
drod?
haha, nvm then ๐ very nice grid based puzzle game that also had shadows like that in dark rooms
How do you set a shared component filter on an IJobEntity?
IJE scheduling takes a query as well. You need to create a query with the ISCD filter that you want.
eugh, that's kind of annoying
Is there some function to get the shared component data for an archetype chunk?
Or do I just get it normally with a type handle?
Inside a IJC?
There's SharedComponentTypeHandle<> -> chunk.GetSharedComponent(). Readonly in a job though.
Alright, so just the type handle
Yea, everything is just type handles in the end.
I thought there might be something like ArchetypeChunk.GetSharedComponent<T> or something
I should be fine with only reading it once and then caching it at the beginning of the IJC though right? Since it is always the same
Yea. Each chunk has only 1 SCD.
Thanks, just making sure ๐
Anyone else think CleanupComponent is a weird name?
I think I preferred SystemStateComponent
I guess it more clearly differentiates them away from the new SystemState for ISystem ๐คท
Yea. But at the same time, cleanup is basically all that it does.
Yeah but it feels kind of weird to store data there. I usually put my NativeCollections inside ICleanupComponent so they don't leak if the entity gets destroyed
That's what they're intended for.
Yeah I know, like I mentioned I guess it just feels weird putting state data in something called cleanup ๐คท
I guess. You'd think that the corresponding tag ICD is to be named cleanup and not the actual ICCD.
I guess if it were struct SomeComponent : IComponentData, IRequiresCleanup I would feel better about it, but at the end of the day it doesn't really matter
Yea, like how IEC is an additional interface and not IECD.
Yep
Also not a huge fan of all the different types of cleanup components
e.g. shared, normal, buffer
ugh, yea. Disgusting.
Something I'm struggling with while porting some code at the moment:
I have some state that is in a system, and it holds some native collections. It does some calculations, and another system relies on the length of the computed data to schedule an IJobParallelFor. Is there a better way to do this besides calling Complete on the system?
My first step is to move the collections out of the system and onto a component, but that doesn't solve the dependency issue
I also can't get the component and use IJobParallelForDefer since that also requires the job to be completed
IJobParallelForDeferred. Use an NativeList.
hrm
But the list is in the component? How would I get it on the main thread
does the component need to have the list?
Not really, like I said, currently it's just stored in the system
But that doesn't seem to be the way going forward
hrm, it is an option to make a NativeArray<int>(1) in the system with the [0] index containing the final length of the nativelist and pass a pointer to that NA into IJPFD for scheduling.
Yeah there are some ways around it, but it seems kind of cumbersome
Couldn't I also store a pointer to the length of the unsafe list backing the native list and pass that to IJPFD?
You could, if you can guarantee that the list will not be disposed.
I wish you could schedule an IJPFD on a dynamic buffer
(but then you'd also need to get it so that probably wouldn't help either)
:[
That would be interesting but may be possible.
Yeah I think it's doable, but I'd need to get the dynamic buffer on the main thread (same as a component), and it's scheduled, so I'd need to complete as well
Might still be useful for other stuff though
public static unsafe JobHandle ScheduleByRef<T, U>(this ref T jobData, NativeList<U> list, int innerloopBatchCount, JobHandle dependsOn = new JobHandle()) Just look at the source below that method signature for IJPFD and you can probably do it.
Yep, I'd still need to call complete though
complete before? Shouldnt need to.
I can't get the dynamic buffer otherwise
Ah, the DB yea.
Well, you might be able to pull and cache the DB's pointer. Assuming it's stored outside the chunk.
Is there some other way to divide logic across many threads that relies on the data on a single entity?
Not really... IJPFD is I think the only way.
Hmm, alright. Guess I'll just do it by calling Complete ๐คท
Singlethread is better than multithread for surprisingly the majority of options
unless your DB is 1000+ size.
It's just a very compute heavy operation
If it was just some iteration with light logic I wouldn't bother
Can you vectorize it? Otherwise, you might be able to hack together a IJPFD using a NA containing a pointer to the DB backing array and another NA containing the list size for thread dispatch.
Basically the entity represents a world, and contains a list of chunks that need to be created. The chunks are 16x16 tiles and need to do a lot of noise generation, so I think it would be better to split it up on threads
Why cant you make each chunk it's own entity?
I could, but that would probably be a lot of entities per frame
It would certainly make the dependency handling easier
How many times do you need to regenerate the noise?
Whenever an entity moves across a chunk boundary
It gets rid of the chunks that it left, and queues the ones it entered into to generate
I dont know how you're using this noise but what I would do is get 3 already pre-generated noise textures and overlay them with NoiseTexOne and NoiseTexTwo rotating.
No complex noise calculation, just rotating textures and then sample a block for the final noise value.
I might do that in the future if I need to optimize, but for now each tile belongs to a biome and has multiple layers which are just set up on a scriptable object, so that would be a lot of textures
Just 3 global 500x500 ones and then randomly sample a 16x16 block.
They use different types of noise and different frequencies and octaves
Ugh, that's up to you then.
Haha, I know it's all cacheable. If it becomes a bottleneck I'll build some archetypes and use textures, it's definitely the much more performant approach ๐
Is there a way to add a component as initially disabled during the Baking process?
Nope
I still have trouble gauging the performance impact of creating a lot of entities each frame. Each entity that can activate chunks can do so in a 3x3 area, so with 500 actors that's 4500"active chunk" entities, and at least 3 created and 3 destroyed per entity that moved across a chunk boundary in that update
Pain but no.
4,500 is nothing. Go for it.
Really? Even if I add and delete potentially hundreds per frame?
The creation / destruction is an issue though. How many times per frame?
Do you need to structurally change them? Can you not just modify the components?
That sucks. Fortunately turns out I don't need it ATM after doing some thinking, but this seems like a pretty critical feature for most developers
Yea, this is very early dots 1.0
I think this will be added in the future, pretty much everyone has requested it I think
I mean, you can create a baking system to do it, if you really really need it.
devs are aware by now ๐
this is also not working
??? huh.
disable it in runtime
Awesome! In the meantime, is there still an advantage to adding/removing components? In my current use case, the component rarely gets added and removed.
even a baking system can't disable an IEC
Not having enableable components means the per entity iterations within a IJobChunk are a lot faster since it skips the enable bit check.
Well, "a lot faster" is relative. I doubt it's by much.
Sweet, so there's a tradeoff. Thanks!
Im assuming it's because serialization doesnt yet store the v128 bit flags for enabled components.
Can you pass an EntityCommandBuffer to an IJobEntity that you run on the main thread? Or do you also need to use an ECB for structural changes
most likely
If you're doing it main thread, you can pass EntityManager to an IJE.
I also wish queries could somehow do structural changes, creating an ECB before and playing it back is really annoying
? You could? Add and remove components across queries
You can't destroy or create entities
Well, creation of entities is just using an archetype and specifying a number of Entities to generate. Destruction, uhhh. Let me see. I'm fairly certain you can.
I tried it earlier and everything exploded
You can.
Oh. that's just a glorified for each
I think it code gens to EntityQuery.GetEntityArray()
Yeah, but I have some stuff that does structural changes on the main thread very rarely, and there is no replacement
Doing it using EntityQuery.GetEntityArray() -> EntityManager still works.
Yeah definitely, but I feel it would be nice if the query could do that too
Ugh, tomorrow, i need to figure out runtime prefab spawning. Until then, sleep for me
I'm trying to do hybrid without companion GO
I'm not sure what you mean? The baking process converts it to an entity. There is no game object during runtime
I've got a prefab GO inside a managed component
Prefab as in actual prefab. Not entity prefab
You can reference the game object inside an authoring component and baking converts it to a prefab entity
(that you can store as an Entity in a component and then instantiate)
But I don't want it to convert
Why not?
It's my hybrid GO, containing physics2d components and sprite renderer
Ah, then I misunderstood
I just use normal game objects and the entity stores a reference to it, I never messed with the hybrid stuff
How do y'all bake your input actions? I'm finding it doesn't work in 1.0 for some reason...
You mean from the input system?
yeah
Is the asset broken for you?
Nah I can put the asset on a managed ICD no worries
but the actions maps dont want to work
likely a skill issue
Ok then I have no idea what you are doing, I just get my input on the main thread ๐
Trusty built in input
Do you cache your input maps in a system or something tho?
cos you gotta load them up at startup
I just create an instance of the input system class manually
And have a static class that manages it, then I just read the input or subscribe to callbacks on that instance
Reading would look like this
Everything is fetched on the main thread in a system update
I don't have any input stuff on entities
Gameplay is the action map, Target is the input action
whats System?
an instance of the input system class defined by my input action asset
ok this is where I'm not understanding... do you generate the C# ?
Yes
ah ok
Otherwise I couldn't have an instance of the class ๐
now im on board
yes well I've never gone that route before lol
I only know enough to know that I don't know, you know?
It makes it vastly easier imo, since you get compile errors if you rename, add, or remove anything
And you don't require any initialization (besides creating the class and enabling an action map)
thanks Schnoz, I might try that
Can you not disable the multi threading safety on a component lookup?
do you need [NativeDisableParallelForRestriction]
ref readonly weirds me out
and i also find it annoying, it makes it unclear what the value is
eh nvm me ๐ i just had no clue about the correct syntax. it's ref readonly var val = ref someRefRO.ValueRO;
please put this in the comments of RefRO.ValueRO. took me quite a few tries to find this
Hey guys, took a break from ECS, left off at 0.50. I see that 1.0 is out. Looked over the docs, I see new concepts (i.e. Aspects, Baking, etc). What's a good single go to resource that can give me good direction on ECS 1.0?
awesome, thx
c# on unmanaged memory isn't normal c# anymore. it gets pretty unclear what's happening. you don't have to use the ref. now what is val? and UnsafeUtility.AddressOf with a ref readonly doesn't work :/
the comment from ValueRO is already pretty lengthy. noone gets hurt if you throw in that additional info
and UnsafeUtility.AddressOf with a ref readonly doesn't work :/
well that makes sense ๐
they can only be passed to 'in' variables
i just want to get a damn ptr
that's what the non-readonly version is for!
you're kind of fighting a compiler here
i've changed my stats buffer to a fixed byte array public unsafe struct Avatar_StatBuffer_Base : IComponentData { public fixed byte Value[Avatar_StatsConfig.CONST_STATSBUFFER_BYTES]; } i can only access Value with a variable otherwise i get fixed usage in unfixed space errors.
now i'm not really interested in the access anyway because the ptr to it would be enough
if this doesn't work with ComponentLookup i'm just gonna use my UnsafeCDFE and be done with it. i want to give it a try though
i can only access Value with a variable otherwise i get fixed usage in unfixed space errors.
curious what error this is specifically
this works without fixed
isn't this just because you've made a copy?
copy of the ptr or the whole struct?
is VakyeRO = Avatar_StatBuffer_Base ?
yeah, i have Base and Final
so the whole thing is moved onto the stack
/// Returns a read-only reference to the component value itself.
/// </summary>
/// <remarks>
/// This value is a reference to the actual component data. It is safe to use this field directly, e.g.
/// "Data.Value.SomeField". It is also safe to make a copy of this value, e.g. "var myComponent = Data.Value".
/// Keeping a ref ("ref var myref = Data.Value" is inherently unsafe as any structural change may invalidate this
/// reference, and there is no way to detect this. It is safe to use this reference locally if you can guarantee
/// that no structural changes will occur in between acquiring it and using it. Do not hold on to such a reference
/// for any extended amount of time.
/// </remarks>
public unsafe ref readonly T ValueRO
{
get
{
#if ENABLE_UNITY_COLLECTIONS_CHECKS
AtomicSafetyHandle.CheckReadAndThrow(_Safety);
#endif
return ref UnsafeUtility.AsRef<T>(_Data);
}
}``` why i'm even talking about this
and the GC no longer cares that it could potentially move the container
/// "Data.Value.SomeField".```
hm, is there no other method to allocate an array inside an IComp other than fixed?
you can use fixed containers
FixedList etc (wouldn't be hard to make a FixedArray version)
but not really sure it's what you want
i'd need to be able to define the bytes amount
i've a distaste for fixed in unmanaged memory and burst, that much i know ๐
you can do that
for example I have this
where T : unmanaged, IFixedSize```
let's me assign any size bit mask
private struct Bytes4 : IFixedSize
{
}```
for example
private struct StatBuffer : IFixedSize
{
}```
you could do it like this for example
public FixedArray<StatBuffer> Stats;
ah, structlayout. yeah, why not. thanks.
this was very, c++ inspired ๐
and how would i get the ptr to it?
it's just a struct
implement an access [int index]
where T : unmanaged, IFixedSize
{
private const int Idx = 3;
private const int Shift = (1 << Idx) - 1;
private T data;
/// <summary> Sets the value of a bit in the bitmask. </summary>
/// <param name="pos"> The bit to set. </param>
/// <param name="value"> The value to set it to. </param>
public void Set(int pos, bool value)
{
this.CheckArgs(pos, 1);
fixed (T* t = &this.data)
{
var ptr = (byte*)t;
var idx = pos >> Idx;
var shift = pos & Shift;
var mask = (byte)(1 << shift);
var bits = (byte)((ptr[idx] & ~mask) | (-value.AsByte() & mask));
ptr[idx] = bits;
}
}```
for example this is how my set works for my bit array
it's just a struct that holds a block of data you assign from the generic
{
get
{
fixed (byte* t = &this.data)
{
return t[index];
}
}
set
{
fixed (byte* t = &this.data)
{
t[index] = value;
}
}
}```
would just look something like that
for an index if you were doing a fixed array
you can make a ref return version
or whatever you want
thanks, i'll try that tomorrow. tbh, i don't want to use fixed mainly because of this ```byte* stats = null;
if (spellData.Effect_Main.Value.snapShotStats)
stats = statsAccessor[i].Value;
else
{
ref readonly var tmp = ref StatBuffer_Final_Lookup.GetRefRO(spellOwner.source).ValueRO;
stats = UnsafeUtility.AddressOf(ref tmp);
}```
doesn't play nice with something like this
{
get
{
var d = UnsafeUtility.AddressOf(ref this.data);
return ref UnsafeUtility.ArrayElementAsRef<byte>(d, index);
}
}```
i think would work
and i wrote a small method to return a ptr which has that warning
unity dev lied to me ๐ฆ said i can get the address from a RefRO
try void
same error
what type is your this?
Can someone give me a quick example of the power of using Aspects?
byte
ah, seems the struct is the problem
still unsure why you don't want to use fixed?
But I don't see a DOTS file menu, not any option to enable Live Conversion. Even in the Edit>Preferences>Entities section.
Unity's version of 'turn it of and back on again' is often: close Unity, delete the Library dir, open Unity...
go Help -> About
Type internal
check edit -> preferences -> entities again
they accidently? left an attribute on the option to hide it from the menu
lol, now that's just odd. thx for the tip
i also like how that is disabled by default. Go Unity! haha
i'm not sure if it is or just your state you had before you upgraded is just stored
https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/ECSSamples/Assets/HelloCube/1. MainThread/RotationSpeedSystem.cs
reading up on the examples in unity's repo, they dont' seem to do OnStartRunnung() { someQuery = Entity.Manager.CreateEntityQuery(); }
instead they just foreach
SystemAPI.Query<RefRW<LocalToWorldTransform>, RefRO<RotationSpeed>>()
any reason to do that?
or is this a burst compiler thing
i see unity physics has a 1.0.0 experimental version, does it support the new transform system yet? Or is it still using the old one?
old
what you're saying here do different things
but really SystemAPI just hides a lot of boilerplate
ah sad, i was hopeful for a bit
hmmm
Unity removed [BurstCompatible] attribute
I like it though
was a nice way to mark whether certain method is burst compatible
they renamed it
they renamed it to what it actually does
huh?
that's what the attribute always did
I used it only for personal work in IDE ๐
it generated unit tests
that could be run in a build
to test if a method actually worked in burst
so
just make your own attribute?
if it's marked with attribute
then during run it'll error?
if not burst compatible
if you run the obscure command to do it
and make a test build
and run the tests
then yes
ah
(unless you are very determined, i very much doubt you were actually getting anything out of those attributes; they only do anything if you proceed to run the codegeneration that knows about them AND then make a player build afterwards)
yeah, I only used them to know whether method can be used in Burst
grumble grumble
var commandBufferSystem = SystemAPI.GetSingleton<BeginEffectEntityCommandBufferSystem.Singleton>();
Packages\com.bovinelabs.effects\BovineLabs.Effects\Effects\Systems\EffectDestroySystem.cs(66,39): error SGSA0001: SystemAPI usage with generic parameter not supported
this doesn't look generic to me ๐ข
was kind of hoping I could just have a base ECBS
so i didn't have to keep manually implement the Singleton
but i guess is why unity didn't do that...
it's fully resolved though so I really feel like it should be handlable
So sadge, we still don't have a way to register generic components through reflection
Still didn't understand your use case of this that wouldn't break il2cpp
Was it just convenience
it's not really meant for il2cpp I think
and yeah, this is pretty much for convinience and some edge cases
It's just that il2cpp has even stricter requirements on generics than entities and burst
I've broken il2cpp multiple times from generics that work fine in mono / entities
does il2cpp allow for loading new assemblies in runtime?
so il2cpp are fine?
That said you seem focused on Modding so probably only looking at Windows mono? in which case this all all mute
Interesting, seems like one I fixed recently, but could you post the whole snippet? ๐
I am certainly focused on Modding, but tbh registering ComponentTypes in runtime is not related to it really
while I have you for a minute @proud jackal, can I ask what the possibility of something like this would be?
#archived-dots message
For 1.0 likely not - but I'll happily show how one might add it to the generator themselves, with the obvoius caveats of changing entities yourself :3
obviously i don't expect some major feature request for 1.0, i'm sure you have a whole task list of stuff to do
was just more curious about a) if it's feasible (which you seem to imply it is) and b) if it's something that would even be considered
as for doing it myself, i have had a quick look at the Unity.Entities.SourceGen.JobEntity.csproj
which I assume is where it'd be done?
but I try not to make changes to packages as it's just a pain to maintain and I don't need the feature enough to warrant breaking this rule at the time
just been thinking a lot about how entities 1.0 is shaping up with systemapi and how clean code is starting to look
JobEntityDescriptionSourceFactory.cs
with changes like this would pretty much do it:
ok so tempting
Does anyone know if there is a problem with having many systems that run very infrequently?
I would like to create an individual system for each ability a player or npc can perform to allow for maximum flexibility in terms of execution logic. Or can you think of a better way to encapsulate the logic of an ability?
historically yes it's been terrible
in 1.0 with ISystem it's a lot less problematic
we basically merged all our systems into 1 giant system
in 0.17
merging to single system, lots of little jobs - 2.5ms
1 single system, merging into 1 large job (reusing Gets) - 0.75ms
1 single system, 1 large job, burst compiling Gets - 0.35ms```
this is what i mean by being terrible in 0.17
benchmark xbox one back in February
Okay very interesting
now this has improved a lot in 2022 + 1.0
job scheduling is much cheaper
using ISystem significantly reduces system overhead
So if I have to make a design choice right now, do you think I can go with the many systems approach or would you still opt for fewer bigger systems to be safe?
cached GetX and Update is much faster
it depends entirely on your numbers
i should say we have like 500 systems or something ridiculous in 0.50
We are probably talking around 100-150 different ability systems max
unfortunately i don't have the numbers of large enough project to say either way if this would be fine now
we are unlikely to upgrade work project to 1.0
and well it'll take 2 years before next project is large enough to start finding scale issues
Okay I will do some testing on my own and keep the architecture flexible for now I guess. Thanks a lot tertle!
i will say very roughly that systembase is like 0.1ms and isystem is 0.01ms with like single query / job
overhead at least on my machine
so do the maths
or just create 150 dumby systems ๐
thinking about it, personally 150 systems for a single feature might be a bit much, but for no particular reason though
Last time I checked, I have 89 systems including built in
no netcode, no physics though
150 systems = 150 entities so there is that, but not like the biggest cost in that :3 But from a design perspective, 150 framgentations of one feature does feel weird to me
I've read up one way how to reference prefabs in a tutorial, but tried to use IBufferElement over IDataComponent to reference multiple prefabs but the authoring component doesn't have an editor drag drop
[GenerateAuthoringComponent]
public struct EnemyPrefabElement : IBufferElementData
{
public Entity Value;
}
how would you fill this?
why have a partial struct ?
shrugs probably typo when testing
but anyway how would i create a collection of prefabs
to refer to
[GenerateAuthoringComponent] no longer works in 1.0
are you using 0.51 ?
in experimental yes
yes, couple of weeks now
with 2022.2
If you are still in 0.51 you can start here :
https://www.youtube.com/watch?v=N-xoBFi2YF0&list=PL6ubahbodJ3N2udo4n9yGQcpbWnqdgYnL
In this video we will present the main packages of Unity's Data oriented Technology Stack.
We will also setup our workspace and introduce the core concepts of ECS that we will explore in the next videos.
SOURCE CODE & FOLLOW ALONG CONTENT
https://github.com/WAYN-Games/DOTS-Training/tree/DOTS-101
com.unity.rendering.hybrid
CHAPTERS
00:00 ...
is it?
it will take you to 1.0 in the 4th episode
@deft pilot if you use a lot of [GenerateAuthoringComponent] i would highly recommend duplicating your project so you can see previous data
i don't
well if you don't, it's not that painful of an upgrade
okay good
the only thing i used it for was literally this thing
weird installed 2022 dont' see 1.0.0
do i have to manually download it?
