#archived-dots

1 messages ยท Page 29 of 1

balmy thistle
rotund token
#

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

balmy thistle
#

Yes, that's the idea.

robust scaffold
rotund token
#

oh just open the source

#

its too well documented for me to post it here

robust scaffold
#

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?

mortal ether
#

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.

late mural
#

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

robust scaffold
#

Does anyone know what these two components are? They are giant and I dont have any transform components on this entity.

mortal ether
robust scaffold
mortal ether
#

Yep. So is the 3-way toggle in play mode. We are making it a drop-down.

robust scaffold
#

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.

rotund token
#

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

robust scaffold
rotund token
#

well when we get c# 10 you can just do something like
global using L2WT = Unity.Transforms.LocalToWorldTransform;
if you really want...

robust scaffold
#

We'll sooner see tiny get revived from the dead than C# 10.

wraith hinge
#

a) I disagree and b) do you not have tab completion?

robust scaffold
wraith hinge
#

true

robust scaffold
#

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.

rotund token
#

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

robust scaffold
#

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.

rotund token
#

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]

robust scaffold
#

Hrm, so make an intermediate managed component containing copies of the monobehaviors... huh. TemporaryBakingType?

rotund token
#
    /// 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

robust scaffold
#

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.

brave field
#

Hybrid interop

clear radish
#

anyone else have issues with latest entities + physics 1.0 giving error for 'LocalToWorldTransform'?

rotund token
#

LocalToWorldTransform should not be usable if you have physics enabled

clear radish
#

right, just saw in a post, thanks

rotund token
#

physics/netcode do not support the latest transform system so force enable the old V1

clear radish
#

so everything back to Translation

safe lintel
#

anyone have an idea of what BakingType would typically be used for? sometimes struggle to think of uses for some of the features available

rotund token
#

i'm still not 100% certain of the use for BakingType vs TemporaryBakingType

#

but i've been using TemporaryBakingType a bit

safe lintel
#

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)?

rustic rain
devout prairie
#

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?

rotund token
#

physics currently updates mostly in baking systems

#

it creates passes temp data in bakers for the systems

devout prairie
#

any idea if it is possible to access those joint entities within the baker?

rotund token
#

you should consider baker isolated

rustic rain
#

past Baker you can access anything in BakingSystem

#

only within ECS sadly

devout prairie
#

so it should then be possible to access the additional entities created by joints, inside a BakingSystem

rustic rain
#

and world

#

all your systems will run once

#

same rules as runtime

devout prairie
#

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

rustic rain
#

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

devout prairie
#

mmm

#

so can those 'bakingsystems that just do whatever' access and alter Prefab hierarchies that have previously been converted by the first phase?

rustic rain
#

you can do jobs here, kek

#

if you want

#

it's literally normal World

#

that only updates once

#

that's about it

devout prairie
#

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

rustic rain
#

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

devout prairie
#

you mean ever because they've been removed or specifically during conversion?

rustic rain
#

and will add to it all entities of game objects that are children

#

in GO hierarchy

rustic rain
#

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

devout prairie
#

yeah that sounds like exactly the kind of workarounds i'm currently doing for physics

rustic rain
#

by doing Baker<Transform>

devout prairie
#

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

rustic rain
#

what is it you want to access?

rotund token
#

the order of baking is

PreprocessBake

  • PreBakingSystemGroup

Bakers

  • BakingSystem.Bake

PostprocessBake

  • TransformBakingSystemGroup
  • BakingSystemGroup
  • BakingSystem.UpdateReferencedEntities();
  • LinkedEntityGroupBaking
  • BakingCompanionComponentSystem
  • PostBakingSystemGroup
  • BakingStripSystem
devout prairie
#

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

rustic rain
#

yeah, it sucks

rustic rain
#

but whatever, it is what it is

#

doubt it will change

#

so

#

better get used to it

devout prairie
#

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

rotund token
#

on the other hand, i think most normal devs won't be doing such weird things

devout prairie
#

the ironic thing though, to me, is that ecs and systems are actually pretty straightforward, conversion is the headache part

