You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unexpected behavior on folders with no projects #222
I was debugging today a problem with our CI environment on my development machine and noticed a strange bug where the Editor was upgrading randomly, not noticing that my terminal went back to my home folder.
That is no bug per-se, the command line utility selects the latest editor (due to the missing ProjectVersion.txt). However, the editor still executes fine - because Unity does store the last opened project somewhere (I'm guessing either by registry key or somewhere in LocalAppData), and opens that.
Start-UnityEditor falls back to the latest version, starts the Editor, which then opens the last opened project, no matter which ProjectVersion.txt.
Reproduction
Execute Start-UnityEditor in a folder that does not contain a Unity project
Possible Solutions
Start-UnityEditor should either be able to find the folder that Unity is going to open or exit prematurely with an error code that this folder is not a Unity project folder.
Interesting, when I run Start-UnityEditor from a non-unity project folder I essentially get the Unity Hub to open. It's an interesting bit of confusion, but this working as intended currently. If there's a unity project and you haven't passed -IgnoreProjectContext then it launches the latest version of Unity, which Unity has changed to fall back to the Hub if installed and there's no unity project specified I believe. This gives one a quick way to get into Unity from the command line if you don't have a project available.
What might make sense though is to look at what other arguments have come in to Start-UnityEditor and if they seem like they'd only make sense if a project is discovered/specified, then throw the error?
If I had to guesstimate, then Unity is not opening the hub either because of -batchmode, since it already assumes that there is no UI involved. Probably good guess that -nographics does something similar (but I have yet to test that either).
I think your additions generally make sense, it's not actively hurting (our) CI process, it's most a side-effect I have discovered while working on our CIs
I have seen another variant of this issue recently. In our CI, when we open Unity with the intent to license it, Unity is consistently emitting a new empty project into the WorkingDirectory. I could not replicate this on my local machine. Locally, I saw what the above users mentioned, either Unity opened a cached project or if there was no cached project, the hub would open. I circumvented the issue by explicitly using the "-CreateProject" flag to create a decoy project in the build machine's Temp folder when licensing.
Activity
jwittner commentedon Jul 6, 2021
Interesting, when I run
Start-UnityEditorfrom a non-unity project folder I essentially get the Unity Hub to open. It's an interesting bit of confusion, but this working as intended currently. If there's a unity project and you haven't passed-IgnoreProjectContextthen it launches the latest version of Unity, which Unity has changed to fall back to the Hub if installed and there's no unity project specified I believe. This gives one a quick way to get into Unity from the command line if you don't have a project available.What might make sense though is to look at what other arguments have come in to
Start-UnityEditorand if they seem like they'd only make sense if a project is discovered/specified, then throw the error?[-]Incorrect editor version on folders with no projects[/-][+]Unexpected behavior on folders with no projects[/+]jwittner commentedon Jul 6, 2021
Retitled as there really is no 'incorrect version' on projects without a folder.
mio-moto commentedon Jul 6, 2021
If I had to guesstimate, then Unity is not opening the hub either because of
-batchmode, since it already assumes that there is no UI involved. Probably good guess that-nographicsdoes something similar (but I have yet to test that either).I think your additions generally make sense, it's not actively hurting (our) CI process, it's most a side-effect I have discovered while working on our CIs
mister-liss commentedon Feb 17, 2022
I have seen another variant of this issue recently. In our CI, when we open Unity with the intent to license it, Unity is consistently emitting a new empty project into the WorkingDirectory. I could not replicate this on my local machine. Locally, I saw what the above users mentioned, either Unity opened a cached project or if there was no cached project, the hub would open. I circumvented the issue by explicitly using the "-CreateProject" flag to create a decoy project in the build machine's Temp folder when licensing.