While setting up my first environment with Unity I discovered a bug that made all options under ‘Version Control’ disappear from Editor Settings in inspector. I could still access VCS settings via debug but as I was not sure which values those settings accept, I simply reverted the change in EditorSettings.asset via SVN and it solved the problem.
The bug may look boring, but how comes that Unity scans project folders for .svn and automatically changes VCS settings based on their existence? Note that I have “C:\Program Files\Unity\Editor\Data\Tools\VersionControl\SubversionPlugin.exe” file on my system and I didn’t add it myself. Why does Unity 3.6 contain SubversionPlugin.exe in its installation directory? Is it the same SVN plug-in which source is available at Bitbucket ?
I reproduce the problem with Unity 5.6.0f3 Personal on Windows 10 64-bit with any Unity project in SVN working copy. I don’t use any special SVN extension in Unity. The reproduction is very simple – I add my Unity project to Subversion and SVN places single hidden directory .svn to the root of my project. If I add an empty .svn directory manually via mkdir .svn Unity behaves a bit differently. But I think that you anyone could reproduce the problem just by checking out svn working copy with Unity project from the web. Here is an example:
- Make sure that you have svn client installed (e.g command line svn.exe or TortoiseSVN).
- Checkout any Unity project. For example, run
svn checkout https://github.com/dominusbelli/FortVR.git/trunk myproj - Open the project in Unity (it should ask you to upgrade the project and that’s OK).
- Go to Edit | Project Settings | Editor.
- Click ‘gear’ on the right side of Editor Settings inspector and click Reset.
Getting this in console:
IndexOutOfRangeException: Array index is out of range.
And this in editor.log:
IndexOutOfRangeException: Array index is out of range.
at UnityEditor.EditorSettingsInspector.CreatePopupMenuVersionControl (System.String title, .PopupElement[ ] elements, System.String selectedValue, UnityEditor.MenuFunction2 func) [0x00021] in C:\buildslave\unity\build\Editor\Mono\Inspector\EditorSettingsInspector.cs:489
at UnityEditor.EditorSettingsInspector.OnInspectorGUI () [0x00076] in C:\buildslave\unity\build\Editor\Mono\Inspector\EditorSettingsInspector.cs:177
at UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) [0x0039d] in C:\buildslave\unity\build\Editor\Mono\Inspector\InspectorWindow.cs:1229
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
UnityEditor.InspectorWindow:smile:rawEditor(Editor, Int32, Boolean, Boolean&, Rect&) (at C:\buildslave\unity\build\Editor\Mono\Inspector\InspectorWindow.cs:1236)
UnityEditor.InspectorWindow:smile:rawEditors(Editor[ ]) (at C:\buildslave\unity\build\Editor\Mono\Inspector\InspectorWindow.cs:1019)
UnityEditor.InspectorWindow:OnGUI() (at C:\buildslave\unity\build\Editor\Mono\Inspector\InspectorWindow.cs:358)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[ ], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[ ], CultureInfo) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
System.Reflection.MethodBase:Invoke(Object, Object[ ]) (at /Users/builduser/buildslave/mono/build/mcs/ndexOutOfRangeException: Array index is out of range.
at UnityEditor.EditorSettingsInspector.CreatePopupMenuVersionControl (System.String title, .PopupElement[ ] elements, System.String selectedValue, UnityEditor.MenuFunction2 func) [0x00021] in C:\buildslave\unity\build\Editor\Mono\Inspector\EditorSettingsInspector.cs:489
at UnityEditor.EditorSettingsInspector.OnInspectorGUI () [0x00076] in C:\buildslave\unity\build\Editor\Mono\Inspector\EditorSettingsInspector.cs:177
at UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) [0x0039d] in C:\buildslave\unity\build\Editor\Mono\Inspector\InspectorWindow.cs:1229
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
UnityEditor.InspectorWindow:smile:rawEditor(Editor, Int32, Boolean, Boolean&, Rect&) (at C:\buildslave\unity\build\Editor\Mono\Inspector\InspectorWindow.cs:1236)
UnityEditor.InspectorWindow:smile:rawEditors(Editor[ ]) (at C:\buildslave\unity\build\Editor\Mono\Inspector\InspectorWindow.cs:1019)
UnityEditor.InspectorWindow:OnGUI() (at C:\buildslave\unity\build\Editor\Mono\Inspector\InspectorWindow.cs:358)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[ ], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[ ], CultureInfo) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
System.Reflection.MethodBase:Invoke(Object, Object[ ]) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView:Invoke(String, Object) (at C:\buildslave\unity\build\Editor\Mono\HostView.cs:262)
UnityEditor.HostView:Invoke(String) (at C:\buildslave\unity\build\Editor\Mono\HostView.cs:255)
UnityEditor.HostView:InvokeOnGUI(Rect) (at C:\buildslave\unity\build\Editor\Mono\HostView.cs:222)
UnityEditor.DockArea:OnGUI() (at C:\buildslave\unity\build\Editor\Mono\GUI\DockArea.cs:346)
(Filename: C:/buildslave/unity/build/Editor/Mono/Inspector/EditorSettingsInspector.cs Line: 489)class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView:Invoke(String, Object) (at C:\buildslave\unity\build\Editor\Mono\HostView.cs:262)
UnityEditor.HostView:Invoke(String) (at C:\buildslave\unity\build\Editor\Mono\HostView.cs:255)
UnityEditor.HostView:InvokeOnGUI(Rect) (at C:\buildslave\unity\build\Editor\Mono\HostView.cs:222)
UnityEditor.DockArea:OnGUI() (at C:\buildslave\unity\build\Editor\Mono\GUI\DockArea.cs:346)
(Filename: C:/buildslave/unity/build/Editor/Mono/Inspector/EditorSettingsInspector.cs Line: 489)
I looked into Editor Settings ‘debug’ and External Version Control was set to Subversion. If I save the changes and re-open the project I will receive these warning and error in console:
Unknown version control plugin: Subversion
Cannot load Subversion overlays when plugin is not running
All this made me curious how Unity determines that the project is in SVN working copy. I ran procmon on project startup and unity.exe checks for “.svn” on startup:
Path:
C:\Users\user1\Documents\New Unity Project 11.svn
Stack:
IsDirectoryCreated + 0x6f 0x141219f0f C:\Program Files\Unity\Editor\Unity.exe
DetectVersionControl + 0x86 0x1405ef936 C:\Program Files\Unity\Editor\Unity.exe
DetectVersionControl + 0x21 0x1405f1581 C:\Program Files\Unity\Editor\Unity.exe
EditorSettings::SmartReset + 0x38 0x141734718 C:\Program Files\Unity\Editor\Unity.exe