rustic rain
#

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

rotund token
#

my only complaint atm is my inability to create entities in baking systems

#

or maybe i've just missed something

rustic rain
#

you can't?

devout prairie
#

doesn't it have the create additional entities thing

rustic rain
#

no

rotund token
#

it's an ISystem

#

it just says entity not assigned to an authoring component and will be ignored or something like that

rustic rain
#

or SystemBase

#

hmm

#

have you tried BakingSystem

devout prairie
#

ah i think i read you complain about that

#

so it needs a go ref

rustic rain
#

to inherit from?

rotund token
#

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

devout prairie
#

i have a feeling they might address that

rustic rain
#

hmm

#

I wonder

#

if you can do it

#

with

#

Baker<SubScene>

#

๐Ÿค”

rotund token
#

i did consider attaching it to some subscene entity

devout prairie
#

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

rustic rain
#

pretty sure they did it

#

because conversion wasn't doing too well with live conversion

devout prairie
#

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

rustic rain
#

well, I do like the idea of it

#

and if it works

#

then fine, my heart with accept it xD

devout prairie
#

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)

rustic rain
#

ain't that's exactly how it meant to be?

devout prairie
#

just simple, without all the bugs/mess

rustic rain
#

you either close subscene (convert offline)

devout prairie
#

well currently subscenes are live, and buggy as all hell in my experience

rustic rain
#

or start with open (convert online)

devout prairie
#

for me the damn buttons were just vanishing

rustic rain
#

UI is broken

#

yeah

#

I can't even deal with it, so I wait for new updates

devout prairie
#

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, ๐Ÿคทโ€โ™‚๏ธ

brave field
#

๐Ÿฅฒ Simple test project still can get this subscene error

rotund token
#

clear the entity cache after you fix any compile errors

brave field
#

For 1.0, where's clear the entity cache button located at? Can't find it lol

rotund token
#

preferences -> entities

brave field
#

๐Ÿ‘€ Need more bottom tabs at 1.0

hot basin
#

How to make a raycast in physics 1.0 in SystemBase?

rotund token
#

at least i have an ultrawide so i have 2 groups next to each other

hot basin
#

previously I just get CollisionWorld from .GetExistingSystem<Unity.Physics.Systems.BuildPhysicsWorld>();

rotund token
#

oh

#

var physicsWorld = SystemAPI.GetSingleton<PhysicsWorldSingleton>().PhysicsWorld;

proud jackal
#

You were too quick tertle I was about to type it ๐Ÿ˜†

hot basin
#

thanks!

rotund token
#

Copy paste trumps typing!

hot basin
#

upgrading 0.51 -> 1.0exp is tedious

rotund token
#

i found it pretty fine until i hit netcode

hot basin
#

what about authoring?

rotund token
#

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

hot basin
#

oh yeah I had bunch of [GenerateAuthoringComponent]

rotund token
#

yeah i had i think 5 of 14 libraries

#

and most all were tag components

hot basin
#

now I'm replacing ECBs

rotund token
#

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

hot basin
#

do you still cache something?

#

i.e. singleton of ecb system

rotund token
#

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)

brave field
rotund token
#

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

proud jackal
pulsar jay
#

Do I understand correctly that companion objects wont be a thing anymore with 1.0?

rotund token
#

as far as i'm aware they still exist

full epoch
#

In systembase systems we had Enabled property to enable/disable systems - is there something similar for ISystem systems?

rotund token
#

SystemState.Enabled

#

for the most part, under the hood systembase actually just uses the same SystemState that is passed into ISystem

full epoch
#

thx

