question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't inherit from NetworkVariable

See original GitHub issue

Description

Since NetworkBehaviour use IsSubclassOf(NetworkVariableBase) and IsSubclassOf use BaseType we’re forced to inherit directly from NetworkVariableBase

Context :

During a Unet to Netcode translation, i wanted to avoid the throw when setting a NetworkVariable from client since Unet was fine with this even in incorrect case. Inheriting from NetworkVariable just to override Value property seems a quick way for this.

Expected :

Either forbid this sealing NetworkVariable (and that’s fine) or allow it (changing IsSubClass for a IsAssignableFrom or kind of)

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
matthieu-blincommented, Feb 22, 2023

oh no don’t apology, if you can’t pinpoint the bug easily, either my explanations were not clear enough or i just make some dumb assumption (i just read the github code at that time, not retrieve it) or both !

So i performed some tests earlier this morning : can’t reproduce the issue despite i double and tripled checked first time before submitting.

First i assumed it was an issue with assembly/domain (since the report, we forked ngo into our repository). But don’t seems so.

Could also be in 1.1.0 or even 1.0.0 (just checked when you told me to, and can’t remember if i upgraded after report neither i can’t find the information due to multiple branching at that time )

Could also just be a timing issue : did i really check that object were spawn at that time ? Was i testing against the Unet time of variable registering ? Since i was in a middle of the migration , a lot of stuff were broken.

So anw, sorry for the time spend on this and thanks for your support. You can close this For others issue, i will provide a pull request btw with a basic sample code for you to test.

0reactions
NoelStephensUnitycommented, Feb 22, 2023

No worries at all. Thank you for checking this again on your side and confirming the issue does not occur in v1.2.0. Regarding future issues, it always helps to have some kind of code reference that replicates the issue. That would definitely help get faster response times and is a big help to us on this end! 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

NetworkVariables fail to initialize for inherited ancestor ...
I solved it by making a while loop and iterating up the class hierarchy until the NetworkBehavior class is reached: Code (CSharp):
Read more >
NetworkVariable | Unity Multiplayer Networking
Property must be defined within a NetworkBehaviour derived class ... You can't nest NetworkVariable s inside other NetworkVariable classes.
Read more >
MLAPI NetworkVariable not syncing on clients
If you have a NetworkVariable<T> not syncing, it could be any of the following: Make sure your class is inheriting from NetworkBehaviour ......
Read more >
NetworkVariable
A NetworkVariable 's value can only be set when: ... When a client first connects, it will be synchronized with the current value...
Read more >
Unity Netcode For Gameobject - Network Variables - YouTube
Otherwise, you can just listen and get how NetworkVariables are working 00:00 - Intro 00:19 - Network Prefab 02:23 - Network Variables 06:17 ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found