Unity-Technologies/EntityComponentSystemSamples

Boids - Errors on player build

PitouGames opened this issue · 2 comments

I have errors when building the boids project for Windows.
I'm using Unity 2022.2.1f1 and made no script modification. Juste open the projet, add the "Boids" scene to build settings and build.

Errors:

Assets\Scripts\Systems\BoidSchoolSpawnSystem.cs(13,5): error SGICE002: This error indicates a bug in the DOTS source generators.

Assets\Scripts\Systems\BoidSchoolSpawnSystem.cs(13,5): error SGICE002: This error indicates a bug in the DOTS source generators. We'd appreciate a bug report (Help -> Report a Bug...). Thanks! Error message: 'System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.) |--| ---> System.NullReferenceException: Object reference not set to an instance of an object. |--| at Unity.Entities.SourceGen.Common.SymbolExtensions.ToFullName(ITypeSymbol symbol) |--| at Unity.Entities.SourceGen.SystemAPIQueryBuilder.SystemAPIQueryBuilderDescription.<>c.<.ctor>b__18_1(Query t) |--| at System.Linq.Enumerable.SelectArrayIterator2.MoveNext() |--| at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() |--| at System.String.Join(String separator, IEnumerable1 values) |--| at Unity.Entities.SourceGen.Common.EnumerableHelpers.SeparateByCommaAndSpace(IEnumerable1 lines) |--| at Unity.Entities.SourceGen.SystemAPIQueryBuilder.SystemAPIQueryBuilderDescription..ctor(SystemDescription systemDescription, QueryCandidate queryCandidate) |--| at Unity.Entities.SourceGen.SystemAPIQueryBuilder.SystemAPIQueryBuilderModule.RegisterChangesInSystem(SystemDescription systemDescription) |--| at Unity.Entities.SourceGen.SystemGenerator.SystemGenerator.<>c__DisplayClass2_1.b__1(SyntaxTree syntaxTree) |--| at System.Threading.Tasks.Parallel.<>c__DisplayClass44_02.<PartitionerForEachWorker>b__1(IEnumerator& partitionState, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) |--| --- End of stack trace from previous location --- |--| at System.Threading.Tasks.Parallel.<>c__DisplayClass44_02.b__1(IEnumerator& partitionState, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) |--| at System.Threading.Tasks.TaskReplicator.Replica1.ExecuteAction(Boolean& yieldedBeforeCompletion) |--| at System.Threading.Tasks.TaskReplicator.Replica.Execute() |--| --- End of inner exception stack trace --- |--| at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction1 action, ParallelOptions options, Boolean stopOnFirstFailure) |--| at System.Threading.Tasks.Parallel.PartitionerForEachWorker[TSource,TLocal](Partitioner1 source, ParallelOptions parallelOptions, Action1 simpleBody, Action2 bodyWithState, Action3 bodyWithStateAndIndex, Func4 bodyWithStateAndLocal, Func5 bodyWithEverything, Func1 localInit, Action1 localFinally) |--| --- End of stack trace from previous location --- |--| at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException) |--| at System.Threading.Tasks.Parallel.PartitionerForEachWorker[TSource,TLocal](Partitioner1 source, ParallelOptions parallelOptions, Action1 simpleBody, Action2 bodyWithState, Action3 bodyWithStateAndIndex, Func4 bodyWithStateAndLocal, Func5 bodyWithEverything, Func1 localInit, Action1 localFinally) |--| at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable1 source, ParallelOptions parallelOptions, Action1 body, Action2 bodyWithState, Action3 bodyWithStateAndIndex, Func4 bodyWithStateAndLocal, Func5 bodyWithEverything, Func1 localInit, Action1 localFinally) |--| at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable1 source, ParallelOptions parallelOptions, Action1 body) |--| at Unity.Entities.SourceGen.SystemGenerator.SystemGenerator.Execute(GeneratorExecutionContext context)'

  • Assets\Scripts\Systems\SampledAnimationClipPlaybackSystem.cs(34,66): error CS0246: The type or namespace name 'SampledAnimationClip' could not be found (are you missing a using directive or an assembly reference?)

  • Assets\Scripts\Systems\SampledAnimationClipPlaybackSystem.cs(55,37): error CS0246: The type or namespace name 'SampledAnimationClip' could not be found (are you missing a using directive or an assembly reference?)

  • Assets\Scripts\Systems\BoidSystem.cs(331,20): error CS0246: The type or namespace name 'Boid' could not be found (are you missing a using directive or an assembly reference?)

image

Playing in the editor has no problem.

Hello. The #if UNITY_EDITOR ... #endif is being too all-encompassing in the Authoring scripts causing the build issue. To solve it, limit the scope to only the BoidAuthoring, BoidObstacleAuthoring, BoidSchoolAuthoring, BoidTargetAuthoring and TransformRecorderAuthoring or extract the struct in a dedicated C# file.

In addition, I found it particularly intriguing to put the structure after its authoring.

Here is a patch for a temporary fix. You can apply it within your project using git apply BuildBoids.patch.
Note that I have switched the structure to be on top for more personal clarity.
BuildBoids.patch