Settings UI does not support projects with version control enabled

Avatar
  • updated
  • Fixed

If a Unity project is managed with version control such as Perforce, files may need to be checked out before they can be modified, otherwise leaving files marked as readonly in the file system.

This means that currently there are cases where attempting to modify Shapes settings results in an UnauthorizedAccessException:

Image 256

UnityEditor.VersionControl.Provider https://docs.unity3d.com/ScriptReference/VersionControl.Provider.html should be used to query the state of any settings or shader files that the settings UI attempts to write to.

If it is not checked out and should be, then the 'Apply' buttons need to be disabled, as well as show an optional 'check out' button.

    Reporting a bug? please specify Unity version:
    2019.4.16f1
    Reporting a bug? please specify Shapes version:
    3.0.0
    Reporting a bug? please specify Render Pipeline:
    Built-in render pipeline
    Pinned replies
    Avatar
    Freya Holmér creator
    • Answer
    • Fixed

    as far as I can tell (without testing with perforce) this should now be fixed in 3.1.0!
    If you have VC enabled with checkout support, and the file is not open for edit, you'll have to unlock them using this button

    Avatar
    JohannesMP

    In case it might be useful just for reference, here's a bit of related code I use that checks if a file is writable with version control (though it does not handle checking out): https://github.com/JohannesMP/unity-scene-reference/blob/master/unity-scene-reference/Assets/source/SceneReference.cs#L408-L450

    Avatar
    Freya Holmér creator
    • Under Review

    what line does that happen on? (I don't use the integrated VC myself so I can't test where this happens)

    Avatar
    Freya Holmér creator

    documentation seems super lacking in how to handle asset editing with VC in general

    like, if I use serializeObject.ApplyModifiedProperties in my editor UI, do I manually detect changes before that kicks in and then check out the asset if needed?

    Avatar
    JohannesMP
    Quote from Freya Holmér

    documentation seems super lacking in how to handle asset editing with VC in general

    like, if I use serializeObject.ApplyModifiedProperties in my editor UI, do I manually detect changes before that kicks in and then check out the asset if needed?

    Yeah, I believe that is correct.

    This answer may be useful: https://answers.unity.com/questions/1004403/versioncontrolprovidercheckoutisvalid-returns-fals.html

    Most likely will not be relevant for a single settings file like this, but you could also support handling remote checkouts: https://prof.johnpile.com/2015/01/12/unity3d-p4-remote-checkout-in-inspector/

    Avatar
    Freya Holmér creator

    so on what line did that error happen on? (I'm kinda doing this blindly, I have no way of testing this and there seems to be no docs on this anywhere)

    Avatar
    Freya Holmér creator
    • Answer
    • Fixed

    as far as I can tell (without testing with perforce) this should now be fixed in 3.1.0!
    If you have VC enabled with checkout support, and the file is not open for edit, you'll have to unlock them using this button

    Avatar
    JohannesMP

    Excellent! I look forward to testing it once available