MirrorNetworking / MirrorNetworking/Mirror

Setting a SyncVar in a Generic results in an error

Open
#3,654 5 comments 3 reactions 1 assignee View on GitHub

@miwarnec is already working on this.

Since Nov 17, 2023.

bug Weaver
Dominant language
C#
Stars
6.3k
Forks
870
PR merge metrics
No merged PRs in 30d

Description

public class Base<T> : NetworkBehaviour
{
    [SyncVar] public bool syncvar;
    public Base() { syncvar = true; }
}

results in the following error:

Modifying a [SyncVar] from another assembly is not supported. -- both assemblies printed in the error are the same assembly

despite the error, derived classes do seem to be working for my use case, the syncvar is set once in Start() on the host and connecting clients somehow see it, I guess because the value is still being serialized even though the setter isn't working

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.