FishNet icon indicating copy to clipboard operation
FishNet copied to clipboard

Using generics with NetworkBehaviour classes throws at runtime.

Open FirstGearGames opened this issue 3 years ago • 1 comments

Reported by Khalos.

Using generics with NetworkBehaviour classes throws at runtime. Reproduced by adding the following to an object in the scene.


using FishNet.Object;

public class Base<T> : NetworkBehaviour 
{
}

public class GenericIssue : Base<string> 
{
}

Decompiler shows the generics are not being included when Awake is initializing. Codegen will need to be adjusted to check for generics in Awake calls, and NetworkInitialize calls.

//invalid generated code.
    if (((AA<>) this).NetworkInitializeEarly_AA`1_Assembly\u002DCSharp\u002Edll)
      return;

FirstGearGames avatar Jun 25 '22 15:06 FirstGearGames

Just ran into this as well. Did anyone ever find a workaround?

lukechatton avatar Aug 19 '22 01:08 lukechatton

This is currently being worked on. There is no ETA yet but with current progress everything is believed to be working except SyncVars in the generic types.

FirstGearGames avatar Oct 25 '22 21:10 FirstGearGames

Added support for this in 2.6.0. Currently available for public testing.

FirstGearGames avatar Nov 15 '22 15:11 FirstGearGames

No reports of problems yet. We may have some rare instances down the road but until then this is considered working!

FirstGearGames avatar Nov 18 '22 22:11 FirstGearGames