C
C#6mo 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
! 'Hoplan6mo ago
if you need more screen tell me
! 'Hoplan
! 'Hoplan6mo ago
No description
No description
Angius
Angius6mo ago
What exactly is the error?
! 'Hoplan
! 'Hoplan6mo 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
Angius6mo ago
Well, there you have it. The Menu class does not seem to have UnityEngine.Component anywhere in its inheritance chain
! 'Hoplan
! 'Hoplan6mo ago
it have it "unityEngine'"
No description
Angius
Angius6mo 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
! 'Hoplan6mo ago
nope bit if i use MonoBehavior my code is full of error
Angius
Angius6mo 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
! 'Hoplan6mo ago
so i have to put the using UnityEngine (UnityEngine.Component) ?
Angius
Angius6mo ago
No Menu needs to inherit Component Either directly or indirectly Do you know what inheritance is?
! 'Hoplan
! 'Hoplan6mo ago
nope
! 'Hoplan
! 'Hoplan6mo ago
MonoBehaviour is a subclass of Component
Want results from more Discord servers?
Add your server