rotund token
#

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;
        }```
hot basin
#

oh yeah forgot that if my authoring was change I need to remake everything from scratch

hot basin
#

are class/managed components removed entirely?

#

nvm I think I need to use AddComponentObject in Baker

devout prairie
#

Here's a not exactly relevant question for you all but i'm curious: Laptop or Desktop?

remote crater
#

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

hot basin
#

@remote crater URPMaterialPropertyBaseColor

remote crater
#

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.

remote crater
hot basin
#

HDRPMaterialPropertyBaseColor? ๐Ÿ˜„

remote crater
#

So color is changeable! Awesome!

#

Is skin material changeable?

hot basin
#

check samples for HDRP

remote crater
#

yayah ty Kra

hot basin
#

AFAIK both pipelines can have custom shader properties overrides

#

so you can override everything you want

remote crater
#

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

remote crater
#

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...

โ–ถ Play video
#

Good Stuff Gustov

hot basin
#

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>();
        }
    }
proud jackal
#

Oh gotcha!.. Hmm, that totally should work o.o

#

What error are you getting?

hot basin
#

It just don't get added

proud jackal
#

Does it not show in the editor or? I'm assuming you put OnCreateAuthoring on an entity in your subscene

hot basin
#

yeah, it's on the object in the subscene

rustic rain
proud jackal
#

Awesome, could you then check what happens if you press this?

hot basin
proud jackal
#

As that should show you the baking result aka the baked entity

#

Oh that's very interesting O.O

hot basin
#

UIComponent is managed component added by AddComponentObject() in it's own baking class

#

ok

#

I changed ICleanupComponentData to IComponentData and it's working

rustic rain
#

hmmm

#

I wonder if Unity aims towards keeping Game Objects inside SubScenes

#

considering currently World loads before Scene

viral sonnet
robust scaffold
harsh owl
#

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?

proud jackal
viral sonnet
#

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

proud jackal
#

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!

rustic rain
#

Any idea what happens when you try to remove Entity with cleanup component? And only it

viral sonnet
#

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.

rustic rain
#

I wonder how much overhead it creates over doing em.RemoveComponents(e, lots of types);

wraith hinge
#

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?

rustic rain
#

related to limitation of ComponentTypes capacity

wraith hinge
#

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

rustic rain
wraith hinge
#

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?

rustic rain
#

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

wraith hinge
#

i'm afraid i don't see how modding is related; what would modders add?

rustic rain
#

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

wraith hinge
#

so like the modder defines a new component?

#

and they add an assembly that they build themselves, or something?

#

let's make a thread

whole gyro
#

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?

viral sonnet
#

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

robust scaffold
#

Welp, companion game objects and the new transform components and transform usage flags do not play well together

viral sonnet
#

you can still use companion links? ๐Ÿง

robust scaffold
#

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

viral sonnet
#

wouldn't the white list get wiped when you run the game?

robust scaffold
#

It worked with the GOCS but not the baker variants. Because GOCMS doesnt exist when bakers run.

viral sonnet
#

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

robust scaffold
#

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

viral sonnet
#

huh, CompanionLink is private. Add HybridObject is gone. it vanished from the docs in 0.51. how do you set this up?

robust scaffold
#

It's been merged with AddComponentObject

viral sonnet
#

oh, i'm using AddComponentObject with a Transform. never seen a CompanionLink

robust scaffold
#

CompanionComponentSupportedTypes are the types that spawn a companion GO

rustic rain
robust scaffold
viral sonnet
#

yes, Transform work

#

the list has no SkinnedMeshRenderer. teh fk

#

but it has a MeshRenderer

#

maybe that will help you?

robust scaffold
viral sonnet
#

BakingCompanionComponentSystem.cs line 180

robust scaffold
#

Also Systembase got a direct property of "WorldRewindableAllocator". No longer need to access the World.UpdateAllocator

#

Hahahaha, unity that wont stop me

viral sonnet
#

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? ๐Ÿ˜„

viral sonnet
rotund token
#

Because you're not meant to add new ones ๐Ÿ˜…

rustic rain
#

such an important feature

viral sonnet
#

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

robust scaffold
#

Hahahahaha. Thanks Enzi, it works.

#

Just gotta yank those internal methods out into the light of public. Like all good unity functions.

whole gyro
#

What is a companion link exactly?

robust scaffold
whole gyro
#

Does it keep the originating game object alive or something?

robust scaffold
#

No, it spawns a copy, hence the (clone) (clone) (clone)

whole gyro
#

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?

robust scaffold
#

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.

whole gyro
#

When does the game object get cloned? Is it during the bake or at runtime?

robust scaffold
#

At bake / inside the editor.

whole gyro
#

Interesting. Is it hidden in the hierarchy then?

quick gazelle
#

I haven t had a question in weeks since

robust scaffold
rustic rain
#

It's a cool thing

#

gameobjects only exist with entity

#

entity removed - GO removed

robust scaffold
#

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.

rustic rain
#

Just use old one?

#

new transform is just uugh yet

robust scaffold
#

No no, I dont want the L2W to exist.

rustic rain
#

very early into development I think

#

tbh, I'd rather them have 1 component

#

like

robust scaffold
#

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

rustic rain
#

LocalToWorld, but with tons of properties which allow assigning values to specifics

robust scaffold
rustic rain
#

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

robust scaffold
#

that waste 8 floats when you can fit the entire transform into a component half the size.

rustic rain
#

hold up

#

position = 3
scale = 3
rotation = 4
10

#

right

#

ok

#

math is hard ๐Ÿ˜…

#

anyways

robust scaffold
#

and pulling eulerian rotation values are really painful for a 4x4

rustic rain
#

I wouldn't consider size a problem anyway

#

they have capped chunk size to 128

#

so

#

rip small archetypes perfomance

robust scaffold
#

Every byte counts in the end.

rustic rain
#

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

whole gyro
#

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.

frosty siren
wraith hinge
#

probably com.unity.platforms, guessing same version as entities

whole gyro
wraith hinge
#

i know there are fixes for picking in general coming

#

dunno about whether that exact bug is fixed or not

whole gyro
#

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.

rotund token
#

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

wraith hinge
#

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

rotund token
#

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)```
wraith hinge
#

