Skip to content

Add NavMesh assets binary exception to prevent broken files - #252

Open
Sont3k wants to merge 2 commits into
gitattributes:masterfrom
Sont3k:patch-1
Open

Sont3k wants to merge 2 commits into
gitattributes:masterfrom
Sont3k:patch-1

Conversation

@Sont3k

@Sont3k Sont3k commented Aug 18, 2026

Copy link
Copy Markdown

NavMesh assets are required to have binary handling otherwise they are breaking in git and then you are getting missed reference in game object components and unreadable file

NavMesh assets are required to have binary handling otherwise they are breaking in git and then you are getting missed reference and unreadable file
@max-lacasse-maisonneuve

max-lacasse-maisonneuve commented Aug 28, 2026 •

Copy link
Copy Markdown

@Sont3k - It is the same thing for terrain assets. It is possible to modify this as well?

@Sont3k

Sont3k commented Sep 6, 2026

Copy link
Copy Markdown
Author

@Sont3k - It is the same thing for terrain assets. It is possible to modify this as well?

I haven't checked if terrain assets have the same issue, but can be a similar case
Do you want to add in this PR attribute rule for terrain assets as well?

@FurkanKambay

Copy link
Copy Markdown
Contributor

Could you try this change at the top instead of the NavMesh*.asset rule and see if the issue persists?

- [attr]unity-yaml        merge=unityyamlmerge eol=lf linguist-language=yaml
+ [attr]unity-yaml        text=auto eol=lf merge=unityyamlmerge linguist-language=yaml

This should prevent the eol=lf attribute from messing with binary files and it also avoids having to enforce a naming scheme in your files.

The only possible issue I see with this: the other attributes still apply to both text and binary files and I haven't verified whether or not unityyamlmerge is safe to use with binary files, but I'd assume it is. (text=auto only prevents eol=lf in binary files)

See #231 (comment) and fe1bd9e#r198092088 for longer explanations.

@Sont3k

Sont3k commented Oct 2, 2026

Copy link
Copy Markdown
Author

Could you try this change at the top instead of the NavMesh*.asset rule and see if the issue persists?

- [attr]unity-yaml        merge=unityyamlmerge eol=lf linguist-language=yaml
+ [attr]unity-yaml        text=auto eol=lf merge=unityyamlmerge linguist-language=yaml

This should prevent the eol=lf attribute from messing with binary files and it also avoids having to enforce a naming scheme in your files.

The only possible issue I see with this: the other attributes still apply to both text and binary files and I haven't verified whether or not unityyamlmerge is safe to use with binary files, but I'd assume it is. (text=auto only prevents eol=lf in binary files)

See #231 (comment) and fe1bd9e#r198092088 for longer explanations.

Your proposed change is working well from what I see.
What I have tried:

  1. Remove my patch, add your patch to .gitattributes
  2. Remove NavMeshSurface file (like "Clear" reference to it on component and remove from filesystem)
  3. Regenerate NavMeshSurface, see it got assigned to component + scene got updated
  4. Commit and push all three changes (.gitattributes, scene file, new NavMeshSurface file), so git attributes got applied to source files
  5. Restart Unity Editor a couple times and check if NavMeshSurface got broken inside Project window inside Editor
  6. NavMeshSurface file still has proper rendering as a component and reference to it in a NavMeshSurface component are not broken

Can't say for sure for other binary files, but seems for NavMeshSurface it is enough to fix a behavior.

@FurkanKambay

This comment was marked as outdated.

@FurkanKambay

FurkanKambay commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Ignore my previous message, I've tested that scenario and it skips the file, even with --force:

~/UnityYAMLMerge.exe merge --force --fallback none _base/NavMesh.asset _remote/NavMesh.asset _local/NavMesh.asset MERGED/NavMesh.asset
# Error parsing file '_base\NavMesh.asset': File is not a valid text serialized YAML file. Make sure that Asset Serialization is set to 'Force text' in Editor Settings.

Safe to say the only problem was the eol=lf implying text.

@FurkanKambay FurkanKambay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found out that /ProjectSettings/NavMeshAreas.asset exists, which matches the rule NavMesh*.asset.

Recommend Assets/**/*NavMesh*.asset
and text=auto for the macro

Updated unity-yaml attribute to include text=auto.
@Sont3k

Sont3k commented Oct 7, 2026

Copy link
Copy Markdown
Author

I found out that /ProjectSettings/NavMeshAreas.asset exists, which matches the rule NavMesh*.asset.

Recommend Assets/**/*NavMesh*.asset and text=auto for the macro

I have update PR with changes that we have tested last time. Explicit filtering for NavMesh asset was removed as just adding "text=auto" was enough to solve all issues that I had in the beginning.
It looks like a final solution to me rn.

Thanks for your help.

@Sont3k
Sont3k requested a review from FurkanKambay October 7, 2026 18:56
@max-lacasse-maisonneuve

Copy link
Copy Markdown

Would this solution solve also the problem with the Terrain.asset file corruption?

@Sont3k

Sont3k commented Oct 10, 2026

Copy link
Copy Markdown
Author

Would this solution solve also the problem with the Terrain.asset file corruption?

I can test it on my side but I need to get from you steps that you did for terrain asset.
Like just created terrain asset or something else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants