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

Objects which class with interface implemented couldn't be inject correctly #684

Open
gary9716 opened this issue Mar 13, 2021 · 0 comments

Comments

@gary9716
Copy link

gary9716 commented Mar 13, 2021

Hi, recently I found out that some objects which class that has interface implemented would not able to correctly get the dependencies from scene context.(dependencies from project content can be perfectly resolved without any hassle.) For example, I have a class called EquipCardCtrler. It has Monohaviour class as base and ISlotItem as interface. One of its dependencies is called PrefabMgr. This dependency is dynamically bound in difference scenes. It would always cause error when those objects which classes with interface implemented got injected. It said a sort of message like the dependency graph cannot be resolved. I solved this issue by casting the object into its base class and then injecting.
For example:
....
var ctrler = aGameObj.GetComponent< EquipCardCtrler >();
diContainer.Inject(ctrler as MonoBehaviour);
....

Hope this can help someone who struggle with same issue.

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

No branches or pull requests

1 participant