fixed in an upcoming editor release iirc

#

was a bug in properties

viral sonnet
#

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?

rotund token
#

i haven't seen this one

balmy thistle
molten flame
#

I have a similar thing happen with my InputActions asset, sometimes it just doesn't serialize/deserialize properly and have to reimport it.

viral sonnet
rotund token
#

SceneSection, SceneTag - yeah i can see that breaking some stuff o_O

viral sonnet
#

to my defense, i don't use them anywhere! ๐Ÿ˜„ subscenes were just my recent error. i had this on all kinds of scripts now

rotund token
#

side note, not sure if you missed it before but there's kind of an official way to strip transform components now

viral sonnet
#

i missed it

rotund token
#

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
viral sonnet
#

oh, how do i set this for the entity that is baked? i'm only using the flag for CreateAdditionalEntity

rotund token
#

GetEntity([optional]authoring, TransformUsageFlags.ManualOverride)

viral sonnet
#

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

rotund token
#

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

proud jackal
rotund token
#

and use the temporarybakingtype attribute to remove it at the end

proud jackal
#

Don't quote me on this, but I think an entity with only bakingtypes and manualoverride will auto delete after baking think

viral sonnet
#

thanks, i'll try that

viral sonnet
viral sonnet
proud jackal
#

Gotcha! Thx for letting me know :3

rotund token
#

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

viral sonnet
#

yep, can repo. not on all subscenes though. killed my unity with errors ๐Ÿ˜„

rotund token
#

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 ^_^'

viral sonnet
#

if i learned something from webdev in the past. always spam buttons that are not supposed to be spammed ๐Ÿ˜„

whole gyro
viral sonnet
#

good to know, i don't add any comps though. it's the empty entity screenshot i posted above

whole gyro
#

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

whole gyro
#

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.

rotund token
#

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

whole gyro
#

I'm actually not sure when OnStartRunning() happens compared to scene load

rotund token
#

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

whole gyro
#

Make your systems implement an IAfterSceneLoad interface? Find them all with reflection and call their callbacks after the scene is loaded

rotund token
#

i'm very specifically trying to not use any hacks

whole gyro
#

ha

rotund token
#

