How to check if there are any pending changes before exiting the editor?

Hi everyone,

About the Unity version control, I would like to implement a feature that checks for any uncommitted changes before I exit the editor.
If there are any pending changes, I want a dialog box to pop up to remind me,
otherwise, quit without notice.

To achieve this, I would like to know:
1. How to check the length of pending changes.
2. The API for checking in changes.

Thanks in advance for your help!

Hi,

There’s APIs for UVCS(Plastic SCM)

REST API:Plastic SCM version control · The Plastic SCM API
Server REST API:Plastic SCM - Server REST API

However, you can use the cm command instead to achieve what you want.

cm status --help command to see pending changes.
cm checkin: checkin

To my knowledge, there is no way to interrupt or cancel exiting out of the editor.

Thus even if you found a way to pop up a confirmation dialog upon the user clicking the X icon or choosing File => Quit/Exit this would not allow you to run any asnychronous code to completion since “awaiting” a call won’t stop the editor from continuing to shut down. Since Plastic is a cloud service, its API is asynchronous.

A better alternative would be to use the Plastic desktop application and use that for a final commit. And generally remind the team of ALWAYS comitting a working state before the end of the day. Because if they don’t and they call in sick the next day, nobody can finish their work and others would be blocked from making certain contributions, most painfully when there’s checked out scenes that are hard to impossible to merge.

If this is only about yourself, you only have to discipline yourself. Much easier. :wink:

If you absolutely must, prefer to write a regular C# resident app that monitors the Windows shutdown process because that is interruptible (shutdown /a on the command prompt). You can use the Plastic REST API to check for uncommitted files. There are also ways to monitor if the “unity.exe” process has exited and then perform the Plastic check.

Since Unity is no longer open at that point I recommend using the desktop app, which you’ll generally find useful because if I recall correctly some Plastic features are not available from within the Unity editor anyway.