touched on a little here: https://forum.unity.com/threads/exciting-developments-in-upcoming-entities-1-0-releases.1341071/
#archived-dots
1 messages ยท Page 29 of 1
yeah that's the one
if you really don't like it from what i've seen baking basically has the option to choose your transform components now with the TransformUsageFlags
and you could replace it with your own
Yes, that's the idea.
Hrm, not much appearing from google or a source dive. Any examples of TransformUsageFlags?
Oh, found it. Hrm. Gonna see what I can do with this. Seems flexable.
Also, does anyone know how to lock the view mode of the inspector to the entity runtime version when clicking on converted entities in the entities hierarchy?
Yeah, the baking preview is on its way out. We're no longer maintaining it. It gets to stick around until we have a good UX in the Entity inspector for GameObjects that generate additional entities. After that, it will be removed.
wondering if there are any graphs, or things that compare the performance of the particle system (gpu mesh mode) to entities? Tryna work out which is faster, and although the general consensus is that the particle system is faster, it would be nice to some data, like a graph or something
Does anyone know what these two components are? They are giant and I dont have any transform components on this entity.
We're actually working on that as we speak. DataModes will either be chosen automatically based on context or locked to what you chose from the UI.
Good to hear, it's really annoying right now.
Yep. So is the 3-way toggle in play mode. We are making it a drop-down.
Hrm, bug or not? This flag is not actually used. Instead, the transform creation baker queries for None or ManualOverride to determine if L2W matrix should be added to the entity.
From what I understand the new transform system is very much in it's infancy, i expect a lot of features are either missing or will be fleshed out.
very few people are likely to be using it due to physics (and netcode) not working with it yet
True. What I really personally want is for unity to reduce the LocalToWorldTransform name size. It's twice as large as all my component names. They did good with cutting ComponentDataFromEntity to ComponentLookup. L2WT needs the same treatment.
well when we get c# 10 you can just do something like
global using L2WT = Unity.Transforms.LocalToWorldTransform;
if you really want...
10? We're just breaking into C# 9 features. I dont want to even think of what 10 would bring. Makes me sad.
We'll sooner see tiny get revived from the dead than C# 10.
a) I disagree and b) do you not have tab completion?
I do. I also have vertical code alignment. The size of L2WT makes the following component type handles have a lot of white space.
true
CDFE also had that problem but segregating it via new line was fine as there was often a lot of CDFE being used within the same job. ComponentLookup is only 2 characters longer than ComponentType so now it can be in the same group.
Hrm, is there any way to order the baking of GOs? I need a baker to run before another baker does so. Trying to roll my own companion GO system.
think you're probably meant to utilize baking systems if you need ordering
there are 4? groups you can assign to as well if you need to inject in a specific point
The baking systems just seem like stock systems that run during the baking world. Do I just query every GO that need a companion GO over and over again? Rolling my own incremental baking is gonna be pain.
once you get to baking systems i don't think your authoring data exists anymore
you need to have passed it on via components
you can have baking specific components though
via
[BakingType]
[TemporaryBakingType]
Hrm, so make an intermediate managed component containing copies of the monobehaviors... huh. TemporaryBakingType?
/// Strips the component at the end of baking process. As it is removed after a single baking run, it will not be present
/// in subsequent baking runs unless it is (re-)added by a Baker.
/// This also means that the component doesn't show up at runtime.
/// </summary>
public class TemporaryBakingTypeAttribute : Attribute
{
}
/// <summary>
/// Automatically adds the component to each entity that the baking process creates.
/// The component is stripped out automatically at runtime.
/// </summary>
public class BakingTypeAttribute : Attribute
{
}```
ideally all work is done in bakers but sometimes you might need to do extra stuff (or you want to do a heavy load and burst it in the sytems)
this way you can pass data from bakers to baking systems and it'll be removed for you when done
Interesting. Temporary seems like the incremental whereas the basic baking type is added every time baker runs.
Alright, lets see if I can make this work... tomorrow. Thanks for the help. 1.0 is clearly very experimental but an exciting new world.
Hybrid interop
anyone else have issues with latest entities + physics 1.0 giving error for 'LocalToWorldTransform'?
LocalToWorldTransform should not be usable if you have physics enabled
right, just saw in a post, thanks
physics/netcode do not support the latest transform system so force enable the old V1
so everything back to Translation
anyone have an idea of what BakingType would typically be used for? sometimes struggle to think of uses for some of the features available
i'm still not 100% certain of the use for BakingType vs TemporaryBakingType
but i've been using TemporaryBakingType a bit
yeah same
but bakingtype, data that persists between bakes but not during runtime. not like the user can modify the data post bake right(thinking of level design purposes)?
You can use baking type to add some child transform component. As it doesn't get added during baking system update
Curious how the new baking system interacts with physics prefabs for example currently my conversion has to do additional initialization steps later as physics entities ( joint conversion creates additional entities containing Joint components ) etc don't exist and can't be referred to inside the IConvertGameObjectToEntity mono's..
Anybody looked at this at all?
physics currently updates mostly in baking systems
it creates passes temp data in bakers for the systems
any idea if it is possible to access those joint entities within the baker?
you should consider baker isolated
think of baker as Designer who designs authoring entities
past Baker you can access anything in BakingSystem
only within ECS sadly
ah i see that's interesting
so it should then be possible to access the additional entities created by joints, inside a BakingSystem
inside BakingSystem you literally have SystemBase
and world
all your systems will run once
same rules as runtime
ah right ok
one example is accessing Constraints, the default conversion values aren't perfect so i do additional tweaking of those once i spawn my prefabs ( because they are not accessible during conversion ).. so if i could avoid that kind of stuff it would help simplify things
you pretty much have 2 phases for tweaks
Baker that can only access entity mapped to authoring object and additional entities you create
And BakingSystems that just do whatever they want in entities world without any access to authoring objects
Biggest annoyance to me here
is that you are literally forced to create additional types
just for baking
mmm
so can those 'bakingsystems that just do whatever' access and alter Prefab hierarchies that have previously been converted by the first phase?
you can do jobs here, kek
if you want
it's literally normal World
that only updates once
that's about it
cos i'm guessing phase 1 baking will generate the Prefab entity hierarchy, which would include LinkedEntityGroups, Joint entities, and all the stuff that isn't generally accessible during conversion
ugh
yeah
I wouldn't be so sure about that
Child buffers are not created
so
for my baking I implement my own buffer
BakedChild
you mean ever because they've been removed or specifically during conversion?
I think they are simply not added
by the time my baking systems run
and I wasn't able to find a way
to update when those buffers are created
it's irrelevant anyway
the way I see it, it's way too simple to create such buffers yourself
yeah that sounds like exactly the kind of workarounds i'm currently doing for physics
by doing Baker<Transform>
yeah i mean it's simple enough to iterate the transforms of the hierarchy during conversion currently anyway, i'm assuming baker is the same
problem is i guess just those out of reach components and entities, that are generated later and not accessible during conversion
what is it you want to access?
the order of baking is
PreprocessBake
- PreBakingSystemGroup
Bakers
- BakingSystem.Bake
PostprocessBake
- TransformBakingSystemGroup
- BakingSystemGroup
- BakingSystem.UpdateReferencedEntities();
- LinkedEntityGroupBaking
- BakingCompanionComponentSystem
- PostBakingSystemGroup
- BakingStripSystem
i really think that if unity is to achieve it's aims with dots, conversion (baking/whatever) really needs to be simple/linear/not-convoluted.. i think not every dev is going to have the patience to do complex multi-stage setups just to get basic hierarchys converted over
yeah, it sucks
thanks
haha yeahhh
tbh, if you're feeling like it's messy and it sucks, and you're a capable dev well versed in the kind of juggling that dots involved, i think there will be a lot of less patient/technical devs that just give up
if it's too difficult, it's a high entry barrier to dots sadly
on the other hand, i think most normal devs won't be doing such weird things
the ironic thing though, to me, is that ecs and systems are actually pretty straightforward, conversion is the headache part
I'd say the biggest trouble with baking - people were too used to conversion
so they try to apply the same rules while migrating
conversion was OOP and baking is ECS, same trouble of migration xD
my only complaint atm is my inability to create entities in baking systems
or maybe i've just missed something
you can't?
doesn't it have the create additional entities thing
no
it's an ISystem
it just says entity not assigned to an authoring component and will be ignored or something like that
to inherit from?
i basically just wanted to store some meta data per subscene
i in the end just created a new authoring type and set it up on that
but it's annoying i have to manually add this to all subscenes
instead of automating it
again, i could have missed a way to do this i didn't look that deeply
but nothing was obvious to me
i have a feeling they might address that
i did consider attaching it to some subscene entity
is moving conversion from oop to ecs an unnecessary headache
can't we just have all the benefit of oop for conversion which is a one-time thing anyway
pretty sure they did it
because conversion wasn't doing too well with live conversion
mm
imo all that live conversion shit was just another layer of additional headache
i mean i know it's nice etc to have that but damn
well, I do like the idea of it
and if it works
then fine, my heart with accept it xD
wouldn't it have been simpler just to have subscene as a container holding a bunch of GO's that are converted either when you hit CONVERT or on running the game
(in the editor)
ain't that's exactly how it meant to be?
just simple, without all the bugs/mess
you either close subscene (convert offline)
well currently subscenes are live, and buggy as all hell in my experience
or start with open (convert online)
for me the damn buttons were just vanishing
well this was with 0.5/0.51 back in unity 2020
and subscenes have been around a lot longer than that
i hated it right off the bat tbh, just added a whole other layer of complexity/fickleness/bugs
the best way to have a rocksolid pipeline, is to have a rocksolid pipeline
the more i think about it, the more i think why move conversion over to ecs
getting assets in to dots should be the easy part
not essentially a bottleneck to entry, which is what it is ( pre 1.0 and from what i gather just as much in 1.0 )
i think having the option for much faster conversion of very large scenes and assets should be an optional stage
i do like the concept of Baker and BakingSystem, i think it unifies the whole previous toolset, which was very messy, into one ecosystem.. but it has to be easy to do conversion of typical game asset setups
if it makes it harder and more convoluted, ๐คทโโ๏ธ
๐ฅฒ Simple test project still can get this subscene error
clear the entity cache after you fix any compile errors
For 1.0, where's clear the entity cache button located at? Can't find it lol
preferences -> entities
๐ Need more bottom tabs at 1.0
How to make a raycast in physics 1.0 in SystemBase?
haha yeah thats what mine looks like
at least i have an ultrawide so i have 2 groups next to each other
previously I just get CollisionWorld from .GetExistingSystem<Unity.Physics.Systems.BuildPhysicsWorld>();
physicsworld.raycast
oh
var physicsWorld = SystemAPI.GetSingleton<PhysicsWorldSingleton>().PhysicsWorld;
You were too quick tertle I was about to type it ๐
thanks!
Copy paste trumps typing!
upgrading 0.51 -> 1.0exp is tedious
i found it pretty fine until i hit netcode
what about authoring?
converting IConvert to Baker was basically a copy paste and a new class
serialized data was maintained
i thankfully didn't have many generate authorings
those would be tedious
oh yeah I had bunch of [GenerateAuthoringComponent]
now I'm replacing ECBs
i just did a find / replace on the field/getexistingsystem/addhandleforproducer
and deleted
then did a find/replace on the create and switched it to systemapi
one of the perks of having very strict coding and naming style
nup
i trust dani and his code gen that this is going to be fast enough
(I'd prefer to keep it clean until I have a an issue with main thread costs growing)
A lot of breaking changes?
big change to how systems are put in different worlds
and they made a bunch of changes to system groups and stuff and i had a lot of work arounds for previous quirks which just aren't needed anymore
so i've been going through and cleaning a lot of app management up
Hehe, how'd you know it was me that did the codegen for that :3
Do I understand correctly that companion objects wont be a thing anymore with 1.0?
as far as i'm aware they still exist
In systembase systems we had Enabled property to enable/disable systems - is there something similar for ISystem systems?
SystemState.Enabled
for the most part, under the hood systembase actually just uses the same SystemState that is passed into ISystem
thx
just to show what i mean, this is SystemBases Enabled
public bool Enabled { get => CheckedState()->Enabled; set => CheckedState()->Enabled = value; }
{
var state = m_StatePtr;
if (state == null)
{
throw new InvalidOperationException("system state is not initialized or has already been destroyed");
}
return state;
}```
oh yeah forgot that if my authoring was change I need to remake everything from scratch
are class/managed components removed entirely?
nvm I think I need to use AddComponentObject in Baker
Here's a not exactly relevant question for you all but i'm curious: Laptop or Desktop?
Is this possible: Spawn an entity from entity then change mesh skin and or color? I think .5 or .51 allow it now right?
Good morning all. I think this is the day I launch my first version of Starfighter General that I can confidently say is stupid fun with building potential.
The reason I want color swapped guys is that I can make different colors of same enemy and call em different types of enemy: Red Dragon,Gold Dragon, Fuchsia Dragon,etc
@remote crater URPMaterialPropertyBaseColor
I have it so the enemy fights, so changing the color can also change the personality, attack and even trash talk as it hails your communication channels.
I am using HDRP so there is an equivalent? That's cool!
HDRPMaterialPropertyBaseColor? ๐
check samples for HDRP
yayah ty Kra
AFAIK both pipelines can have custom shader properties overrides
so you can override everything you want
Old pre .5 dots if you changed one, you changed all entities.
I think in .5 if you clone an entity. Entity cloneEntity = oldEntity;
I think in .5 it got decoupled.Well I can just try it out! TYTY
WOOO! God bless ya Krajca! Awesome way to start the day. Have a good one all younz.
Holy crud! Anyone scroll down?
You can animate your material to change properties on the fly
This means you can have not just a red,blue or green dragon, but one that cycles colors!
Johnny from TurboMakes Games did this back in the day and it was impressive: https://www.youtube.com/watch?v=XMRSNlTYHFY
๐ Download the full project files: https://www.tmg.dev/MaterialOverrides ๐
๐จโ๐ป Code/Scripts from this video: https://www.tmg.dev/MaterialOverrides-Code ๐จโ๐ป
๐ฌ Come chat with other DOTS/ECS devs: https://tmg.dev/Discord ๐ฌ
๐ง Resources Mentioned ๐ง
Using Random in Unity ECS: https://youtu.be/s-nr9EMmhfo
๐ป My Game Development Setup: https://tmg.dev...
Good Stuff Gustov
For some reason I can't add ICleanupComponentData to my entity
public struct OnCreate : ICleanupComponentData
{
}
public class OnCreateAuthoring : UnityEngine.MonoBehaviour
{
}
public class OnCreateBaker : Baker<OnCreateAuthoring>
{
public override void Bake(OnCreateAuthoring authoring)
{
AddComponent<OnCreate>();
}
}
Interesting, how are you adding it? Just the classic entityManager/ecb.AddComponent<SomeCleanUpData>() or?
Oh gotcha!.. Hmm, that totally should work o.o
What error are you getting?
It just don't get added
Does it not show in the editor or? I'm assuming you put OnCreateAuthoring on an entity in your subscene
yeah, it's on the object in the subscene
I would guess, such static queries of components don't create any impact on sync points?
Awesome, could you then check what happens if you press this?
As that should show you the baking result aka the baked entity
Oh that's very interesting O.O
UIComponent is managed component added by AddComponentObject() in it's own baking class
ok
I changed ICleanupComponentData to IComponentData and it's working
hmmm
I wonder if Unity aims towards keeping Game Objects inside SubScenes
considering currently World loads before Scene
i think they expect us to create entities in bakers, put data on them (bakingTypes) and then process in systems. it's convoluted though.
What's the difference between a baking type and a temporary baking type
is this valid?
NativeArray<float3> Vertices = new NativeArray<Vector3>(MapMetadataAndRaycaster.vertices, Allocator.TempJob).Reinterpret<float3>();
Can I just dispose Vertices later? Or do I need to keep a reference to the original Vector3 NativeArray to dispose of it instead?
Just got the heads-up that ICleanupComponents are specifically not serialized so that's why ๐คทโโ๏ธ
TemporaryBakingType removed after one bake. BakingType will stay on the entity (in baking world)
this is how I understood it. i never used BakingType, temp was enough for what i wanted to do
thanks! any info why that is?
Indeed I have!
ICleanupComponents are intended to clean up state created by a system.
As a result, we don't want it serialized, therefore we can ensure you definitely added the component at runtime!
Any idea what happens when you try to remove Entity with cleanup component? And only it
I personally don't have any stake in this topic. However, you are probably aware that this was requested quite a few times now either here or in the forums as a wanted feature, to reduce a structural change on every instantiate. Previously this was with ISystemStateComponentData, now with ICleanupComponent. The choice is odd in that sense because it clearly signals that the prefab has/needs a cleanup job and needs setup. Additionaly, I'm not sure why ICleanup is not an enableable component.
I wonder how much overhead it creates over doing em.RemoveComponents(e, lots of types);
my understanding is that cleanup components are just renamed system state components, and are for cleaning up after systems, not components
what's an example of a prefab that needs to be cleaned up, and when does that cleanup need to happen?
that's not really for prefab actually
I want this to make some logic, that clears entity of all data except of one on cleanupcomp when you try to remove it
It's more about removing a lot of components without knowing what components to remove
related to limitation of ComponentTypes capacity
to zoom out, what are you trying to accomplish overall? what makes you need to remove components without knowign what they are?
i'm also surprised because baking usually involves adding components rather than removing them
for example
I have input entity, that gets all sorts of components attached whenever certain input happens. And that needs to be cleaned at the end of frame.
So currently I simply store archetype and change archetype
But that makes impossible to attach more cleanup components, unless you do some prep work
ehm. but we said that structural changes are bad. why would you add components on input that you know you will immediately want to remove, rather than just writing to some existing components?
that's to support modding
I do have other option in mind for that. But I just want to know
whether killing Entity is viable strategy to just clear it of all components except for CleanUp ones
i'm afraid i don't see how modding is related; what would modders add?
new callbacks that add component tags to input entity
for example modder decided that there's a new bind for throwing a boot.
So whenever key is pressed - tag BootThrownTag is added to it
so like the modder defines a new component?
and they add an assembly that they build themselves, or something?
let's make a thread
Is entity picking in the scene view supposed to work with entities that were converted from prefabs? When I try to click on an entity spawned from a prefab, it opens the inspector but it is missing the little circle to switch the data mode in the top right. And when I click on the entity a second time it outputs an error:
GetAllOverlapping failed, could not ignore game object 'Cube (UnityEngine.GameObject) (0)' when picking
I made a little test scene to show what I'm talking about. The sphere is a normal game object in the subscene. In play mode, I can click on the sphere in the scene view and the inspector shows the little data mode circle in the top right. The cubes are created from a spawner game object in the subscene. The spawner baker simply fetches a cube prefab using GetEntity and puts it in an IComponentData. Then in the first frame at runtime, the spawner spawns 10 cubes from the entity prefab. Clicking on the cube appears to open the inspector for the prefab asset, not the entity that I clicked on. There is also no data mode circle in the top right to click. You can also see the error when I try to click on a cube a second time.
I'm wondering if this is happening for other people and if this is a bug or not. I assume the error is a bug, but what is the expected behavior when clicking on an entity that was instantiated from a prefab?
I hope before 1.0 releases the entities team can take another look at LinkedEntityGroup. I have a bunch of problems with it. a) this data shouldn't even be in chunks and have core support like enable comps b) it should not exist on flat entities that don't even have a child. c) when a) doesn't work out, at least it should have an InternalBufferCapacity of 0 to not be inlined in chunk. d) it should not have a default cap of 8
Welp, companion game objects and the new transform components and transform usage flags do not play well together
you can still use companion links? ๐ง
Trying to do this with other GO components (physics2d components). I need to disable the existing Entity -> Companion GO transform system and reverse it to GO -> Entity.
Setting transform usage flags to manual override with a companion GO throws error on baking. I think they're ignorable errors though.
Damn, doesnt work. Shame
wouldn't the white list get wiped when you run the game?
This is just for baking. I'm trying to expand the allowable list of component types that can be attached to the companion game object on conversion
It worked with the GOCS but not the baker variants. Because GOCMS doesnt exist when bakers run.
i'll go back to the initial question. you can still use companion links? ๐ from what i saw it's all sealed off and unusable, code is there but that's it
not even talking about the white lists
but that's a seperate problem
Yea, it's still there and hasnt changed from 0.50. From what I can see.
Just all the hooks for conversion are from the conversion systems and not baking. I have no clue how pre-whitelisted components like sprite renderer gets registered
huh, CompanionLink is private. Add HybridObject is gone. it vanished from the docs in 0.51. how do you set this up?
It's been merged with AddComponentObject
oh, i'm using AddComponentObject with a Transform. never seen a CompanionLink
CompanionComponentSupportedTypes are the types that spawn a companion GO
you mean 1.0 hasn't changed since 0.50 for companion links?
Does that work? My attempts at adding monobehaviors that are not on that list results in null components
yes, Transform work
the list has no SkinnedMeshRenderer. teh fk
but it has a MeshRenderer
maybe that will help you?
Oh my god, yes. Where's that found?
BakingCompanionComponentSystem.cs line 180
Also Systembase got a direct property of "WorldRewindableAllocator". No longer need to access the World.UpdateAllocator
Hahahaha, unity that wont stop me
haha
there's also internal static void BakeGameObjects(World conversionWorld, GameObject[] rootGameObjects, BakingSettings settings) { using (s_BakeGameObjects.Auto()) { var bakingSystem = conversionWorld.GetOrCreateSystemManaged<BakingSystem>(); bakingSystem.PrepareForBaking(settings, default); PreprocessBake(conversionWorld, settings, bakingSystem); bakingSystem.Bake(default, rootGameObjects); PostprocessBake(conversionWorld, settings, bakingSystem); } } baking at runtime? ๐
no idea why that is internal if that's the only thing that's needed to register new components for companion links
Because you're not meant to add new ones ๐
I don't understand why though
such an important feature
dani is already rewriting it to a private method ๐
yeah, why is that? unity can't possibly support all MBs that devs need. white listing is a nice method to keep it flexible
Practically intended by Unity. As we all know, internal is just public with more work.
Hahahahaha. Thanks Enzi, it works.
Just gotta yank those internal methods out into the light of public. Like all good unity functions.
What is a companion link exactly?
A very rudimentary and kinda broken hybrid dots
Does it keep the originating game object alive or something?
No, it spawns a copy, hence the (clone) (clone) (clone)
Got it, so you have a gameobject in a subscene with a companion baker. This converts to an entity with the managed component pointing to the monobehaviour. This monobehaviour exists on a cloned version of the gameobject before the bake. Is that right?
Yes. And only specific MBs can be added to the cloned version. Unless you yank this specific internal function using assembly ref hacks.
Camera conversion for example uses this method. So does sprite renderer conversion.
When does the game object get cloned? Is it during the bake or at runtime?
At bake / inside the editor.
Interesting. Is it hidden in the hierarchy then?
I haven t had a question in weeks since
yeah
Yep:
It definitely feels like a stop gap functionality. But it's integrated very deeply into Entities so I prefer to use it instead of rolling my own.
If the transform usage flag is set to manual override and there exists a companion GO, the companion transform sync system continuously throws errors about how there doesnt exist a local to world matrix which is annoying.
No no, I dont want the L2W to exist.
What I dont want is the CGOTS to exist as well. But the query seems to look for the existance of a companion link and not the subsequent required components
LocalToWorld, but with tons of properties which allow assigning values to specifics
Nah, the current one is nice and packed. They should just have a function within the L2WT that generates a 4x4 matrix on demand, instead of having a separate 16 float wide component.
why not just have 1 16 float wide component then?
after all
that's pretty much how big it will be with non uniform scale
that waste 8 floats when you can fit the entire transform into a component half the size.
hold up
position = 3
scale = 3
rotation = 4
10
right
ok
math is hard ๐
anyways
and pulling eulerian rotation values are really painful for a 4x4
I wouldn't consider size a problem anyway
they have capped chunk size to 128
so
rip small archetypes perfomance
Every byte counts in the end.
not sure about that
one thing - you read already allocated memory
the other thing - you allocate memory on stack
every time you need to get 4x4 matrix
with such cap perfomance benefit is questionable
I do wish there were some better hybrid options in 1.0. Letโs say we want an entity to have a monobehaviour attached as a managed component. It seems like our options are:
A) From a monobehaviour in a scene, at runtime, instantiate a new entity and add the mono as a managed component to the entity.
B) In a subscene, have entity with an authoring script referencing a game object prefab. Create a baker that stores a reference to a game object prefab on the entity. In a system, at runtime, instantiate the game object prefab and then add the mono as a managed component to the entity.
C) Some version of option B, but done at bake time and extra work to ensure the game objects are cleaned up and recreated during a re-bake.
D) Use assembly ref hacks to add monobehaviour types to the companion link whitelist. This is basically option C, but implemented by unity.
Am I missing another option? I've been trying to figure out the best way to proceed with hybrid stuff. Currently, I'm doing option A, but it feels like I basically recreated runtime conversion.
I'm now trying to migrate my project from 0.17 to 0.51 and in build guide https://docs.unity3d.com/Packages/com.unity.entities@0.51/manual/ecs_building_projects.html there is a requirement to install entities platform package wich is hidden and i can't find it's name. Anyone knows it's name or list of dots related packages?
probably com.unity.platforms, guessing same version as entities
Still hoping to get an answer to this. Is anyone else seeing the same thing?
i know there are fixes for picking in general coming
dunno about whether that exact bug is fixed or not
Got it, thanks. Mainly wondering if it's something else in my project. I guess I should create a new entity project to test. Should be reproducible in any of the ECS samples with spawners.
with the release of 1.0, any idea if we'll see a entities usable on a wider range of unity versions (2023+) or will it still likely be tied to LTS for a while?
I ask because Localization seems to be getting support for UI Elements in 2023, and while I have my own quickly hacked together solution I'd prefer not to invest time into something that is already obsolete
great question. i have no idea. i would think there would be some attempt to get the maintenance stream (which will be 1.0) to work on later versions at some point, but i have no idea of the cadence, and it would almost certainly after 1.0 was alllllll the way out. it probably depends on resource allocations and stuff
oh boy what have i broken here =S
System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) (at <7ab397abd13b41e3ad74fc63bc0bd4a1>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].TryGetValue (TKey key, TValue& value) (at <7ab397abd13b41e3ad74fc63bc0bd4a1>:0)
Unity.Properties.TypeUtility.GetTypeConstructor (System.Type type) (at <d4bd05a1303843099419718ac603eb57>:0)
Unity.Properties.TypeUtility.Instantiate[T] (System.Type derivedType) (at <d4bd05a1303843099419718ac603eb57>:0)
Unity.Serialization.DefaultTypeConstruction.ConstructFromSerializedType[TValue] (TValue& value, System.Type type, Unity.Serialization.ISerializedTypeProvider provider) (at Library/PackageCache/com.unity.serialization@2.0.0-exp.11/Runtime/Unity.Serialization/Utility/DefaultTypeConstruction.cs:79)
Unity.Serialization.DefaultTypeConstruction.Construct[TValue] (TValue& value, Unity.Serialization.ISerializedTypeProvider provider) (at Library/PackageCache/com.unity.serialization@2.0.0-exp.11/Runtime/Unity.Serialization/Utility/DefaultTypeConstruction.cs:47)
Unity.Serialization.Binary.BinaryPropertyReader.ReadValueWithoutAdapters[TValue] (TValue& value, System.Boolean isRoot) (at Library/PackageCache/com.unity.serialization@2.0.0-exp.11/Runtime/Unity.Serialization/Binary/Properties/BinaryPropertyReader.cs:274)```
...
```Unity.Scenes.SceneSectionStreamingSystem:ProcessActiveStreams(SystemState&) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Scenes/SceneSectionStreamingSystem.cs:455)```
oh man, i come back to my project and this happens. all subscenes are - i dunno - broken ๐ฆ
had to reimport subscene script.
is anyone else having weird caching problems?
i haven't seen this one
Do you have any custom baking systems going on? Could be an incorrect dependency breaking incremental baking.
I have a similar thing happen with my InputActions asset, sometimes it just doesn't serialize/deserialize properly and have to reimport it.
yes i have this baking system where i use baking comps to remove some other comps. could this really be related?
SceneSection, SceneTag - yeah i can see that breaking some stuff o_O
to my defense, i don't use them anywhere! ๐ subscenes were just my recent error. i had this on all kinds of scripts now
side note, not sure if you missed it before but there's kind of an official way to strip transform components now
i missed it
TransformUsageFlags
/// Use this flag to specify that you want to take full manual control over the transform conversion of an
/// entity. This flag is an override: When it is set, all other flags will be ignored. The transform system will
/// not add any transform related components to the entity. The entity will not have a parent, and it will not
/// have any children attached to it.
/// This is different from None, because None will result in removing any previously added transform components during incremental baking.
/// </summary>
ManualOverride = 1 << 5,```
this one will just ignore everything
oh, how do i set this for the entity that is baked? i'm only using the flag for CreateAdditionalEntity
GetEntity([optional]authoring, TransformUsageFlags.ManualOverride)
that easy, huh? ๐ cool thanks
can we also control that a entity that is baked will be deleted? i have an authoring go that spawns a bunch of entities but it should remove itself after the bake
I told KornFlaks about this and he's been using it a bit this moring so can ask him for more actual implementation experience if you want
Wow, you found it! TransformUsageFlags are not really explained anywhere tmk, tho they are defintly nice for this exact reason! :3
not sure about actually destroying entities (there's some vague stuff in there i haven't read through enough) but an alternative is just dump all your authoring data on a component
and use the temporarybakingtype attribute to remove it at the end
Don't quote me on this, but I think an entity with only bakingtypes and manualoverride will auto delete after baking 
thanks, i'll try that
ManualOverride indeed works. interestingly, TransformUsageFlags.None doesn't.
sadly not, ends up as empty entity
Gotcha! Thx for letting me know :3
ok time for me to just collect all my random conversion errors and post them all up at once
ArgumentException: An item with the same key has already been added. Key: 9af0ad5d699bef14294c79b00d200e65
LiveConversionConnection.cs:360)
a quick search of this channel and i can't see anyone posting this before
but if i just spam errors all day that's not really helpful
hey at least this one is easy to repo: start game, spam open/close a subscene in the hierarchy
yep, can repo. not on all subscenes though. killed my unity with errors ๐
you remember my method for ensuring settings/etc are in game without checking singletons?
it always had 1 annoying flaw, opening/closing subscenes at runtime would make these components disappear for a few frames
well i solved it finally and that's why I was spamming open/close on the subscene ^_^'
if i learned something from webdev in the past. always spam buttons that are not supposed to be spammed ๐
I read through the code on this the other day. TransformUsageFlags.None will always be overwritten by any other call to Baker<>.AddComponent() since it passes TransformUsageFlags.Default. Maybe if you add no other components, but even then I wouldn't be surprised if some internal thing is setting the flags back to default.
good to know, i don't add any comps though. it's the empty entity screenshot i posted above
Oh and TransformUsageFlags.None corresponds to a value of 0 so setting any other flag will overwrite it. Unlike TransformUsageFlags.ManualOverride that can work in conjunction with things setting TransformUsageFlags.Default since its a bitmask
yeah, you aren't adding any but something is added all of those scene-related components.
So I think the documentation on TransformUsageFlags.None isn't very accurate.
/// <summary>
/// Use this flag to specify that no transform components are required. Unless someone else is requesting other
/// flags, the entity will not have any transform related components and will not be part of a hierarchy.
/// This does not affect its membership in any <see cref="LinkedEntityGroup"/> components that might be created
/// based on the source GameObject hierarchy.
/// </summary>
Even though you specify that your baker doesn't need transform components, unity's own stuff is. The only way around this is ManualOverride.
hmm with 1.0 i've managed to completely remove my custom bootstrap and basically all start up custom code except for overriding AutomaticWorldBootstrap because I want to change world creation from BeforeSceneLoad to AfterSceneLoad so my systems can get the managed components (i.e. UIDocument) from the scene in OnCreate
no one has like a brilliant idea how i could work around this? i'd love to just be able to rely on default setup
Can you get the managed components in OnStartRunning() instead?
I'm actually not sure when OnStartRunning() happens compared to scene load
yeah that's my current thought
(it's fine i've already tested it)
the only problem is
the system doesn't actually update
so that bothers me a tiny bit ๐
protected override void OnUpdate()
{
// NO - OP
}```
i could make it do Enabled = false in here and it'd be fine
but it's the principle of the matter
it's going to eat at me
Make your systems implement an IAfterSceneLoad interface? Find them all with reflection and call their callbacks after the scene is loaded
i'm very specifically trying to not use any hacks
ha
so this library is just droppable in anyones project and works
just going to suck it up and use OnStartRunning
What about accessing that managed data through a property? Inside the property getter, it looks for the managed component or returns null. If found, it caches it in a field that the property returns on future calls. Then in OnUpdate(), check for null
it's only ever used once
{
if (this.root != null)
{
return;
}
var document = Object.FindObjectOfType<UIDocument>();
if (document == null)
{
Debug.LogError($"{nameof(UIDocument)} not found.");
this.root = new VisualElement();
}
else
{
this.root = GetRoot(document);
}
this.root.Add(this.view);
}```
anyway you convinced me to suck it up and use OnStartRunning
which has now removed all custom bootstraps and initialization ๐ฅณ
Haha yay ๐
so i take it, based on what you've said, OnStartRunning happens after any sceneload?
i started using OnStartRunning recently and realised it removes some of the hackery in trying to step around when systems vs monos are created etc
oh yeah
do you control OnStartRunning with a RequireForUpdate?
you might want to check for the presence of the view in the list when for some reason OnStartRunning triggers again
i have Enable = false in OnUpdate
and it early outs if root as been setup
{
return;
}```
in case someone accidently starts running it again from system window
so we have these super handy
SystemAPI.GetComponentLookup<T>()
when can we get super handy
SystemAPI.GetComponentHandle<T>()
!
Hmm, I wonder who you would have to convince for that 
am I missing something? why are they super handy? they just replace state.Get...
ah yes, missed your early out ๐ how do you control waiting for the managed objects? doesn't onCreate and OnStartRunning usually trigger in the same frame?
They also do .Update and Cache automatically in OnCreate
gah beat me for once
i just wrote up a fun example
public partial struct TestSystem : ISystem
{
private ComponentLookup<Translation> translations;
public void OnCreate(ref SystemState state)
{
this.translations = state.GetComponentLookup<Translation>(true);
}
public void OnDestroy(ref SystemState state) { }
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
this.translation.Update(ref state);
new Job { Translations = this.translations }.Schedule();
}
}
[BurstCompile]
public partial struct Test2System : ISystem
{
public void OnCreate(ref SystemState state) { }
public void OnDestroy(ref SystemState state) { }
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
new Job { Translations = SystemAPI.GetComponentLookup<Translation>(true) }.Schedule();
}
}```
what would you rather?!
THAT is fantastic to know!
that's a really nice way to get around the boilerplate
That's the whole Idea behind SystemAPI, meant as an easy way to get rid of boilerplate, with an easy escape hatch when you want the little extra control :3
yeah, i only realized this after i updated everything and had to go update everything again
gonna rewrite some systems tomorrow with this ๐
not if i'm just using automatic bootstrap and creating the world before scene load
the playerloop doesn't start ticking till after initial scene has loaded
if i was doing this after scene load i'm not actually sure if they tick the same or next frame
probably depends when i create the world in the frame
Just curious about this - GetComponentLookup is CDFE right.. Would you normally cache CDFE in create? Pre 1.0 i mean of course.. I've never cached CDFE before..
pre 1.0 no you can't
post 1.0 they added the same Update method that handles got for performance and it should not be got every frame anymore
ok yeah so it's optimized out and cached
so i'm right in saying then, we cannot cache GetComponentDataFromEntity in OnCreate in 0.51?
Ok haha, just double checking that one!
GCLookup is indeed a nice touch, look forward to using that
congratulations david on volunteering to be the channels test dummy, please report back asap
No, pretty sure b10 won't contain the fix.
Darn...
Well, I guess I should be specific, there is a particular il2cpp bug that I seem to remember you hit in Quest2 and I don't think that's in b10, there may be other il2cpp fixes there.
"Who's deleting my companion objects?! ๐ก "
journaling - "you are"
where was this window 2 years ago
hmm just updated my AlwaysUpdatePhysicsWorld system, still haven't heard an argument why this shouldn't be done but it still concerns me
tertle is in a moooood today and I'm here for it ๐
it's my fortnightly day off
which means super entities focus
but just to debate this again,
AlwaysUpdatePhysicsWorld is a system that will update the BuildPhysicsWorld even when your fps > fixed tick and fixedstepsimulation group hasn't run
it won't update the simulation (step), just the physics world
this ensures if new entities are created or something is destroyed if you do a query on the physics world it will exist
Update
Fixed
Update - Create Entity1
Update - OverlapSphere, entity1 not returned
Fixed
Update - OverlapSphere, entity1 returned```
to avoid this issue
ah so gives your frame perfect collision queries, hmm most people would want this by default I would imagine
I can't think of why you wouldn't want this other than to save a small bit of processing power
"Performance" - it only slightly slows down performance if you are rendering > physics which is typically >60fps which means you're doing /ok/
If you were to move your systems inside of fixed update instead it would hurt performance if you were <60fps causing a fixed update death spiral
So I'd argue it's better for performance than the alternative because targeting low end is more important
The reason why this came about for me is my fracturing / cluster system which needs to know about anything it spawns next to, that frame
otherwise it's going to fracture due to no connection
I finally got around to looking through your hybrid solution tertle, looks really cool man.
I like the way you handle cleanup, much more controlled than the dispose solution I had going.
it's worked well for me
Did last patch fix UI issues with hierarchy?
maybe
Hmmm, is there a reason Memory.Unmanaged.Allocate is internal
UnsafeUtility.Malloc does not seem to support rewind allocators and all the containers seem to use this so it seems like the right thing to do for my own container
bruh, bug still exists
what was your error again? it was pretty specific right
i don't think i've heard anyone else have this specific one
in playmode subscenes look like this
outside of playmode they look good
have you checked with entity journaling what removes it?
^ had a similar issue this morning
alternatively, how are you opening your subscenes
alternatively, how are you creating your worlds
sounds like you're doing something like
var sceneEntity = SceneSystem.LoadSceneAsync(world.Unmanaged, _SceneGUID, loadParams);
nah, nothing is recorded
but not doing
EntityManager.AddComponentObject(sceneEntity, this);
error happens as soon as I open Hierarchy window
where this = SubScene
yeah
i.e. are you opening subscenes without adding the SubScene component
if you're delaying your world creation until after OnEnable() then you aren't letting SubScene set up the entities and you probably have to do it yourself
#if UNITY_EDITOR
flags |= EditorApplication.isPlaying ? SceneLoadFlags.BlockOnImport : 0;
#else
flags |= SceneLoadFlags.BlockOnImport;
#endif
foreach (var world in World.All)
{
var sceneSystem = world.GetExistingSystem<SceneSystem>();
var stateptr = world.Unmanaged.ResolveSystemState(sceneSystem);
if (stateptr != null)
{
var loadParams = new SceneSystem.LoadParameters
{
Flags = flags
};
var sceneEntity = SceneSystem.LoadSceneAsync(world.Unmanaged, _SceneGUID, loadParams);
stateptr->EntityManager.AddComponentObject(sceneEntity, this);
_AddedSceneGUID = _SceneGUID;
}
}```
is what it does in OnEnable
but if your world doesn't exist yet
world exists though
hold up, I need to catch up
๐
public class CustomWorldInit : ICustomBootstrap
{
private World _world;
private BootExtensionManager _bootExtensionManager;
public bool Initialize(string defaultWorldName)
{
SceneManager.sceneLoaded += SceneManagerOnSceneLoaded;
Debug.Log("Creating world");
_world = new World(defaultWorldName);
World.DefaultGameObjectInjectionWorld = _world;
_bootExtensionManager = new BootExtensionManager(_world);
return true;
}
private async void SceneManagerOnSceneLoaded(Scene arg0, LoadSceneMode arg1)
{
Debug.Log("Creating systems");
SceneManager.sceneLoaded -= SceneManagerOnSceneLoaded;
var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);
var bootSystems = systems.Where(x => typeof(IBootSystem).IsAssignableFrom(x)).ToList();
var otherSystems = systems.Except(bootSystems).ToList();
_bootExtensionManager.CreateBootExtensions();
DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(_world, bootSystems);
foreach (var system in _world.Systems)
{
if (system is IBootSystem bootSystem)
{
await bootSystem.Ready();
}
}
DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(_world, otherSystems);
_bootExtensionManager.PostBootExtensionCall();
#if !UNITY_DOTSRUNTIME
ScriptBehaviourUpdateOrder.AppendWorldToCurrentPlayerLoop(_world);
#endif
}
}
here's what my CustomBootstrap looks like
So I pretty much copy default init
but with delayed load
of systems
should I create certain specific systems?
during Initialize call?
ding ding
because subscenes call this in OnEnable
your world won't exist yet to setup the scene entities
i delay world load as well, just do what I do,
Grab all scene entities and call
var entity = SceneSystem.LoadSceneAsync
this.EntityManager.AddComponentObject(entity, subScene);
hopefully that fixes the issue
world does exist though
because I use interface to create it
and I do create
same as default init
but systems don't
int has nothing to do with it
which might be the case
yeah, and world is created before the scene is
and the scene systems are included?
no, I just used ICustomBootstrap
public bool Initialize(string defaultWorldName)
{
SceneManager.sceneLoaded += SceneManagerOnSceneLoaded;
Debug.Log("Creating world");
_world = new World(defaultWorldName);
World.DefaultGameObjectInjectionWorld = _world;
_bootExtensionManager = new BootExtensionManager(_world);
return true;
}
here's what exist by the time Awake, OnEnable and etc are called
yeah, I see
so
what system do I need
to create
so subscenes are registered correctly?
all the subscene ones
or dont bother
just when you create your world
just do FindObjectsOfType<SubScene>
and do the above
or alternatively, keep all your subscenes disabled and just enable them all after world is created
๐ค
I'd rather create subscene systems
I just need to know which
I assume
SceneSystem is one
There's some scene section ones
I wonder if they have any sort of attribute on them
so I can easily query them through reflection
They're all isystem now I think
that's fine
DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(_world, bootSystems);
works well with Type[]
[UpdateInGroup(typeof(SceneSystemGroup))]
huh
work?
just finished testing
yeah
works
thanks!
๐ค
no errors, but
smth is wrong
await UniTask.WaitUntil(() => SceneSystem.IsSceneLoaded(World.Unmanaged, sceneEntity));
yep
this does not work
it's forever awaited
without a result
weird
sounds like you aren't ticking your world
I do
hold up
SceneSystem group is emtpy
I guess that's no good
var sceneSystems = otherSystems.Where(x =>
x.GetCustomAttributes<UpdateInGroupAttribute>()
.Any(x => x.GroupType == typeof(SceneSystemGroup)))
.ToArray();
here's how I get SCeneSystemGroup
doesn't seem like that would include the scene system group itself
oh
right
yay, that was it
DrawMeshInstanced does not support the shader 'Universal Render Pipeline/Unlit' because it does not read any instanced properties. Try switching to DrawMeshInstancedProcedural if the shader is doing procedural instancing.
hmmm
hmmm
Exception in Burst now don't say what system it is
it never really did?
it did, just without blue links
it said class name in exception
Finally
Managed to get partial functionality of project ๐
How to properly convert GameObjects that should be rendered to Entity. Earlier it was easy with ConvertToEntity and all convertation was doing automatically. Now i should do it through Bake and add all components myself needed for rendering?
rendering is done by Unity
Anyone else getting this error from clicking on entity in hierarchy?
ArgumentNullException: Value cannot be null.
Parameter name: _unity_self
UnityEditor.UIElements.InspectorElement.GetOrCreateEditor (UnityEditor.SerializedObject serializedObject) (at <68dc13de18804097a5f386c11cbbb64f>:0)
UnityEditor.UIElements.InspectorElement.Reset (UnityEditor.SerializedObject bindObject) (at <68dc13de18804097a5f386c11cbbb64f>:0)
UnityEditor.UIElements.InspectorElement.ExecuteDefaultActionAtTarget (UnityEngine.UIElements.EventBase evt) (at <68dc13de18804097a5f386c11cbbb64f>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <c9c6a76099e240a893d3af0dc16ae863>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtCurrentTargetAndPhase (UnityEngine.UIElements.EventBase evt) (at <c9c6a76099e240a893d3af0dc16ae863>:0)
hmmm
what would be a better approach
Have an entity with special tag, which gets all sorts of components added to it for events
and then in systems that must update depending on those components, will only require single query of selected components
OR
for every single possible component type create singleton
and then just enable/disable it?
While in systems declare requirements for multiple queries
Any thoughts on this?
Just drop it in a subscene no?
I only have a few gameobjects and I'm not sure that I should use subscene for this
it's the only way to convert to entity
I think 1.0 has dropped ConvertToEntity completely right
Subscene and Bakers only
You must become a Master Baker
Ive been master baking all day long. Ive been having to revise and edit my long and very wide strip of authoring code up and down.
maybe with a stroke of luck, your master baking will produce the results you require.
Woah, new rider UI is slick
EAP2 rider, new UI.
Rainbow brackets unfortunately doesnt work with it. Otherwise, looks cool
for a second I thought you were joking and this is VS
It's the new rider. Well, new soon.
Does anyone know how to use the SystemAPI Query with an existing entity query? Do I need to construct a new one every time?
Ooh I guess its time to update
The main bonus is shifting code tabs is like VSCode. A lot smoother and it shows where the tab will line up below the icon.
It also just looks way less busy
unless that part isn't new and I've somehow missed a focus mode
There is a focus mode but that just fullscreen-ed the editor. This removes the top bar which is nice.
Codegen creates it manually in oncreate
stores it in a field
and then uses it
Is there a .WithNone or .WithAny option?
no idea, barely use it
Unity uses it everywhere, at least in their training samples, so it's pretty important.
I think this works.
well, it's just an easy way to iterate over chunks on single thread
here and now
under the hood it's same as
query.GetChunkArray
and then foreach chunk foreach entity...
oh wait
you mean query builder
Yea... that's what im doing anyways.
๐
The query builder is a different section of code
btw, how do you enable that thingy on the right that let's you quickly scroll over?
I would like to make this into a SystemAPI.Query but the .WithNone<Tag>() doesnt seem to work.
The code vision? That's a plugin: CodeGlance Pro (which is free)
It's the only one that I've seen that is actually colored from the code. Which is sweet. I dont think VSCode does that.
I cant live without it. Thankfully, people smarter than me also cant and made that plugin.
IIRC, cleanup component datas with properties (not tags) do not show up in the entity inspector view. Are they baked or not?
0.51 didnt bake system state components, did 1.0 change that?
no
cleanup components are runtime only
Do you use Toolbox to update rider? For some reason it isn't showing me EAP2. Only EAP1
I just went to the download page itself:https://www.jetbrains.com/rider/nextversion/
mmk, I'll try that
Also, i like your idea for the hybrid component and i'm trying to see if I can do it myself
It depends on if the baker runs before or after inspector update
Are you thinking of relying on the existing companion stuff or implementing a new version of that?
New version, the existing companion GOs have several hardcoded transform sync systems that interfere / override physics2D. Which is bad.
Got it. Yeah, I think the companion stuff shouldn't have any special handling for transforms. Too many different things to try and support there. Better to leave it to users to implement their own transform syncing systems
Do you know if its possible to stop baking from deleting the authoring game object?
Nah, I'm instead gonna make a copy of every Unity component then recreate the managed companion GO at start of runtime.
Yeah, that seems like a good approach. I wish it was possible to do it at bake time but I think it will require some internal changes
Yea, if I could use SS/CCD at baking, recreating companion GOs would be trivial.
SS/CCD?
SystemState or as they're called now Cleanup Component Data
You can if you are creating the companion GO at runtime anyways
The main issue is deleting the GOs when the entity they're attached to is deleted as well, such as when incremental baking occurs. And the only way to do that is through CCDs
Oh you mean doing this during baking?
Ideally yes. But without access to CCDs, i'm doing it at runtime.
Yeah makes sense
I want to be able to add this managed component monobehavior script to a GO thats being converted and instantly detect all unity components that are not converted (which is, for me, all of them) and populate a list without needing to manually drag and add to a list.
You can iterate all unity components from a monobehaviour:
foreach (Component component in GetComponents(typeof(Component))) {
// Do stuff
}
I think default GetComponents returns all, no need for the typeof filter.
Good to know, thanks. Sorry I thought you were asking how to do this.
Do u mean combine entity and game object at Baker just like how convert and inject game object works but now bake into subscene?
No worries. I'm just slowly making my way through it.
I agree that it should auto-populate and should be readonly. I'm not super familiar with the builtin monobehaviour events but is there one that gets called every time a unity component is added to the game object?
Yeah pretty much. I'm not sure if subscenes are able to store the game objects in the post-bake format though. Seems like they are entity only. But I also know that companion link still works so they appear to be doing it somehow.
Or is the existing companion link also at runtime?
[CustomEditor(typeof(BridgeAuthoring))]
public class BridgeInspector : Editor
{
private SerializedProperty _components;
private void OnEnable()
{
_components = serializedObject.FindProperty(nameof(BridgeAuthoring.managedComponents));
}
public override void OnInspectorGUI()
{
DrawDefaultInspector();
serializedObject.Update();
}
}```
It's gonna be something like this. Where OnInspectorGUI it repopulates a list of ManagedComponents.
Cool thanks. I was hoping there was an event that would trigger less often then every repaint, but this should work fine.
Yea, but the inspector's conditional repaint is dependent on the script that it's serializing, not the GO as a whole.
One of the reasons for keeping the authoring game object around instead of cloning is that I would like to keep the game object hierarchy intact. For example, if I want a hybrid animator, I may the child bone transforms to be updated by the animator.
I know this makes things tricky, but I was imagining having every bone game object have this hybrid monobehaviour attached to it with the transform box checked. Then at runtime, the hierarchy is exactly like it was in authoring
Oh, yea. No clue about that. My hierarchy is completely flattened.
I think this is one of the reasons why unity is hesitant to support hybrid stuff. Lots of weirdness when you start thinking about hierarchies and transform stuff
I guess I could do something like your approach, but clone the entire game object hierarchy. Then iterate through it and delete anything that isn't needed
Definitely. Hrm, redraws happen a lot. I need to find a way to check if the GO as a whole changed.
hmm what's this? https://docs.unity3d.com/ScriptReference/ObjectChangeEvents.html
Hrm maybe
https://gist.github.com/karljj1/f8adaf0024288052f991191777110f3d
There's a global stream and tacking on every single GO to watch it doesnt seem performant.
Hmm yeah. Seems less than ideal but not finding another way
Hrm, maybe instead of a custom inspector, there's this global class that listens to this stream and checks if every GO that has changed contains the BridgeAuthoring MB component. Then calls a refresh method on that component to repopulate the Managed list.
Yeah that could work
I gotta run, but good luck! Curious to hear if you get it working
Yep, grinding through this slowly
Need a quick reminder: There was something about 1.0 ECS and physics, but I can't recall what. Was is just the transform aspect thing not being in physics yet? Is that what I'm thinking of? Or is there more?
public override void OnInspectorGUI()
{
var script = (BridgeAuthoring)target;
if (GUILayout.Button("Refresh"))
script.Repopulate();
// public void Repopulate()
// {
// Component[] components = GetComponents(typeof(Component));
//
// // * Recreate managed component list.
// managedComponents ??= new();
// managedComponents.Clear();
//
// managedComponents.AddRange(components.Where(component =>
// {
// // * Default is managed component.
// var pass = true;
//
// // * Filter out skipped components.
// // ! HARDCODED: Skips transform components.
// pass &= !Skip.Contains(component.GetType());
//
// // * Filter out authoring scripts.
// // ! HARDCODED: Authoring scripts must have a name containing "Authoring".
// pass &= !component.GetType().Name.Contains("Authoring");
//
// return pass;
// }));
// }
DrawPropertiesExcluding(serializedObject, "m_Script");
}``` This seems to work.
The new transform components (TransformV2) are not yet implemented in physics and netcode.
@oblique cosmos new transform system isnt used by netcode or physics(afaik presence of either will disable it), havent used aspects yet personally
But that's pretty much it, otherwise it's functional, yea?
Yea. Functional.
Cool, thanks!
Managed component storing a copy of the list found in the inspector.
Would be nice if I could add a checkbox next to each element in the inspector list but that requires advanced custom inspector editing. And the same can be done by just removing it from the list using the "-" button.
Nice looks great!
If you're creating the EntityQuery in OnCreate, you might as well just use EntityQueryBuilder directly.
_destroyed = new EntityQueryBuilder(Allocator.Temp).WithAll<BridgeObject>().WithNone<BridgeTag>().Build();
SystemAPI is useful if you want to just do that in OnUpdate; it will sourcegen the query creation in OnCreate for you. If you don't mind doing it yourself, you'll save a little bit of build time.
With Odin Inspector, its pretty easy to do this. Instead of storing a list of Component, you store a list of structs that contain a bool and a Component. Then draw them on the saw row with HorizontalGroup attributes:
public class ManagedComponents : MonoBehaviour
{
public List<ManagedComponent> Components;
[Serializable]
public struct ManagedComponent
{
[HorizontalGroup(20, LabelWidth = 0)]
[HideLabel]
public bool AddAsManaged;
[HorizontalGroup(LabelWidth = 0)]
[HideLabel]
[ReadOnly]
public Component Component;
}
}
hrmmmmmmmm, doesnt work if the subscene is closed.
Ah, dont have odin.
hrmmmmm
Well, you just cant close / stream subscenes with this. Unless i can serialize the entire component.
Not sure how you have it set up, but your authoring game object will be deleted at the end of baking. If you then try to reference those components at runtime, they won't exist any more
They are deleted but because I'm keeping the reference to each component alive and active in this managed component data, I can still access the data of the original game object. So long as the original has not been completely deleted.
I can see and access the managed components so long as the source subscene is open and the original GO is still alive.
Of course, the center game view is displaying nothing because the actual GO within the greater scene has been deleted.
hrm, I think the only way for this to work with the subscene closed is the assembly ref hack
And then swap CompanionLink component with a custom managed component at start. Disabling the built in transform syncs but otherwise operating through the CGO built in baking system.
Yeah, with the scene view open, I think it keeps the authoring game objects around so that you can toggle data modes and see the authoring view in the inspector. But with the subscene closed, I think the only thing that remains is the entity data. But again, I'm not sure how CompanionLink currently works since they are somehow working around this problem.
I'm guessing, since all systems now run always by default
GetEntityQuery doesn't cache query inside list of required queries for update?
They do all of this except with a manual implementation of a CCD for synchronizing CGO and Source Entity lifetimes.
If the baker could allow for CCDs, this whole thing would be trivial to implement. But it doesnt, so CGOs go deep into Entities to make it possible.
Oh, cool.
I don't really understand how ICleanupComponentData in a baker makes this trivial. If that is all you need, can't you add a normal ICD and then have a system that replaces it with an ICCD in the first frame?
It's an issue with the iterative baking system. It will continually recreate the GO every time the baker runs and using the instance ID for unique name to prevent duplicate creation doesnt work. Closed and open baked game objects have different instance IDs.
hmm okay, sounds more complicated than I thought
this all sounds like pain, i think i'll wait for 2.0
The provided CGO works fine for hybrid, if I can just disable the built in transform sync. I need to reverse the direction of synchronization.
hrm, maybe disabling the system might work
i'm kinda joking tbh, just hoping conversion isn't too much hassle to port over, everything else looks like pure improvements
It sounds like a lot of people have been just fine with baking a reference to a prefab game object. Then at runtime, instantiating it and linking it to your entity. This isn't too difficult to set up and tertle has shared their implementation of this already. But the main limitation with this approach is that your managed components are authored in a prefab asset, so it can't reference other things in your subscene.
The issue with prefab is that you need additional baking components to modify per instance the GO properties that are just the properties of the source GO.
Yeah good point. This prefab setup really only works when it only references other assets and all of the GO properties can be left as whatever they are set to in the prefab.
I don't really get why you need extra components for this?
I think they mean, on the authoring game object in the subscene, you need both a reference to the prefab asset and additional components/fields with any overrides for the instantiated prefab
You just have more than 1 prefab
And you can use prefab instances to share data
It's like no different to having more than 1 gameobject in the scene
right, that's what I was trying to say. You have to either leave the prefab/variant as-is after instantation, or have support for some kind of complicated override thing on the authoring game object.
I'm still a bit confused, are you talking about runtime editing?
Like after you instantiate it
With the override idea, yes. I'm not advocating for that option btw, just saying that it is an option if you want to change a few fields on an instantiated prefab.
Ugh. I think I'm just gonna drop this whole conversion thing and go back to runtime conversion. It doesn't cost that much anyways and I won't be using subscene streaming for the foreseeable future
For me, the deal breaker with the prefab workflow is not being able to reference other things in the subscene, or other hybrid objects
So runtime conversion of a game object in the regular scene?
Basically. Just a MB that spawns an entity in OnCreate and populates it manually from there.
Or! Make it pure ๐
Skips the whole Companion nonsense if the original GO was never destroyed to begin with
I tried to roll my own physics engine, didn't work
what's the problem with baking?
Hybrid
He's making a gameobject game and tacking on entities
where do you have trouble?
I want an entity game using physics2d
I want an entity game that uses sprites. I want an entity game that uses tilemaps.
Hybrid basically. And baking with hybrid doesn't work.
i have some hybrid baking. spawns some gos or entities in both directions
Yeah, its just a shame that we can't use Bakers for this, but its good approach. I already do this for scene objects that don't have any normal ICD on them. Just an entity with some managed components referencing monos
Relies on prefabs though, right?
scene gos also work
scene game object linked to a baked entity somehow? Or runtime entity creation?
the scene go spawns a (baked) entity prefab. no runtime conversion of course
how does this work? Like how do you reference the baked entity prefab from the scene without cross-scene references?
You could just use weak asset references like dots shooter sample
either that which would make it full generic, a dedicated spawner or ids
Haven't heard of that. So is the weak ref on the entity in the subscene pointing to the scene game object? Or the other way around?
(I'd make the baked entities reference the game objects but either way technically works)
I guess I don't understand how game object can reference a baked entity. In the editor, all we have is the authoring game object. But I could see how the reverse could work. Either way, definitely didn't know about weak asset references.
I'm currently doing something with custom tags/ids, but not really happy with it.
ids are not too bad. weakassetreference also relies on it https://github.com/Unity-Technologies/DOTSSample/blob/master/Assets/Unity.Sample.Core/Scripts/WeakAssetReference/WeakAssetReference.cs
it uses the asset guid
you can implement it however you want
but yeah unity used guid because they only used it on cross scene prefabs
sure, using the guid from the asset just makes it very straight forward
Just starting looking at the code. But with the name "asset", makes me think it wouldn't work on game objects in the scene, only prefab assets. But you're saying it works
so they'd register all their prefabs in 1 scene, convert
and other scenes could reference these
if you don't have too much and don't need a generic solution. strongly typed works also fine
worth it to upgrade to b10? i haven't seen much changes in the notes
what do you mean exactly? Like some component on the entity that uniquely identifies it?
So that gameobject can just query for that component type?
every time i turn a SystemBase into an ISystem I get a swell of joy
also rewrote my drawer yesterday
var drawer = SystemAPI.GetSingleton<DrawSystem.Singleton>().CreateDrawer();
so much cleaner
than storing it in OnCreate, creating an instance each frame + addhandleforproducer
i'm wondering if I can write a generic or inheritable version of this pattern
Systems still cache their queries. EntityQueryBuilder.Build(SystemBase) and EntityQueryBuilder.Build(SystemState) just call GetEntityQuery under the hood for now. But that may be going away as it causes subtle bugs if you don't realize it's returning a cached query (and most of the query data is cached elsewhere).
Can we store native collections in components on baked entities in a subscene?
I'm getting an error about the pointer in a NativeHashMap:
[Worker0] Exception thrown during SubScene import: System.ArgumentException: Blittable component type 'ECSTween.TweenConfigs' contains a (potentially nested) pointer field. Serializing bare pointers will likely lead to runtime errors. Remove this field and consider serializing the data it points to another way such as by using a BlobAssetReference or a [Serializable] ISharedComponent. If for whatever reason the pointer field should in fact be serialized, add the [ChunkSerializable] attribute to your type to bypass this error.
are you allocating it?
because if so, no
it's not going to be allocated when you deserialize the subscene
yeah makes sense
as the error message says, you can store pointers with [ChunkSerializable] in subscenes
so no native collections in subscene entities, only runtime entities?
but these will point to something random
it won't be whatever you had beforehand
if you use a null pointer you can check and allocate it at runtime and avoid the structural change
the allocation has to be at runtime
a structural change might be worth the constant null pointer check.
yeah okay. I need it to be populated with the authoring data. I can just use a buffer at bake and convert to a hash map at runtime or something
yeah in general, but you could just have a single instantiate system that will always run per new entity type
(that said I disagree with putting native containers on regular entities anyway, [good on singletons])
remember you still need to deallocate it
yeah its a singleton
think he just wants to bake the data
i used to do something like this for my prefab registry
just bake it all in a buffer
at runtime if buffer exists, remove it make it into a hashmap
yeah that was my new plan ๐
i don't do this anymore as I now use linear keys
and just store it on buffer and the index is the key
but it's totally fine to do
Yeah, your K system, right?
nah
oh nvm then haha
Interesting. Sounds similar to what I want for my tween registry
i took a little inspiration from eizenhorn system
So if a system wants a prefab, how does it get the index in the buffer?
but made it branch proof
var prefab = prefabs[key];```
get the singleton, get the prefab
key is just an int
i think 2billion will be fine
haha sure, but how does the system get the key?
entities have the reference to the key
if a system needed some special key then I would use K for that
and define it by name
hmm, not sure how the entity has the key. I assume at authoring you specify a prefab in a normal way. And somehow it gets baked with the correct index
also each prefab can be stored in a category (defined by K)
yeah pretty much
you just use an int field instead of a gameobject
with an attribute
actually no
i wrapped this with on attribute
you just use
public ObjectId Prefab;
public struct ObjectId : IComponentData, IEquatable<ObjectId>, IComparable<ObjectId>
{
public int ID;```
i wrapped this just so i could change ID type in future if i ever needed (shouldnt happen)
and it has a custom drawer
so it appears as an object field
so you just drag/drop the definition into it
but under the hood it's stored as in int
oh that's cool. And where are you storing the list in the editor?
just on a gameobject
that is converted into the buffer of all of them
you haven't asked the important question though!
how do i handle unique IDs
I think I saw your message about that a while back actually
well that's boring ๐
At bake, iterate the asset database or something?
you dont have to do anything
i lied a little above, you dont use ObjectId
you just reference ObjectDefinition
ok yeah memory was a bit fuzzy
little definition, this has the unique ID (hidden)
this is what you reference
in baking you just call definition.ID
and that's all you store on your component
anyway this is my mornings update to 1.0 job ๐
neat, sounds like exactly what I want for my tween scriptable objects. This system of yours isn't generic by any change, is it? ๐
there's no need to be generic
it's designed to work on every asset in your project
they all just share the same key interface
when crafting there's no reason i can't make a human
or some random effect
whatever entity is chosen will be created ๐
Does that mean in authoring, you can set an incorrect type?
as long as it can be a gameobject and therefore convertable to an entity
no such thing ๐
but this is why i provide categories
I don't want a game object or entity. I want a scriptable object defining some tween parameters that is convertable to a blittable struct
Maybe I'm misunderstanding, but it sounds like your system works with prefabs (within categories). But not any type of scriptable object.
my system works with entities
all my data is stored on entities
it maps keys -> entity prefabs at runtime
Got it. Yeah, I feel like I want the exact same setup, but instead of mapping to an entity, I want to map to some piece of data. So all my tween scriptable objects can be converted to a blittable struct and looked up by key in systems.
Regardless, this was very helpful. I was stuck on the authoring -> baking part when using indices and you helped me figure that out. Thanks!
oh 1 more note on my baking
i don't hard store a list of anything
during baking i just do a
var guids = AssetDatabase.FindAssets($"t:{nameof(ObjectDefinition)}");
so designers don't need to manually add them to a list
instead i just grab them all
yeah I remember reading that a while back. So how does ObjectDefinition.ID work in baking if it is dependent on this running first?
the IDs are not defined during baking
they are defined during asset importing
once you create an asset definition it is given a unique id
and this never changes
EXCEPT! if 2 people make new definitions in different branches
then when 1 person imports other persons stuff during that asset import it will detect a collision
and fix it
solo dev ftw!
as you are not referencing this ID you are referencing the definition everything just works
So if an object definition is deleted, your list is sparse?
the only way this ever breaks is if 1 dev branches makes IDs, another dev branches makes IDs
dev 1 merges into master, then master is shipped publicly
and then dev 2 merges and breaks dev 1 ids
asset importer finds lowest ID when assigning
so there is a chance of holes but new assets will fill them
ah nice
// The importer should keep this close to the number of prefabs
definitions.Sort((d1, d2) => d1.ID.CompareTo(d2.ID));
var length = definitions[^1].ID + 1;
registry.ResizeInitialized(length);```
from my baker
but yeah this is why it was important for me to not manually assign ID's or do them randomly
because i don't want a 2GB dynamic buffer
anyway all this is not required you can just use a hashmap
and not care about your IDs like that
i just happened to want to make a system that handled merge conflicts from multiple devs
and it turned out the solution allowed me to keep ids close and linear so i switched it from a hashmap as it was no longer needed
haha yeah I'm just using a hashmap for now
Right now I'm using strings (FixedString64Bytes) for keys. Systems have the strings hardcoded. It don't really like those being hardcoded, but haven't figured out the best way to set this up in authoring.
I have like 20 tween configs needed by 10-20 different systems. No one-to-one mapping. Seems overkill to define an authoring game object for each system
So if I use DisableRendering tag then what entity should it be on, because I can't seem to get it to work on an entity that has multiple meshs
aren't multiple meshes handled by multiple entities
so it would need to be on all of them?
yeah
i wrote this helper a long time ago, haven't tested 1.0 as project that uses it hasn't been updated completely but i don't see why it wouldn't work
https://gitlab.com/tertle/com.bovinelabs.core/-/blob/0.9/BovineLabs.Core/Utility/DisableRenderingHelper.cs
yeah but I have the main entity and the two sub entities, which each have the mesh's on
disables all renderers in a hierarchy
I only want to disable one of the entitys renderer
I tried putting DisableRendering on the main, and the sub entities but nothing seems to work
I'm wondering if the entity requires certain components because there's the entities in the buffders which have the materials
i haven't looked at the rendering changes tbh
I'm using 0.5 still so
oh
yeah this changes a lot in 1.0
i think there's only the single parent now
uses RenderMeshArray instead
maybe that script will work you posted, I'll try it anyway, thanks
im not sure it would be possible to disable 1 sub mesh in 1.0
interesting I'd hope it would be possible