Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EntityViewInspector #67

Merged
merged 1 commit into from
Oct 30, 2024
Merged

Update EntityViewInspector #67

merged 1 commit into from
Oct 30, 2024

Conversation

ivan443250
Copy link
Contributor

Hello! I noticed that when opening a custom inspector for the "EntityView" type in runtime, Unity is lagging. This happens due to access to the allComponentTypes field inside the EntityViewInspector script. The ".SelectMany()" and ".Where()" methods are deferred methods. This means that they will not be executed until the method with immediate execution is called.
Because of this, a resource-intensive operation of iterating over all classes in all assemblies is performed every time ".OnInspectorGUI()" is called.
To fix this you just need to add a linq method with immediate execution when initializing the "allComponentTypes" field. For example ".ToArray()".

@grofit
Copy link
Member

grofit commented Oct 30, 2024

Hello, thanks for the PR will get it merged in.

I just want to mention that the editor stuff in here for Unity was a proof of concept it was never really fleshed out so you will probably find lots of janky bits in there.

There was a branch created AGES ago which tried to do a bit too much (handle persistence of entities external to scene, update editors and a few other bits).

So if you are doing a lot in this space you may be able to take some of the code from this branch but I honestly cant remember what state it was in, the editor stuff seemed ok but the whole persistence layer was flakey.

https://github.com/EcsRx/ecsrx.unity/tree/editor-upgrade/src/Assets/EcsRx

@grofit grofit merged commit 676b4e6 into EcsRx:master Oct 30, 2024
@grofit
Copy link
Member

grofit commented Oct 31, 2024

Off the back of this I had a stab at updating the editors based off that branch and put the branch up, so it may be worth giving that a look, its mentioned more in here #68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants