Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Unsupported enum type 'UnityEngine.Networking.Types.NetworkID'

Discussion in 'Multiplayer' started by Chris_Entropy, Oct 6, 2015.

  1. Chris_Entropy

    Chris_Entropy

    Joined:
    Apr 11, 2011
    Posts:
    202
    Every time I use the NetworkID enum type in any C# script (namespace UnityEngine.Networking.Types), my console is flooded with the following error:
    Unsupported enum type 'UnityEngine.Networking.Types.NetworkID' used for field '<variable name>' in class '<class name>'

    It does not seem to interfere with any functionality, but it clutters the console. Is there a way around it?
     
  2. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    this is a known bug.. 711764
     
  3. Chris_Entropy

    Chris_Entropy

    Joined:
    Apr 11, 2011
    Posts:
    202
    Can it be workarounded by storing the value in a ulong? Or will this cause some information to go missing?
     
  4. JeremyUnity

    JeremyUnity

    Joined:
    Mar 4, 2014
    Posts:
    147
    That's the best work around right now. The issue is Unity's enum serializer expects a 32bit value only, but the underlying type for NetworkID is a ulong
     
  5. Chris_Entropy

    Chris_Entropy

    Joined:
    Apr 11, 2011
    Posts:
    202
    Ok, thanks.
     
  6. mikef

    mikef

    Joined:
    Apr 2, 2009
    Posts:
    57
    Hi, i've just run into this issue, how do you go about converting the value to a ulong so as to avoid these errors?
     
  7. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    ulong value = (ulong) intValue?

    Typecasting?
     
  8. Chris_Entropy

    Chris_Entropy

    Joined:
    Apr 11, 2011
    Posts:
    202
    I store it in a variable of type ulong instead of a NetworkID.

    so for example:
    ulong networkIdUlong = (ulong) actualNetworkId;

    Since I only need it for comparison, I never make a cast back to NetworkID, I don't know if this would work without error. But the errors seem to be irrelevant anyway, since there do not seem to be any bugs in the actual game.
     
  9. mikef

    mikef

    Joined:
    Apr 2, 2009
    Posts:
    57
    Thanks Chris, much appreciated!
     
  10. AllFatherGray

    AllFatherGray

    Joined:
    Nov 29, 2014
    Posts:
    17
    Any ETA on when 64 bit support will be added? I'd like to be able to back my enums with long/ulongs.
     
    Miscellaneous likes this.
  11. gresolio

    gresolio

    Joined:
    Jan 5, 2014
    Posts:
    17
    Another workaround for 64bit value enum:
    just add [NonSerialized] attribute to your field
     
    Miscellaneous likes this.
  12. haouari

    haouari

    Joined:
    Jun 1, 2016
    Posts:
    3
    add
    [System.NonSerialized]
    that [NonSerialized] didn't work for me
     
    Miscellaneous likes this.
  13. haouari

    haouari

    Joined:
    Jun 1, 2016
    Posts:
    3
    but weird error popout when i do that
     
  14. PaulEmbleton

    PaulEmbleton

    Joined:
    Aug 3, 2021
    Posts:
    3
    Looks like its still a problem in 2021.3.18f1. Same error message but not sure its the same cause.

    I've a custom [Flags] enum Int64. Its used in several scripts and a static class which is a kind of messaging system for flags submitted by game objects.

    Occasionally the error appears in Unity console for one or more scripts, but not for all of them. It doesn't give a line number. It doesn't prevent playing or building the game.

    But then it disappears after an unrelated edit. Even just adding a line break can clear it. Additionally, the fields which use the enum are all private readonly. So this doesn't seen the 64 bit serialization error.
     
    Last edited: Oct 29, 2023
    noxelfoxel likes this.
  15. Miscellaneous

    Miscellaneous

    Joined:
    Sep 24, 2013
    Posts:
    53
    Will this BUG be investigated? Hopefully fixed, any better solution/workaround?