so this library is just droppable in anyones project and works

#

just going to suck it up and use OnStartRunning

whole gyro
#

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

rotund token
#

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 ๐Ÿฅณ

whole gyro
#

Haha yay ๐ŸŽ‰

devout prairie
#

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

rotund token
#

oh yeah

viral sonnet
#

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

rotund token
#

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>()
!

proud jackal
viral sonnet
#

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?

proud jackal
#

They also do .Update and Cache automatically in OnCreate

rotund token
#

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?!

viral sonnet
#

that's a really nice way to get around the boilerplate

proud jackal
#

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

rotund token
#

yeah, i only realized this after i updated everything and had to go update everything again

viral sonnet
#

gonna rewrite some systems tomorrow with this ๐Ÿ˜„

rotund token
#

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

devout prairie
rotund token
#

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

devout prairie
#

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?

rotund token
#

you can not

#

only component/buffer handle

devout prairie
#

Ok haha, just double checking that one!

#

GCLookup is indeed a nice touch, look forward to using that

gentle gyro
#

2022.2.0b10 is now available...

#

Hoping it fixed the IL2CPP bug... ๐Ÿคž

rotund token
#

congratulations david on volunteering to be the channels test dummy, please report back asap

gentle gyro
#

๐Ÿคฃ ๐Ÿ˜‚ ๐Ÿ˜

#

Will do...

balmy thistle
#

No, pretty sure b10 won't contain the fix.

gentle gyro
#

Darn...

balmy thistle
#

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.

rotund token
#

"Who's deleting my companion objects?! ๐Ÿ˜ก "
journaling - "you are"

#

where was this window 2 years ago

rotund token
#

hmm just updated my AlwaysUpdatePhysicsWorld system, still haven't heard an argument why this shouldn't be done but it still concerns me

molten flame
#

tertle is in a moooood today and I'm here for it ๐Ÿ˜‚

rotund token
#

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

molten flame
#

ah so gives your frame perfect collision queries, hmm most people would want this by default I would imagine

rotund token
#

well everyone has told me it's a bad idea

#

but never given a convincing reason why

molten flame
#

I can't think of why you wouldn't want this other than to save a small bit of processing power

rotund token
#

"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

molten flame
#

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.

rotund token
#

it's worked well for me

rustic rain
#

Did last patch fix UI issues with hierarchy?

rotund token
#

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

rustic rain
#

bruh, bug still exists

rotund token
#

what was your error again? it was pretty specific right

#

i don't think i've heard anyone else have this specific one

rustic rain
#

in playmode subscenes look like this

#

outside of playmode they look good

rotund token
#

have you checked with entity journaling what removes it?

rustic rain
#

journaling is empty

#

I tried enabling it

#

but nothing is recorded

rotund token
#

hit pause button

#

hit play

#

go to journaling and start recording

#

unpause

rotund token
#

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);

rustic rain
#

nah, nothing is recorded

rotund token
#

but not doing
EntityManager.AddComponentObject(sceneEntity, this);

rustic rain
#

error happens as soon as I open Hierarchy window

rotund token
#

where this = SubScene

rotund token
#

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

rustic rain
#

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?

rotund token
#

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

rustic rain
#

because I use interface to create it

#

and I do create

#

same as default init

#

but systems don't

rotund token
#

int has nothing to do with it

rustic rain
#

which might be the case

rotund token
#

OnEnable is a monobehaviour

#

did you override AutomaticWorldBootstrap?

rustic rain
#

yeah, and world is created before the scene is

rotund token
#

and the scene systems are included?

rustic rain
#
        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

rotund token
#

so you aren't adding the systems though

#

so the code above still fails

rustic rain
#

yeah, I see

#

so

#

what system do I need

#

to create

#

so subscenes are registered correctly?

rotund token
#

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

rustic rain
#

๐Ÿค”

#

I'd rather create subscene systems

#

I just need to know which

#

I assume

#

SceneSystem is one

rotund token
#

There's some scene section ones

rustic rain
#

I wonder if they have any sort of attribute on them

