I have an interface called “IAttribute” that I give to each attribute component. These attributes are applied to a ball to change its behavior, and there can be multiple at a time. Using attributeComponent.GetComponent<IAttribute>()
I can get those, but the problem is that when multiple attributes are on a ball, the code checks the gameObject and finds multiple, but only returns one of them (which may or may not be correct). This is a problem, as I need to correctly get and set their properties, but currently, it only does this for one of them. I’ve tried using a Component comp
property in the interface that I set with comp = this
in the attribute components’ Awake() functions and searching for each interface with that, but I need to reference it before the components’ Awake() functions run, so in this scenario, I need an interface reference to set them.
My question is: is there any way to search for the specific IAttribute component without returning a random component that implements it and exists on the same gameObject? Thanks in advance!