`GenerateAuthoringComponent` Currently Broken in 0.51 Entities

When using Unity LTS21 and Entities 0.51, even making a Tag IComponentData, GenerateAuthoringComponent crashes the DOTS compiler and shows roughly this in the error log:

* *error SGICE004: Seeing this error indicates a bug in the dots compiler. We'd appreciate a bug report (About->Report a Bug...). Thnx! <3 System.IO.IOException: Cannot create '{ProjectPath}\Temp\GeneratedCode\Assembly-CSharp' because a file or directory with the same name already exists.* *

Example code that breaks the compiler:

using Unity.Entities;

[GenerateAuthoringComponent]
public struct PlayerTag :IComponentData { }
1 Like

Seeing this error constantly, but seemingly randomly when my code is recompiled.

I kept getting this as well, so I made this helper. If you place it in an Editor folder and hit Ctrl+Alt+R it will remove the GeneratedSource folder from the temp directory and then recompile. Fixes it right up for me.

Notice: make sure to look it over first and are comfortable with what it is doing before you run it, as it does delete a folder. Better safe than sorry.

5 Likes

Im having the same issue. Most hated I tried your helper tool and it’s still not working for me :frowning:

Looks like we’ll need to use the ECS generated “runtime authoring component” in the create menu.

That creates a new component. I have not tried creating any new ones in 0.51 yet, I have only had issues with existing components on occasion, which removing the GeneratedCode folder and recreating it by recompiling has worked every time for me so far. Strange that it didn’t work for you. It just had the exact same error as before running it? I suppose it’s possible that whatever occurred that makes it happen in the first place simply happened again.

I’ve got the same problem. I moved today from a mac to a windows machine, and started getting this error:

<file>: error SGICE004: Seeing this error indicates a bug in the dots compiler. We'd appreciate a bug report (About->Report a Bug...). Thnx! <3 System.IO.IOException: Cannot create '<corresponding temp-file>' because a file or directory with the same name already exists.

the component it’s complaining about does not have a GenerateAuthoringComponent tag. The only workaround I’ve found is to delete the temp folder and trigger a compilation. That would be ok-ish, if it was not happening quite frequently.

I’m on entities-0.51 and 2021.3.5f1. To repeat, tI never so this error in the mac editor.

Is there anything better I can do?

Can you share more information than these errors, a callstack would help us look into this. @Soaryn I believe you already submitted a bug with the full logs so our team may already be investigating. Thank you!

Sorry, replied and deleted it by mistake.
The error is not happening anymore. I don’t know why. I tried re-importing assets, and deleting Temp and Library but nothing helped. At some point, it just stopped happening. The Unity editor can do amazing things but needs a bit of work in terms of hermetic and repeatable builds. This sort of inconsistent behavior makes it very difficult to isolate and report bugs. In most cases is prohibitively time-consuming. Also, my project now is several GBs large, I wouldn’t upload it for a bug report (not sure if I can even do that).

It might help if there was a “capture bug” mode that does extra logging that will allow users to file bugs easier, even at the expense of editor speed. If I could enable this mode and then push a bug report with a description to unity, I would push much more feedback.

I had the same error today, I created a new script and added references for “Unity.Physics”, “Unity.Physics.Hybrid” and “Unity.Mathematics” to my asmdef. After I deleted the script and the references, it worked again.
I then added the script and references again and this time had no more problems.

On my first try I added the script, after compilation errors the references.

What I noticed was that within “Temp\Generated Code” a file was created with the assambly name, but when it worked again it was a folder.

1 Like

I had the same error, but found a way to fix it.

When the error accrued, I had the Hybrid Renderer not installed. Installing it and restarting the project fixed the problem.

I got this error today:

I hadn’t edited that SimpleCameraController file, however I did edit some existing components to have the GenerateAuthoringComponent attribute on them. Those components were originally regular MonoBehaviours, manually edited to be components, and then later manually edited to have the GAC attribute.

All of the components are namespaced in a nested namespace, but I didn’t think much of it - but it made me think about what is public and private in those components.

Specifically, one component was using get/set syntax in its code. There are variables that are private when you use get/set syntax, and when I restarted the Unity Editor I got an error related to the protection level of those private variables. It was like the codegen couldn’t do anything with the private variables.

After rewriting that component to not use get/set syntax, I restarted the Unity Editor and no errors appear any more. No protection level errors, no SGICE004 errors. All is well! Play mode works fine, too.

However, when I edit one of the components and cause a recompile in the project, I get this warning:

I just closed the editor, deleted my project’s library folder, and reopened the editor. All works! No errors or warnings!
I closed and reopened the editor again to be sure - all still works! No errors or warnings!
I edited one of the components again, also to be sure - I get the SGICE006 warning again.

The SGICE006 warning isn’t a blocking warning, so that’s nice. I can keep on working.
I hope my lil journal of what happened when I got hit by SGICE004 helps!

Ah, nevermind - I edited a component again and now I have that SGICE004 on some of the other files again.

I even tried deleting the SimpleCameraController that came with the project, and then the SGICE004 error moved on to the “tutorial” readme.cs file that came with the URP project template. I deleted that too, and now the SGICE004 error is on my project scripts. Can’t exactly delete those.

Comparing to other experiences in this thread:

  • I have Hybrid Renderer installed
  • The Temp/GeneratedCode directory is a directory
  • I’m not using asmdef files
  • I’m using DOTS 0.51 and 2021.3.5f1
  • Deleting the Temp/GeneratedCode directory and editing a script to regenerate it did not remove the error

I then went through all of my DOTS-relevant scripts and removed any unused using statements. That has removed the error for now.

When I restarted the Unity editor and edited a script to be sure, I got the SGICE006 warning on one of my DOTS-relevant scripts. So the blocking error is gone for now, the warning is on a different file, but I can keep on working again.

Nothing about this error is consistent to me.

EDIT: Nevermind nevermind. The SGICE004 error is back on another of my DOTS-relevant files after I edited a different DOTS-relevant file. So still no method to the madness that I can see, just gonna file a bug report and hope Unity can handle this internally. So much for logging a journey to a solution on the forums!

I switched to 2021.3.6f1 the other day, and I can’t say I recall having this issue since then. If I did and just didn’t notice, it was has definitely been less often.

You can just delete the file and it should be fine.

Okay, seems like that worked for me by coincidence, still might work for some people though.

Edit: Okay, found the edit button, lol. Turns out you need to remove the whole folder not just the offending file.