#

so I can easily query them through reflection

rotund token
#

They're all isystem now I think

rustic rain
#

that's fine

#

DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(_world, bootSystems);

#

works well with Type[]

#

[UpdateInGroup(typeof(SceneSystemGroup))]

#

huh

rotund token
#

work?

rustic rain
#

just finished testing

#

yeah

#

works

#

thanks!

#

๐Ÿค”

#

no errors, but

#

smth is wrong

rustic rain
#

await UniTask.WaitUntil(() => SceneSystem.IsSceneLoaded(World.Unmanaged, sceneEntity));

#

yep

#

this does not work

#

it's forever awaited

#

without a result

#

weird

rotund token
#

sounds like you aren't ticking your world

rustic rain
#

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

rotund token
#

doesn't seem like that would include the scene system group itself

rustic rain
#

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

rotund token
#

it never really did?

rustic rain
#

it said class name in exception

rustic rain
#

Finally
Managed to get partial functionality of project ๐Ÿ˜…

half jay
#

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?

rustic rain
#

rendering is done by Unity

rustic rain
#

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)
rustic rain
#

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?

devout prairie
half jay
rustic rain
devout prairie
#

I think 1.0 has dropped ConvertToEntity completely right

#

Subscene and Bakers only

#

You must become a Master Baker

robust scaffold
devout prairie
robust scaffold
#

Woah, new rider UI is slick

rustic rain
#

what new rider UI?

robust scaffold
#

Rainbow brackets unfortunately doesnt work with it. Otherwise, looks cool

rustic rain
#

for a second I thought you were joking and this is VS

robust scaffold
robust scaffold
#

Does anyone know how to use the SystemAPI Query with an existing entity query? Do I need to construct a new one every time?

whole gyro
robust scaffold
whole gyro
#

It also just looks way less busy

#

unless that part isn't new and I've somehow missed a focus mode

robust scaffold
rustic rain
#

stores it in a field

#

and then uses it

robust scaffold
rustic rain
#

no idea, barely use it

robust scaffold
#

Unity uses it everywhere, at least in their training samples, so it's pretty important.

#

I think this works.

rustic rain
#

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

robust scaffold
#

Yea... that's what im doing anyways.

rustic rain
#

๐Ÿ˜…

robust scaffold
#

The query builder is a different section of code

rustic rain
#

oof, hard to get used to all that stuff

#

after doing it for almost a year manually

rustic rain
robust scaffold
#

I would like to make this into a SystemAPI.Query but the .WithNone<Tag>() doesnt seem to work.

robust scaffold
rustic rain
#

yeah

#

good stuff

robust scaffold
#

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.

rustic rain
#

I remember that feature from VS

#

missed it a bit

robust scaffold
#

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?

rustic rain
#

cleanup components are runtime only

robust scaffold
#

That means I am forced to use companion GOs....

whole gyro
whole gyro
#

mmk, I'll try that

robust scaffold
#

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

whole gyro
#

Are you thinking of relying on the existing companion stuff or implementing a new version of that?

robust scaffold
whole gyro
#

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?

robust scaffold
#

Nah, I'm instead gonna make a copy of every Unity component then recreate the managed companion GO at start of runtime.

whole gyro
#

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

robust scaffold
#

Yea, if I could use SS/CCD at baking, recreating companion GOs would be trivial.

whole gyro
#

SS/CCD?

robust scaffold
#

SystemState or as they're called now Cleanup Component Data

whole gyro
#

You can if you are creating the companion GO at runtime anyways

robust scaffold
#

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

whole gyro
#

Oh you mean doing this during baking?

robust scaffold
#

Ideally yes. But without access to CCDs, i'm doing it at runtime.

whole gyro
#

Yeah makes sense

robust scaffold
#

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.

whole gyro
robust scaffold
whole gyro
brave field
robust scaffold
whole gyro
whole gyro
#

Or is the existing companion link also at runtime?

