Description
After refactoring code to have generic base types, Unity refused to compile until all generics with types extending NetworkBehaviour were swapped to MonoBehaviour
Reproduce Steps
-
Create a generic that extends NetworkBehaviour, such as: public abstract class BaseActionController<ActionType,CharacterType> : NetworkBehaviour where ActionType : BaseAction<CharacterType> where CharacterType : NetworkBehaviour
-
Try to compile and run project.
Actual Outcome
Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP: (0,0): error - System.NullReferenceException: Object reference not set to an instance of an object
Expected Outcome
Code compiles.
Environment
- OS: Windows 11
- Unity Version: 2023.1.0b20
- Netcode Version: 1.5.1
- Netcode Commit: 7a969f8
Additional Context
For now I have managed to replace the code with extending MonoBehaviour and it compiles, but it does not seem like an ideal limitation as I may have to assert types down the road.
Description
After refactoring code to have generic base types, Unity refused to compile until all generics with types extending
NetworkBehaviourwere swapped toMonoBehaviourReproduce Steps
Create a generic that extends
NetworkBehaviour, such as:public abstract class BaseActionController<ActionType,CharacterType> : NetworkBehaviour where ActionType : BaseAction<CharacterType> where CharacterType : NetworkBehaviourTry to compile and run project.
Actual Outcome
Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP: (0,0): error - System.NullReferenceException: Object reference not set to an instance of an objectExpected Outcome
Code compiles.
Environment
Additional Context
For now I have managed to replace the code with extending
MonoBehaviourand it compiles, but it does not seem like an ideal limitation as I may have to assert types down the road.