Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity cannot recognize some .cs files after pulling a project from git

I am currently developing a project using Unity 2020.3.3f1. I use git version control system and store my project in a Bitbucket repository. When I clone / pull my project to another computer (especially with macos) some of my cs. files are displayed as an unknown file` (not a script) in the project view, and some other classes cannot find the class defined on that file. When I right click and select "reimport" the cs file, recovered immediately and I build successfully.

This causes me a problem when I try to build my project through Unity Cloud build, because I get an error about some missing classes which are indeed there.

[Unity] Initialize engine version: 2020.3.6f1 (338bb68529b2)
3: [Unity] -----CompilerOutput:-stdout--exitcode: 1--compilationhadfailure: True--outfile: Temp/ToonyColorsPro.Editor.dll
4: [Unity] Assets/JMO Assets/Toony Colors Pro/Editor/Shader Generator/Config.cs(192,13): error CS0246: The type or namespace name 'MaterialLayer' could not be found (are you missing a using directive or an assembly reference?)
5: [Unity] Assets/JMO Assets/Toony Colors Pro/Editor/Shader Generator/ShaderProperty.cs(417,40): error CS0246: The type or namespace name 'MaterialLayer' could not be found (are you missing a using directive or an assembly reference?)
6: [Unity] Assets/JMO Assets/Toony Colors Pro/Editor/Shader Generator/Config.cs(173,59): error CS0246: The type or namespace name 'MaterialLayer' could not be found (are you missing a using directive or an assembly reference?)
7: [Unity] Assets/JMO Assets/Toony Colors Pro/Editor/Shader Generator/Config.cs(192,13): error CS0246: The type or namespace name 'MaterialLayer' could not be found (are you missing a using directive or an assembly reference?)
8: [Unity] Assets/JMO Assets/Toony Colors Pro/Editor/Shader Generator/ShaderProperty.cs(417,40): error CS0246: The type or namespace name 'MaterialLayer' could not be found (are you missing a using directive or an assembly reference?)
9: [Unity] Assets/JMO Assets/Toony Colors Pro/Editor/Shader Generator/Config.cs(173,59): error CS0246: The type or namespace name 'MaterialLayer' could not be found (are you missing a using directive or an assembly reference?)
10: ! build of 'default-ios-ad-hoc' failed. exit
11: publishing finished successfully.
12: Finished: FAILURE

After that I tried pulling the project from a Mac device, the project also could not recognize the same MaterialLayer.cs. I easily recovered using "reimport". My project settings / Asset Serialization : Force Text and "Version Control / Visible Meta Files" are already set.

like image 621
fercis Avatar asked May 01 '21 01:05

fercis


2 Answers

It's a long shot and I write answer only because I can attach image here:

Every file in C# solution has properties:

enter image description here

So my suggestion is to double check if those "missing", "unknown" .cs files have same properties set as those .cs files, which are recoginzed correctly.

like image 56
Michał Turczyn Avatar answered Oct 19 '22 13:10

Michał Turczyn


If you using LFS on git then this issue sometimes happens when LFS pulled with a bug or metafiles was broken during pulling files, please double check your .gitattributes. It's possible that the merge option for .meta was wrongly assigned. I'm using this .gitattributes for my projects, still no issues with this.

like image 1
Arcueid D'athemon Avatar answered Oct 19 '22 14:10

Arcueid D'athemon