CesiumGS / cesium-unity

Bringing the 3D geospatial ecosystem to Unity
https://cesium.com/platform/cesium-for-unity/
Apache License 2.0
348 stars 83 forks source link

Errors with Cesium for Unity package (created through developer guide) #433

Open j9liu opened 6 months ago

j9liu commented 6 months ago

From this forum post.

Following the developer guide, the user successfully produced a .tgz file, but ran into errors while importing in Package Manager:

Unity.SourceGenerators\Unity.MonoScriptGenerator.MonoScriptInfoGenerator\AssemblyMonoScriptTypes.gen.cs(5,20): error CS0101: The namespace ‘’ already contains a definition for ‘UnitySourceGeneratedAssemblyMonoScriptTypes_v1’

Unity.SourceGenerators\Unity.MonoScriptGenerator.MonoScriptInfoGenerator\AssemblyMonoScriptTypes.gen.cs(2,6): error CS0579: Duplicate ‘System.Runtime.CompilerServices.CompilerGenerated’ attribute

Unity.SourceGenerators\Unity.MonoScriptGenerator.MonoScriptInfoGenerator\AssemblyMonoScriptTypes.gen.cs(3,6): error CS0579: Duplicate ‘System.ComponentModel.EditorBrowsableAttribute’ attribute

Unity.SourceGenerators\Unity.MonoScriptGenerator.MonoScriptInfoGenerator\AssemblyMonoScriptTypes.gen.cs(4,6): error CS0579: Duplicate ‘System.CodeDom.Compiler.GeneratedCodeAttribute’ attribute

Unity.SourceGenerators\Unity.MonoScriptGenerator.MonoScriptInfoGenerator\AssemblyMonoScriptTypes.gen.cs(301,40): error CS0111: Type ‘UnitySourceGeneratedAssemblyMonoScriptTypes_v1’ already defines a member called ‘Get’ with the same parameter types

Unity.SourceGenerators\Unity.MonoScriptGenerator.MonoScriptInfoGenerator\AssemblyMonoScriptTypes.gen.cs(276,10): error CS0579: Duplicate ‘System.Runtime.InteropServices.StructLayout’ attribute

Another forum user responded with the following fix:

Fixed it by opening the tar.gz and the tar inside it and doing the following modifications:

com.cesium.unity-1.8.0\package\Editor\generated\Unity.SourceGenerators\Unity.MonoScriptGenerator.MonoScriptInfoGenerator\AssemblyMonoScriptTypes.gen.cs:

class UnitySourceGeneratedAssemblyMonoScriptTypes_v1 → UnitySourceGeneratedAssemblyMonoScriptTypes_v2 com.cesium.unity-1.8.0\package\Runtime\generated\Unity.SourceGenerators\Unity.MonoScriptGenerator.MonoScriptInfoGenerator\AssemblyMonoScriptTypes.gen.cs (there are 2 classes named UnitySourceGeneratedAssemblyMonoScriptTypes_v1):

class UnitySourceGeneratedAssemblyMonoScriptTypes_v1 → UnitySourceGeneratedAssemblyMonoScriptTypes_v3 class UnitySourceGeneratedAssemblyMonoScriptTypes_v1 → UnitySourceGeneratedAssemblyMonoScriptTypes_v4 After that do “Add package from disk…” in the Package Manager

kring commented 6 months ago

I think this is related to https://github.com/CesiumGS/cesium-unity/issues/156. If so, another workaround is to use Unity 2021.3 to package the plugin.