Closed miroslavzeman closed 3 years ago
I was able to track down and reproduce this bug locally. I was able to inspect further and have a feeling I know what the error is. I should have some more info in a day or two as to a fix.
Looking at the implementation of EntityIndexDataProvider.cs
here, it appears to be checking for any members of a component decorated with inherited attribute types of AbstractEntityIndexAttribute
. However the extension/helper methods for HasAttribute and GetAttributes do not check base classes of attributes. As a result it would never find the Primary or Entity index attributes which derive from AbstractEntityIndexAttribute
.
To resolve this I am approaching this as a few steps:
[x] Add overloads or additions to the HasAttributes and GetAttributes methods in Genesis to offer support for checking base classes of attributes. Unit tests will also be created to ensure this functionality remains working.
[x] After that Genesis functionality has been added and pushed, I will update this data provider accordingly to use it which should resolve being able to discover those derived attribute types again and generate the proper entity index code.
[ ] One of the reasons this never came up earlier is that unit tests use manually created entity index code and there are no examples of using entity indexes in the development project. I will add common examples of both indexes to ensure if this kind of issue comes up in the future that it is discoverable when regenerating code.
I've completed the first step of this which was to update genesis with better functionality for checking inherited attributes. Released this morning as a part of Genesis v2.3.1
. I'll be taking a look at the data provider either tomorrow or this weekend.
Just wanted to share an update on this; I have a fix prepared and am tracking down a remaining issue. I should have a new version containing this fix available mid-week.
I've fixed this issue and merged to develop, the fix for this should soon be available in Entitas-Redux v2.1.0
. If you could retest on this new version and let me know if this resolves your issue, I'd appreciate it.
Working like a charm! 💯 Thank you! 👍
Describe the bug Attributes
[EntityIndex]
and[PrimaryEntityIndex]
do not generate additional code for getting entities from context.Unity Version: Unity 2020.3.0f1
To Reproduce
manifest.json
with:Update Genesis CLI
andInstall or Update All Plugins
GenesisSettings
and click on Auto ImportGenerate
button inGenesisSettings
or shortcutCTRL+SHIFT+G
Expected behavior Methods for getting data by indexes should be present in
Game
context, but they are not. It's not possible to use methods likecontext.Game.GetEntityWithPrimary()
etc.Screenshots
Genesis settings:![image](https://user-images.githubusercontent.com/10854425/123637625-86f8c180-d81e-11eb-8048-b9015f3f9b56.png)
Genesis setup in project settings:![image](https://user-images.githubusercontent.com/10854425/123637746-a8f24400-d81e-11eb-89ca-5d553ae954d7.png)
Additional context Win 10, using Mono .NET 4.x in Unity player settings