robust scaffold
# whole gyro I agree that it should auto-populate and should be readonly. I'm not super famil...
[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.
whole gyro
robust scaffold
whole gyro
#

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

robust scaffold
#

Oh, yea. No clue about that. My hierarchy is completely flattened.

whole gyro
#

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

robust scaffold
#

Definitely. Hrm, redraws happen a lot. I need to find a way to check if the GO as a whole changed.

robust scaffold
whole gyro
#

Hmm yeah. Seems less than ideal but not finding another way

robust scaffold
#

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.

whole gyro
#

I gotta run, but good luck! Curious to hear if you get it working

robust scaffold
oblique cosmos
#

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?

robust scaffold
# whole gyro Yeah that could work
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.
robust scaffold
safe lintel
#

@oblique cosmos new transform system isnt used by netcode or physics(afaik presence of either will disable it), havent used aspects yet personally

oblique cosmos
#

But that's pretty much it, otherwise it's functional, yea?

robust scaffold
#

Yea. Functional.

oblique cosmos
#

Cool, thanks!

robust scaffold
#

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.

whole gyro
#

Nice looks great!

quick gazelle
# robust scaffold I would like to make this into a SystemAPI.Query but the .WithNone<Tag>() doesnt...

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.

whole gyro
# robust scaffold Would be nice if I could add a checkbox next to each element in the inspector li...

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;
    }
}
robust scaffold
robust scaffold
#

hrmmmmm

#

Well, you just cant close / stream subscenes with this. Unless i can serialize the entire component.

whole gyro
#

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

robust scaffold
#

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.

whole gyro
#

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.

rustic rain
robust scaffold
#

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.

whole gyro
robust scaffold
whole gyro
#

hmm okay, sounds more complicated than I thought

devout prairie
#

this all sounds like pain, i think i'll wait for 2.0

robust scaffold
#

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

devout prairie
#

i'm kinda joking tbh, just hoping conversion isn't too much hassle to port over, everything else looks like pure improvements

whole gyro
# devout prairie i'm kinda joking tbh, just hoping conversion isn't too much hassle to port over,...

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.

robust scaffold
whole gyro
rotund token
whole gyro
#

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

rotund token
#

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

whole gyro
#

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.

rotund token
#

I'm still a bit confused, are you talking about runtime editing?

#

Like after you instantiate it

whole gyro
robust scaffold
#

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

whole gyro
#

For me, the deal breaker with the prefab workflow is not being able to reference other things in the subscene, or other hybrid objects

whole gyro
robust scaffold
rotund token
#

Or! Make it pure ๐Ÿ™ƒ

robust scaffold
#

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

viral sonnet
#

what's the problem with baking?

robust scaffold
#

Hybrid

rotund token
#

He's making a gameobject game and tacking on entities

viral sonnet
#

where do you have trouble?

robust scaffold
#

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.

viral sonnet
#

i have some hybrid baking. spawns some gos or entities in both directions

whole gyro
whole gyro
viral sonnet
#

scene gos also work

whole gyro
#

scene game object linked to a baked entity somehow? Or runtime entity creation?

viral sonnet
#

the scene go spawns a (baked) entity prefab. no runtime conversion of course

whole gyro
#

how does this work? Like how do you reference the baked entity prefab from the scene without cross-scene references?

rotund token
#

You could just use weak asset references like dots shooter sample

viral sonnet
#

either that which would make it full generic, a dedicated spawner or ids

whole gyro
#

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?

rotund token
#

