C
C#8mo ago
! 'Hoplan

error CS0311 in my loader

Error CS0311 Unable to use type 'HLTool.UI.Menu' as parameter of type 'T' in generic type or method 'GameObject.AddComponent<T>()'. There is no implicit reference conversion from 'HLTool.UI.Menu' to 'UnityEngine.Component'.
No description
14 Replies
! 'Hoplan
! 'HoplanOP8mo ago
if you need more screen tell me
! 'Hoplan
! 'HoplanOP8mo ago
No description
No description
Angius
Angius8mo ago
What exactly is the error?
! 'Hoplan
! 'HoplanOP8mo ago
Error CS0311 Unable to use type 'HLTool.UI.Menu' as parameter of type 'T' in generic type or method 'GameObject.AddComponent<T>()'. There is no implicit reference conversion from 'HLTool.UI.Menu' to 'UnityEngine.Component'.
Angius
Angius8mo ago
Well, there you have it. The Menu class does not seem to have UnityEngine.Component anywhere in its inheritance chain
! 'Hoplan
! 'HoplanOP8mo ago
it have it "unityEngine'"
No description
Angius
Angius8mo ago
Uh, that's a namespace you're importing, yes Does not mean that Menu inherits, at some point, from Component Or does Overlay inherit Component?
! 'Hoplan
! 'HoplanOP8mo ago
nope bit if i use MonoBehavior my code is full of error
Angius
Angius8mo ago
Why would you use MonoBehavior? Menu needs inherit from a Component, as the error says You can use .AddComponent<T>() only when T is a component So either literally is the Component class, or inherits from it
! 'Hoplan
! 'HoplanOP8mo ago
so i have to put the using UnityEngine (UnityEngine.Component) ?
Angius
Angius8mo ago
No Menu needs to inherit Component Either directly or indirectly Do you know what inheritance is?
! 'Hoplan
! 'HoplanOP8mo ago
nope
! 'Hoplan
! 'HoplanOP8mo ago
MonoBehaviour is a subclass of Component
Want results from more Discord servers?
Add your server