Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Issues with Terrain Asset files and general git issues.

Discussion in 'Editor & General Support' started by Jbaker08, Nov 3, 2020.

  1. Jbaker08

    Jbaker08

    Joined:
    Oct 8, 2012
    Posts:
    52
    Hi,
    Were having some pretty bad issues using git and tortoise svn with Unity. Firstly, I've followed all tutorials and steps to get git lfs to work with our project. But the same issues remain no matter what I do.

    Firstly, when somebody clones the project, tortoise svn/git immediately thinks that person has modified or changed files. When they goto commit, theres a long list of .meta files and others that say they've been modified when they definitely have not.

    Secondly, our terrain asset files just dont seem to work at all. I can see them fine on my project (master project) but when I commit and push them, they appear missing to people who have pulled them. What could be causing these issues?

    I have attached our gitignore file and gitattributes

    GitIgnore

    Code (CSharp):
    1. # required ignores for the Unity Temp and build folders
    2. /Temp
    3. /Export
    4. /lfs
    5. /hooks
    6. /Assets/GPUInstancer/Resources/Settings/GPUIShaderVariantCollection.shadervariants
    7.  
    8. # ignore all of the Library folder EXCEPT for the build and project settings.
    9. /Library/**
    10. !/Library/BuildSettings.asset
    11. !/Library/ProjectSettings.asset
    12.  
    13. # any project specific ignores.
    14. **UnityVS**
    15. Assembly-CSharp-Editor-vs.csproj
    16. Assembly-CSharp-Editor.csproj
    17. Assembly-CSharp-firstpass-vs.csproj
    18. Assembly-CSharp-firstpass.csproj
    19. Assembly-CSharp-vs.csproj
    20. Assembly-CSharp.csproj
    21. Assembly-UnityScript-Editor-vs.unityproj
    22. Assembly-UnityScript-Editor.unityproj
    23. Assembly-UnityScript-vs.unityproj
    24. Assembly-UnityScript.unityproj
    25. popcorn.htm
    26. /.vs/**
    27. **.csproj
    28. **.sln
    29. **.cache
    30.  
    31.  
    32.  
    33. # This .gitignore file should be placed at the root of your Unity project directory
    34. #
    35. # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
    36. #
    37. /[Ll]ibrary/
    38. /[Tt]emp/
    39. /[Oo]bj/
    40. /[Bb]uild/
    41. /[Bb]uilds/
    42. /[Ll]ogs/
    43. /[Uu]ser[Ss]ettings/
    44.  
    45. # MemoryCaptures can get excessive in size.
    46. # They also could contain extremely sensitive data
    47. /[Mm]emoryCaptures/
    48.  
    49. # Asset meta data should only be ignored when the corresponding asset is also ignored
    50. !/[Aa]ssets/**/*.meta
    51.  
    52. # Uncomment this line if you wish to ignore the asset store tools plugin
    53. # /[Aa]ssets/AssetStoreTools*
    54.  
    55. # Autogenerated Jetbrains Rider plugin
    56. /[Aa]ssets/Plugins/Editor/JetBrains*
    57.  
    58. # Visual Studio cache directory
    59. .vs/
    60.  
    61. # Gradle cache directory
    62. .gradle/
    63.  
    64. # Autogenerated VS/MD/Consulo solution and project files
    65. ExportedObj/
    66. .consulo/
    67. *.csproj
    68. *.unityproj
    69. *.sln
    70. *.suo
    71. *.tmp
    72. *.user
    73. *.userprefs
    74. *.pidb
    75. *.booproj
    76. *.svd
    77. *.pdb
    78. *.mdb
    79. *.opendb
    80. *.VC.db
    81.  
    82. # Unity3D generated meta files
    83. *.pidb.meta
    84. *.pdb.meta
    85. *.mdb.meta
    86.  
    87. # Unity3D generated file on crash reports
    88. sysinfo.txt
    89.  
    90. # Builds
    91. *.apk
    92. *.aab
    93. *.unitypackage
    94.  
    95. # Crashlytics generated file
    96. crashlytics-build.properties
    97.  
    98. # Packed Addressables
    99. /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
    100.  
    101. # Temporary auto-generated Android Assets
    102. /[Aa]ssets/[Ss]treamingAssets/aa.meta
    103. /[Aa]ssets/[Ss]treamingAssets/aa/*

    Gitattributes:

    Code (CSharp):
    1. ## Unity ##
    2.  
    3. *.cs diff=csharp text
    4. *.cginc text
    5. *.shader text
    6.  
    7. *.mat                     merge=unityyamlmerge eol=lf
    8. *.anim                     merge=unityyamlmerge eol=lf
    9. *.unity                 merge=unityyamlmerge eol=lf
    10. *.prefab                 merge=unityyamlmerge eol=lf
    11. *.physicsMaterial2D     merge=unityyamlmerge eol=lf
    12. *.physicMaterial         merge=unityyamlmerge eol=lf
    13. *.physicmaterial         merge=unityyamlmerge eol=lf
    14. *.asset                 merge=unityyamlmerge eol=lf
    15. *.meta                     merge=unityyamlmerge eol=lf
    16. *.controller            merge=unityyamlmerge eol=lf
    17.  
    18. *.compute                merge=unityyamlmerge eol=lf
    19. *.txt                    merge=unityyamlmerge eol=lf
    20. *.htm                    merge=unityyamlmerge eol=lf
    21. *.html                    merge=unityyamlmerge eol=lf
    22. *.xml                    merge=unityyamlmerge eol=lf
    23. *.XML                    merge=unityyamlmerge eol=lf
    24. *.js                    merge=unityyamlmerge eol=lf
    25. *.flare                    merge=unityyamlmerge eol=lf
    26. *.giparams                merge=unityyamlmerge eol=lf
    27. *.playable                merge=unityyamlmerge eol=lf
    28. *.guiskin                merge=unityyamlmerge eol=lf
    29. *.GUISkin                merge=unityyamlmerge eol=lf
    30. *.json                    merge=unityyamlmerge eol=lf
    31. *.asmdef                merge=unityyamlmerge eol=lf
    32. *.csv                    merge=unityyamlmerge eol=lf
    33. *.shader_backup            merge=unityyamlmerge eol=lf
    34. *.sbs                    merge=unityyamlmerge eol=lf
    35. *.mixer                    merge=unityyamlmerge eol=lf
    36. *.overrideController    merge=unityyamlmerge eol=lf
    37. *.tps                    merge=unityyamlmerge eol=lf
    38. *.tpsheet                merge=unityyamlmerge eol=lf
    39. *.fontsettings            merge=unityyamlmerge eol=lf
    40. *.ms                    merge=unityyamlmerge eol=lf
    41. *.ini                    merge=unityyamlmerge eol=lf
    42. *.orig                     merge=unityyamlmerge eol=lf
    43. *.xgen                     merge=unityyamlmerge eol=lf
    44. *.bat                     merge=unityyamlmerge eol=lf
    45. *.mon                     merge=unityyamlmerge eol=lf
    46. *.h                        merge=unityyamlmerge eol=lf
    47. *.dict                    merge=unityyamlmerge eol=lf
    48. *.params                merge=unityyamlmerge eol=lf
    49. *.cfg                    merge=unityyamlmerge eol=lf
    50. *.pkan                    merge=unityyamlmerge eol=lf
    51. *.pkfx                    merge=unityyamlmerge eol=lf
    52. *.pkat                    merge=unityyamlmerge eol=lf
    53. *.url                    merge=unityyamlmerge eol=lf
    54. *.css                     merge=unityyamlmerge eol=lf
    55. *.terrainlayer            merge=unityyamlmerge eol=lf
    56. *.er3d                    merge=unityyamlmerge eol=lf
    57. *-[Tt]errain.asset -unityyaml lfs
    58. *-[Nn]av[Mm]esh.asset -unityyaml lfs
    59.  
    60.  
    61.  
    62.  
    63. ## git-lfs ##
    64.  
    65. ## Possible solution to track terrain .asset files (adjust path & uncomment)
    66. # /Assets/Terrains/*.asset filter=lfs diff=lfs merge=lfs -text
    67. # #only if subfolders with terrains exist:
    68. # /Assets/Terrains/**/*.asset filter=lfs diff=lfs merge=lfs -text
    69.  
    70.  
    71. #Image
    72. *.jpg    filter=lfs diff=lfs merge=lfs -text
    73. *.jpeg    filter=lfs diff=lfs merge=lfs -text
    74. *.png    filter=lfs diff=lfs merge=lfs -text
    75. *.Png    filter=lfs diff=lfs merge=lfs -text
    76. *.PNG    filter=lfs diff=lfs merge=lfs -text
    77. *.tif    filter=lfs diff=lfs merge=lfs -text
    78. *.gif    filter=lfs diff=lfs merge=lfs -text
    79. *.psd    filter=lfs diff=lfs merge=lfs -text
    80. *.ai    filter=lfs diff=lfs merge=lfs -text
    81.  
    82. *.tga    filter=lfs diff=lfs merge=lfs -text
    83. *.TGA    filter=lfs diff=lfs merge=lfs -text
    84. *.dds    filter=lfs diff=lfs merge=lfs -text
    85. *.TIF    filter=lfs diff=lfs merge=lfs -text
    86. *.bmp    filter=lfs diff=lfs merge=lfs -text
    87.  
    88. #Audio
    89. *.mp3    filter=lfs diff=lfs merge=lfs -text
    90. *.MP3    filter=lfs diff=lfs merge=lfs -text
    91. *.wav    filter=lfs diff=lfs merge=lfs -text
    92. *.ogg    filter=lfs diff=lfs merge=lfs -text
    93. *.aif    filter=lfs diff=lfs merge=lfs -text
    94. *.aiff    filter=lfs diff=lfs merge=lfs -text
    95.  
    96. #Video
    97. *.mp4    filter=lfs diff=lfs merge=lfs -text
    98. *.mov    filter=lfs diff=lfs merge=lfs -text
    99.  
    100. #3D Object
    101. *.FBX    filter=lfs diff=lfs merge=lfs -text
    102. *.fbx    filter=lfs diff=lfs merge=lfs -text
    103. *.blend    filter=lfs diff=lfs merge=lfs -text
    104. *.obj    filter=lfs diff=lfs merge=lfs -text
    105. *.OBJ    filter=lfs diff=lfs merge=lfs -text
    106. *.objb    filter=lfs diff=lfs merge=lfs -text
    107.  
    108. #ETC
    109. *.a            filter=lfs diff=lfs merge=lfs -text
    110. *.exr        filter=lfs diff=lfs merge=lfs -text
    111. *.pdf        filter=lfs diff=lfs merge=lfs -text
    112. *.zip        filter=lfs diff=lfs merge=lfs -text
    113. *.dll        filter=lfs diff=lfs merge=lfs -text
    114.  
    115. *.unitypackage filter=lfs diff=lfs merge=lfs -text
    116.  
    117. *.aif        filter=lfs diff=lfs merge=lfs -text
    118. *.ttf        filter=lfs diff=lfs merge=lfs -text
    119. *.rns        filter=lfs diff=lfs merge=lfs -text
    120. *.reason    filter=lfs diff=lfs merge=lfs -text
    121. *.lxo         filter=lfs diff=lfs merge=lfs -text
    122. *.cubemap    filter=lfs diff=lfs merge=lfs -text
    123.  
    124. *.shadervariants     filter=lfs    diff=lfs merge=lfs -text
    125. *.rtf                 filter=lfs    diff=lfs merge=lfs -text
    126. *.otf                 filter=lfs    diff=lfs merge=lfs -text
    127. *.exe                 filter=lfs    diff=lfs merge=lfs -text
    128. *.doc                 filter=lfs    diff=lfs merge=lfs -text
    129. *.bin                 filter=lfs    diff=lfs merge=lfs -text
    130. *.sdkmesh             filter=lfs    diff=lfs merge=lfs -text
    131. *.sdkmesh_anim         filter=lfs    diff=lfs merge=lfs -text
    132. *.max                filter=lfs     diff=lfs merge=lfs -text
    133. *.mtl                filter=lfs     diff=lfs merge=lfs -text
    134. *.7z                filter=lfs     diff=lfs merge=lfs -text
    135. *.dae                filter=lfs     diff=lfs merge=lfs -text
    136. *.renderTexture     filter=lfs    diff=lfs merge=lfs -text
    137. *.db                 filter=lfs     diff=lfs merge=lfs -text
    138. *.bundle            filter=lfs    diff=lfs merge=lfs -text
    139. *.dll                filter=lfs    diff=lfs merge=lfs -text
    140. *.a                    filter=lfs    diff=lfs merge=lfs -text
    141. *.so                filter=lfs    diff=lfs merge=lfs -text
    142. *.dylib                filter=lfs    diff=lfs merge=lfs -text
    143. *.plist                filter=lfs    diff=lfs merge=lfs -text
    144. *.sbsar                filter=lfs    diff=lfs merge=lfs -text
    145. *.Engine            filter=lfs    diff=lfs merge=lfs -text
    146. *.rar                filter=lfs    diff=lfs merge=lfs -text
    147. *.spm                filter=lfs    diff=lfs merge=lfs -text
    148. *.md                filter=lfs    diff=lfs merge=lfs -text
    149. *.tsv                filter=lfs    diff=lfs merge=lfs -text
    150. *.aup                filter=lfs    diff=lfs merge=lfs -text
    151. *.au                filter=lfs    diff=lfs merge=lfs -text
    152. *.hdr                filter=lfs    diff=lfs merge=lfs -text
    153. *.jas                filter=lfs    diff=lfs merge=lfs -text
    154. *.resources            filter=lfs    diff=lfs merge=lfs -text
    155. *.bytes                filter=lfs    diff=lfs merge=lfs -text
    156. *.mb                filter=lfs    diff=lfs merge=lfs -text
    157. *.skp                filter=lfs    diff=lfs merge=lfs -text
    158. *.skb                filter=lfs    diff=lfs merge=lfs -text
    159. *.mask                filter=lfs    diff=lfs merge=lfs -text
    160. *.swatch            filter=lfs    diff=lfs merge=lfs -text
    161. *.raw                filter=lfs    diff=lfs merge=lfs -text
    162. *.Raw                filter=lfs    diff=lfs merge=lfs -text
    163. *.pwcfg                filter=lfs    diff=lfs merge=lfs -text
    164. *.pwlpk                filter=lfs    diff=lfs merge=lfs -text
    165. *.odt                filter=lfs    diff=lfs merge=lfs -text
    166. *.pkkg                filter=lfs    diff=lfs merge=lfs -text
    167. *.mr                filter=lfs    diff=lfs merge=lfs -text
    168. *.pkmm                filter=lfs    diff=lfs merge=lfs -text
    169. *.sign                filter=lfs    diff=lfs merge=lfs -text
    170. *.mdb                filter=lfs    diff=lfs merge=lfs -text
    171. *.bak                filter=lfs    diff=lfs merge=lfs -text
    172. *.backup            filter=lfs    diff=lfs merge=lfs -text
    173. *.cache                filter=lfs    diff=lfs merge=lfs -text
    174. *.log                filter=lfs    diff=lfs merge=lfs -text
    175.  
    176.  
    177.  
    178.  
    179.  
    180.  
    181.  
    182.  
    183. *.cs diff=csharp text
    184. *.cginc text
    185. *.shader text
    186.  
    187. *.mat merge=unityyamlmerge eol=lf
    188. *.anim merge=unityyamlmerge eol=lf
    189. *.unity merge=unityyamlmerge eol=lf
    190. *.prefab merge=unityyamlmerge eol=lf
    191. *.physicsMaterial2D merge=unityyamlmerge eol=lf
    192. *.physicsMaterial merge=unityyamlmerge eol=lf
    193. *.asset merge=unityyamlmerge eol=lf
    194. *.meta merge=unityyamlmerge eol=lf
    195. *.controller merge=unityyamlmerge eol=lf
    196.  
    197. *.a filter=lfs diff=lfs merge=lfs -text
    198. *.mp3 filter=lfs diff=lfs merge=lfs -text
    199. *.wav filter=lfs diff=lfs merge=lfs -text
    200. *.aif filter=lfs diff=lfs merge=lfs -text
    201. *.ttf filter=lfs diff=lfs merge=lfs -text
    202. *.png filter=lfs diff=lfs merge=lfs -text
    203. *.jpg filter=lfs diff=lfs merge=lfs -text
    204. *.exr filter=lfs diff=lfs merge=lfs -text
    205. *.fbx filter=lfs diff=lfs merge=lfs -text
    206. *.FBX filter=lfs diff=lfs merge=lfs -text
    207. *.rns filter=lfs diff=lfs merge=lfs -text
    208. *.reason filter=lfs diff=lfs merge=lfs -text
    209. *.lxo filter=lfs diff=lfs merge=lfs -text
    210.  
    211.  
    212.  
    If anybody has any idea, that would really help me out here as right now, our team can't really edit environments as the terrains are seemingly invisible.

    Thanks
     
    MrStijket likes this.
  2. niallmc

    niallmc

    Joined:
    Sep 3, 2015
    Posts:
    44
    Bump

    we're having the same problems using git-lfs, proving to be a nightmare

    Have you had any progress with this? Sorry I don't have an answer.
     
    MrStijket likes this.
  3. CelestialShark

    CelestialShark

    Joined:
    Nov 20, 2021
    Posts:
    11
  4. mythicgaming234

    mythicgaming234

    Joined:
    May 27, 2019
    Posts:
    1
    bump please
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,780
    What you report is identical behavior to what happens when you fail to source control ALL that you should source control, or perhaps source control too much.

    For instance, I have NEVER source controlled anything in the Library folder, as outlined in Unity best practices, yet the above looks like maybe you are committing from Library.

    The above seems a rather wordy gitignore with some pattern matching I've never bothered with. I also have never bothered with a gitattributes file and we gave up on the YAML merge stuff as being unreliable.

    PROPERLY CONFIGURING AND USING ENTERPRISE SOURCE CONTROL

    I'm sorry you've had this issue. Please consider using proper industrial-grade enterprise-qualified source control in order to guard and protect your hard-earned work.

    Personally I use git (completely outside of Unity) because it is free and there are tons of tutorials out there to help you set it up as well as free places to host your repo (BitBucket, Github, Gitlab, etc.).

    You can also push git repositories to other drives: thumb drives, USB drives, network drives, etc., effectively putting a complete copy of the repository there.

    As far as configuring Unity to play nice with git, keep this in mind:

    https://forum.unity.com/threads/prefab-links-keep-getting-dumped-on-git-pull.646600/#post-7142306

    I usually make a separate repository for each game, but I have some repositories with a bunch of smaller test games.

    Here is how I use git in one of my games, Jetpack Kurt:

    https://forum.unity.com/threads/2-steps-backwards.965048/#post-6282497

    Using fine-grained source control as you work to refine your engineering:

    https://forum.unity.com/threads/whe...grammer-example-in-text.1048739/#post-6783740

    Share/Sharing source code between projects:

    https://forum.unity.com/threads/your-techniques-to-share-code-between-projects.575959/#post-3835837

    Setting up an appropriate .gitignore file for Unity3D:

    https://forum.unity.com/threads/removing-il2cpp_cache-from-project.1084607/#post-6997067

    Generally the ONLY folders you should ever source control are:

    Assets/
    ProjectSettings/
    Packages/

    NEVER source control Library/ or Temp/ or Logs/
    NEVER source control anything from Visual Studio (.vs, .csproj, none of that noise)

    Setting git up with Unity (includes above .gitignore concepts):

    https://thoughtbot.com/blog/how-to-git-with-unity

    It is only simple economics that you must expend as much effort into backing it up as you feel the work is worth in the first place. Digital storage is so unbelievably cheap today that you can buy gigabytes of flash drive storage for about the price of a cup of coffee. It's simply ridiculous not to back up.

    If you plan on joining the software industry, you will be required and expected to know how to use source control.

    "Use source control or you will be really sad sooner or later." - StarManta on the Unity3D forum boards
     
  6. DifinityRelin

    DifinityRelin

    Joined:
    Aug 9, 2021
    Posts:
    6
    The issue is that Unity is calling the Terrain Data files .asset files even though they don't use the YAML file format. That's a problem because of the line
    Code (CSharp):
    1. *.asset                 merge=unityyamlmerge eol=lf
    in your .gitattributes file. The "solution" we came up with was to add
    Code (CSharp):
    1. *.terrain.asset binary
    at the top of that block and rename our terrain data files to use .terrain.asset instead of just .asset. This allows them to just be treated as just binary files.

    Apparently, you might also have to do this for lighting data and navmesh data files since they don't use the YAML file format either.

    The REAL solution would be for Unity to NOT give these files .asset extensions; but good luck with that one...
     
  7. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    227
    Yeah, but unfortunately for lighting data, if you rename the file, it breaks.
     
  8. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,780
    If you rename the file outside of Unity, it will likely break linkages.



    SCRIPTS OR ASSETS ARE MISSING OR BLANK

    ALWAYS rename / move all Unity assets by using the Unity Editor. Any other way risks disconnecting the GUID in the meta file from the original file, and this will result in all connections to that asset being broken.

    Some info about Missing script warnings, broken prefabs, GUIDs, renaming GUIDs, etc:

    https://forum.unity.com/threads/problem-with-git-and-missing-scripts.1090876/#post-7024801
    https://forum.unity.com/threads/scr...ead-after-loading-editor.998413/#post-6487297
    https://forum.unity.com/threads/scr...ead-after-loading-editor.998413/#post-6488230

    EVERYTHING in Unity is connected to the above GUID, which is stored ONLY in the metafile, and hence why the metafiles ALWAYS MUST be source-controlled.

    When Renaming: It is super-easy to inadvertently change the GUID by renaming outside of Unity. Don't do that. Instead:

    - close Visual Studio (important!)
    - rename the file(s) in Unity
    - in Unity do Assets -> Open C# Project to reopen Visual Studio
    - now rename the actual classes, and MAKE SURE THE FILE NAMES DO NOT CHANGE!

    If you are NOT using source control (see below for how to set up source control!) while you do this, renaming files is an EXTREMELY dangerous process. Use source control at all times so that you can trivially revert if you miss a critical step and damage your project.



    Otherwise...

    Please don't necro-post. If you have a new question, make a new post. It's FREE!!




    How to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    This is the bare minimum of information to report:

    - what you want
    - what you tried
    - what you expected to happen
    - what actually happened, log output, variable values, and especially any errors you see
    - links to documentation you used to cross-check your work (CRITICAL!!!)

    The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven't put effort into finding the documentation, why should we bother putting effort into replying?



    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/

    - Do not TALK about code without posting it.
    - Do NOT post unformatted code.
    - Do NOT retype code. Use copy/paste properly using code tags.
    - Do NOT post screenshots of code.
    - Do NOT post photographs of code.
    - ONLY post the relevant code, and then refer to it in your discussion.




    PROPERLY CONFIGURING AND USING ENTERPRISE SOURCE CONTROL

    I'm sorry you've had this issue. Please consider using proper industrial-grade enterprise-qualified source control in order to guard and protect your hard-earned work.

    Personally I use git (completely outside of Unity) because it is free and there are tons of tutorials out there to help you set it up as well as free places to host your repo (BitBucket, Github, Gitlab, etc.).

    You can also push git repositories to other drives: thumb drives, USB drives, network drives, etc., effectively putting a complete copy of the repository there.

    As far as configuring Unity to play nice with git, keep this in mind:

    https://forum.unity.com/threads/prefab-links-keep-getting-dumped-on-git-pull.646600/#post-7142306

    I usually make a separate repository for each game, but I have some repositories with a bunch of smaller test games.

    Here is how I use git in one of my games, Jetpack Kurt:

    https://forum.unity.com/threads/2-steps-backwards.965048/#post-6282497

    Using fine-grained source control as you work to refine your engineering:

    https://forum.unity.com/threads/whe...grammer-example-in-text.1048739/#post-6783740

    Share/Sharing source code between projects:

    https://forum.unity.com/threads/your-techniques-to-share-code-between-projects.575959/#post-3835837

    Setting up an appropriate .gitignore file for Unity3D:

    https://forum.unity.com/threads/removing-il2cpp_cache-from-project.1084607/#post-6997067

    Generally the ONLY folders you should ever source control are:

    Assets/
    ProjectSettings/
    Packages/

    NEVER source control Library/ or Temp/ or Logs/
    NEVER source control anything from Visual Studio (.vs, .csproj, none of that noise)

    Setting git up with Unity (includes above .gitignore concepts):

    https://thoughtbot.com/blog/how-to-git-with-unity

    It is only simple economics that you must expend as much effort into backing it up as you feel the work is worth in the first place. Digital storage is so unbelievably cheap today that you can buy gigabytes of flash drive storage for about the price of a cup of coffee. It's simply ridiculous not to back up.

    If you plan on joining the software industry, you will be required and expected to know how to use source control.

    "Use source control or you will be really sad sooner or later." - StarManta on the Unity3D forum boards
     
  9. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    227
    1- I renamed the LightingData.asset inside the editor and no VS was open. But it still breaks the lighting in the scene. It's like intensity gets cranked up. All MeshRenderers in the scene still reference the right lightmaps and the scene has a link to the right, but now renamed, lighting data asset. But the lighting is wrong. Also rebaking just recreates the default asset with the default name. So no, renaming doesn't help you, at the very least for lighting, unless you know something more specific about the process for LightingData.

    2- The topic is very specific, so most of what you said about git is unnecessary.

    To give a bit of context, Unity has made this annoying mistake of lumping together 3 types of binary assets with a .asset extension, with every other .asset that's Yaml. Any kind of ScriptableObject, for example, is YAML underneath (as are most of the other file formats like .prefab, .unity, .material etc) and for git diff purposes you define it as text. Sometimes git clients pick up on text without the attribute but it's usually better if they are well defined.

    The problem stems from something called End-of-line conversion which converts eol characters for text files depending on OS. Usually new git repos have a flag enabled by default called core.autocrlf and git auto-converts eol characters whenever you try to see a diff somewhere. You can ofc disable it, but then you'll have to convert manually in the editor and you'll constantly get files being changed if you have people using Mac and Windows in the same repo. Both annoying in their own right.

    Specifically TerrainData, LightingData and NavMesh are all binary .asset files, contrary to every other .asset file which should be treated as text. It's easy to get into a situation where diff corrupts the binary due to auto-crlf conversion and you commit it and from then on it's an issue of how much time you'll waste trying to figure out why.

    And another point is that LightingData.asset seems to be unsuitable for renaming and always resides in a specific folder, while the other two types are freer in this regard.

    Also thank you for making me go through docs again. It seems git attributes favors the latter rule in a case where multiple rules match the same file.

    So the right pattern seems to be:
    1) *.asset ......<text handling>
    2) LightingData.asset filter=lfs diff=lfs merge=lfs -text

    and the following, provided you keep naming conventions:
    3) *-[Tt]errain.asset filter=lfs diff=lfs merge=lfs -text
    4) *-[Nn]av[Mm]esh.asset filter=lfs diff=lfs merge=lfs -text



    3- As for the OPs issue, in case someone else sees this. The problem likely lies on the following two lines
    *.asset                 merge=unityyamlmerge eol=lf

    *-[Tt]errain.asset -unityyaml lfs


    The first makes sure to define .asset as text type. The second has this -unityyaml thing which I'm thinking the OP has either incomplete .gitattributes or posted an incomplete version.

    It might be a macro like so:
    # Macro for Unity YAML-based asset files.
    [attr]unityyaml -text merge=unityyamlmerge diff

    taken from this site.

    -text means "this is not text", so I speculate that -unityyaml is a double negative, so it's back to being a text.
    This is more clear:
    *-[Tt]errain.asset filter=lfs diff=lfs merge=lfs -text
    *-[Nn]av[Mm]esh.asset filter=lfs diff=lfs merge=lfs -text


    I could be wrong about this, but as an alternative for figuring things out:
    there's a command called git check-attr which tells you if a pattern of specific filepath has attributes and what kind/value:
    e.g.
    git check-attr -a .asset
    returns:
    .asset: merge: unityyamlmerge
    .asset: eol: lf


    while based on the rule I set before:
    git check-attr -a LightingData.asset
    returns:
    LightingData.asset: diff: lfs
    LightingData.asset: merge: lfs
    LightingData.asset: text: unset
    LightingData.asset: eol: lf
    LightingData.asset: filter: lfs


    The LightingData clearly speficies that "text" is unset, so it's not text type asset, but binary.

    The .asset though doesn't specify "text" and documentation for gitattributes states that in the absence of text, it defaults to what core.autocrlf defines, which by default is true, so it treats it as text.

    There is a case to be had for "text=auto" in letting git decide if the asset is text or binary, but I can't be sure about it, not having used it.

    Still this git command can act as a debug tool.
     
    Last edited: Sep 29, 2023