(I'd make the baked entities reference the game objects but either way technically works)

whole gyro
#

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.

viral sonnet
#

it uses the asset guid

rotund token
#

you can implement it however you want

#

but yeah unity used guid because they only used it on cross scene prefabs

viral sonnet
#

sure, using the guid from the asset just makes it very straight forward

whole gyro
#

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

rotund token
#

so they'd register all their prefabs in 1 scene, convert

#

and other scenes could reference these

viral sonnet
#

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

rotund token
#

i seem to be getting less random ui element errors

#

but could be coincidence

whole gyro
#

So that gameobject can just query for that component type?

viral sonnet
#

dedicated spawner comp, dedicated spawner system

#

identified by struct type

rotund token
#

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

quick gazelle
whole gyro
#

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.

rotund token
#

are you allocating it?

#

because if so, no

#

it's not going to be allocated when you deserialize the subscene

whole gyro
#

yeah makes sense

rotund token
#

as the error message says, you can store pointers with [ChunkSerializable] in subscenes

whole gyro
#

so no native collections in subscene entities, only runtime entities?

rotund token
#

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

viral sonnet
#

the allocation has to be at runtime

viral sonnet
whole gyro
#

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

rotund token
#

(that said I disagree with putting native containers on regular entities anyway, [good on singletons])

#

remember you still need to deallocate it

whole gyro
#

yeah its a singleton

viral sonnet
#

OrderChange filter also works

#

ah with a singleton i'd just create it at runtime

rotund token
#

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

whole gyro
#

yeah that was my new plan ๐Ÿ‘

rotund token
#

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

whole gyro
#

Yeah, your K system, right?

rotund token
#

nah

whole gyro
#

oh nvm then haha

rotund token
#

that's too manual for prefab keys

#

i want this to be automated and unbreakable

whole gyro
#

Interesting. Sounds similar to what I want for my tween registry

rotund token
#

i took a little inspiration from eizenhorn system

whole gyro
#

So if a system wants a prefab, how does it get the index in the buffer?

rotund token
#

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

whole gyro
#

haha sure, but how does the system get the key?

rotund token
#

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

whole gyro
#

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

rotund token
#

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

whole gyro
#

oh that's cool. And where are you storing the list in the editor?

rotund token
#

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

whole gyro
#

I think I saw your message about that a while back actually

rotund token
#

well that's boring ๐Ÿ˜„

whole gyro
#

At bake, iterate the asset database or something?

rotund token
#

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

#

and that's all you store on your component

#

anyway this is my mornings update to 1.0 job ๐Ÿ˜„

whole gyro
#

neat, sounds like exactly what I want for my tween scriptable objects. This system of yours isn't generic by any change, is it? ๐Ÿ˜

rotund token
#

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 ๐Ÿ˜„

whole gyro
#

Does that mean in authoring, you can set an incorrect type?

rotund token
#

as long as it can be a gameobject and therefore convertable to an entity

rotund token
#

but this is why i provide categories

whole gyro
#

Maybe I'm misunderstanding, but it sounds like your system works with prefabs (within categories). But not any type of scriptable object.

rotund token
#

my system works with entities

#

all my data is stored on entities

#

it maps keys -> entity prefabs at runtime

whole gyro
#

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!

rotund token
#

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

whole gyro
#

yeah I remember reading that a while back. So how does ObjectDefinition.ID work in baking if it is dependent on this running first?

rotund token
#

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

rotund token
#

as you are not referencing this ID you are referencing the definition everything just works

whole gyro
#

So if an object definition is deleted, your list is sparse?

rotund token
#

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

rotund token
#

so there is a chance of holes but new assets will fill them

whole gyro
#

ah nice

rotund token
#
            // 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

whole gyro
#

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

pliant pike
#

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

rotund token
#

aren't multiple meshes handled by multiple entities

#

so it would need to be on all of them?

pliant pike
#

yeah

rotund token
pliant pike
#

yeah but I have the main entity and the two sub entities, which each have the mesh's on

rotund token
#

disables all renderers in a hierarchy

pliant pike
#

I only want to disable one of the entitys renderer

rotund token
#

oh

#

and putting it on that specific entity is not working?

pliant pike
#

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

rotund token
#

i haven't looked at the rendering changes tbh

pliant pike
#

I'm using 0.5 still so

rotund token
#

oh

#

yeah this changes a lot in 1.0

#

i think there's only the single parent now

#

uses RenderMeshArray instead

pliant pike
#

maybe that script will work you posted, I'll try it anyway, thanks

rotund token
#

im not sure it would be possible to disable 1 sub mesh in 1.0

pliant pike
#

interesting I'd hope it would be possible