(IN-32600)(IN-18810) [1.0.0-pre.44] error NetCode: Index was out of range

Did official aware of this issue? If not I will try to file bug report. I just get this compile error for a project that I upgrade to 1.0.0-exp.8. it’s really weird tat I didn’t create dots2 folder that netcode tried to find the path that is not exists. :eyes: I tried to delete all the generated folders and files and reimport project still can’t solve this error.

C:\dots2\Packages\com.unity.netcode\Runtime\SourceGenerators\Source~\NetCodeSourceGenerator\Generators\NetCodeSourceGenerator.cs(95,1): error NetCode: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter ‘index’) at Unity.NetCode.Generators.NetCodeSourceGenerator.Generate(GeneratorExecutionContext executionContext, IDiagnosticReporter diagnostic)

mmm… I will try to do the same. But It is something that wasn’t known (at least not something I remember)

I submitted bug report IN-18810. You can check it out.

I think I know wat’s the issue. It’s the regression at 1.0.0-exp.8 that u can’t put GhostComponent attribute to the component anymore if it’s at package. It will just throw that compile error.

I didn’t quite follow. What you u mean you can’t put a GhostComponent attribute on a component if it is inside a package?
You can definitively do that if the package depends on NetCode.

Basically u create a custom package that u will see it at package manager and then u create component that has GhostComponent attribute. Previously before 1.0.0-exp.8 it’s working perfectly but now at 1.0.0-exp.8 it’s not working anymore.

can you share somehow more about how this package is setup?
We don’t have any specific reference to dots directory (even more to dots2) so I need to understand a little more.

If I do something like:

  • Crete a custom package into the Package folder
  • Add to the manifest a reference to netcode
  • Create an assembly definition into the new package and add also to this a reference to netcode.
  • Then create a component into it the assembly definition and a GhostAuthoringComponent to it.
  • Then create a component into package root and a GhostAuthoringComponent to it.

does this will match some how your current situation?

Last step is not correct I think. What I mean is create IComponentData and add something like [GhostComponent(PrefabType = GhostPrefabType.Server)] tag then u can see the compile error. You can quickly test this at bug report IN-18810.

@CMarastoni This bug still reproducible at 1.0.0-pre.44. I can provide the repro that updated to this latest release if u need it.

I will retry again. Or if you want to create another repro feel free to. I just downloaded the previous sample attached to the case. I will try it with 1.0-pre.44

IN-32600

Note that “dots2” is a red herring. It is the directory that the SourceGenerators was last built from. As I committed the SourceGenerators to the release branch last, it is the path of my dots repo.

Ok, problem found. Will fix in ASAP. As a workaround (fastest) just add Transport as dependency to that package.

1 Like