Skip to content

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

@gary9716

Description

@gary9716

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions