Skip to content

fix: NetworkBehaviours with inheritance are failing to sync public NetworkVariables#2417

Closed
JayPeet wants to merge 1 commit intoUnity-Technologies:developfrom
JayPeet:develop
Closed

fix: NetworkBehaviours with inheritance are failing to sync public NetworkVariables#2417
JayPeet wants to merge 1 commit intoUnity-Technologies:developfrom
JayPeet:develop

Conversation

@JayPeet
Copy link
Copy Markdown

@JayPeet JayPeet commented Feb 20, 2023

If you have a class

class A : NetworkBehaviour
{
    private NetworkVariable<int> TestA = new();
    public NetworkVariable<int> TestB = new();
}

and a subclass

class B : A
{
    public NetworkVariable<int> TestC = new();
}

When a NetworkObject with B attached is spawned, Only the private fields on the parent class A will be initialized correctly and sent across the network. TestA and TestC will send fine. TestB will not get its NetworkBehaviour set and wont send.

Testing and Documentation

  • No tests have been added. But we might be able to add a test to validate this situation?

@JayPeet JayPeet requested a review from a team as a code owner February 20, 2023 17:41
@JayPeet JayPeet changed the title Fixed NetworkBehaviours with inheritance from failing to sync public NetworkVariables fix: NetworkBehaviours with inheritance are failing to sync public NetworkVariables Feb 20, 2023
@0xFA11
Copy link
Copy Markdown
Contributor

0xFA11 commented Feb 24, 2023

thank you for finding the issue and offering a fix.
based on your PR, I did other required legwork (tests, changelog) with a bit of refactor and put it up for review.

so, this PR is superseded by #2423

@0xFA11 0xFA11 closed this Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants