Hi everyone,
this looks like a bug but it might also be something really, really weird.
I have an asset that hooks onto OnWillCreateAsset(). I noticed path not found exceptions and figured out that the path supplied to the function call has a wrong lowercase folder, “scenes”, which is really “Scenes”. The only explanation I can think of that is not a bug is we might have named the folder “scenes” somewhen and then renamed it later and now it is still somewhere in there. Otherwise, it’s a bug, which makes checking the path impossible under Linux, because Linux file systems are case-sensitive.
There’s no reference to “scenes” in the .unity or the .unity.meta file of the scene in question.
Any ideas?
Note that I found FileNotFoundException when reading asset contents in OnWillCreateAsset and this is a completely separate issue.
This is on Unity 2022.3.51f1.
Unfortunately MacOSX and Windows both have weird directory aliasing rules to try to accommodate varying capitalization.
Perhaps Linux has some type of casing shenanigan too?
This gets complicated by the path stored in your source control. For instance, you might have committed a file when the folder was “scenes” and then renamed just the folder to “Scenes”.
On MacOSX and Windows, source control and IDE file writes will continue working until some subsystem that actually cares or goes around the crazy aliasing gets to it.
Best bet is to close Unity, commit all to source control, copy the folder out, delete the entire affected folder in source control, then move the folder back in, verify and get ALL the casing correct, then add it to your source control.
I had to do this a lot with old MS-DOS-era C files that were MAINMENU.C and whatnot. 
I don’t know about Windows and Mac OS aliases but Linux just doesn’t have any. You can have any casing you want and they will all be treated as different paths. Because of that, when I rename the folder to lowercase on Linux in Unity or my file browser, git will think I deleted the old one and created a new one because it uses Linux’ rules when running on Linux.
That’s not what my problem is about though. The path actually is “Scenes” with an uppercase S - on my Linux system, on my partner’s Windows system and in git. Unity just doesn’t provide it that way for reasons unknown to me.
I meanwhile also checked if the folder was ever renamed. It was not. It has been uppercase S since the beginning of the Unity project. There are references to all-lowercase paths in the asset database file but I have no idea where they come from, it looks more like an internal Unity format, which is kind of what I suspect to be the culprit here.
There is good old core.ignorecase on git… I would check there.
It’s easy enough to make a micro repo, maybe start one on your system, try renaming, do it all local, test and see what happens with hand-renaming (case only) stuff with various settings.
If you can’t repro it then, perhaps try it from your partner’s winbox, then clone it to your linux box and see. I don’t personally know enough about core.ignorecase myself to speak about where it would matter, but I imagine it matters only on the system the files are written on. I would need to find out by replication and experimentation and cross-checking it with what the docs say. But even reading the docs can be ambiguous sometimes. 
As mentioned, this problem has nothing to do with casing in git. The folder never was lowercase and even if it had been, the problem is that Unity thinks that it is lowercase. It is not relevant what git has saved. This is about a Unity function and how Unity internally saves paths. The Scenes folder is literally the only folder Unity creates in an empty project, and it creates it with uppercase S, so I don’t know how files in it can ever be referenced to with a lowercase folder name.
1 Like