ZLinq icon indicating copy to clipboard operation
ZLinq copied to clipboard

OfComponent() generic Component constraint

Open slimshader opened this issue 6 years ago • 0 comments

Hi,

OfComponent<T> extension has a constraint that T is a Component. That used to be a requirement for a call to GetComponent<T>() but that is no longer the case. It is problematic as it does not allow to GetComponent() by its interface say we have:

class MyCompoenent : MonoBehaviour, IInteractable
{
}

it is valid to do gameObject.GetCompoenent<IInteractable>() but currently not possible to do gameObjects.OfComonent<IInteractable>();

slimshader avatar Nov 21 '19 13:11 slimshader