Last active
October 31, 2023 09:59
-
-
Save matniedoba/1e09ccea78aa8fe78bbe79eb3fad0e1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Put this into your Assets folder | |
// The best place is to put it in a Scripts/ Editor Scripts folder | |
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.IO; | |
public class NotifyForLockedFiles : UnityEditor.AssetModificationProcessor | |
{ | |
public static string[] OnWillSaveAssets(string[] paths) | |
{ | |
List<string> pathsToSave = new List<string>(); | |
for (int i = 0; i < paths.Length; ++i) | |
{ | |
FileInfo info = new FileInfo(paths[i]); | |
if (info.IsReadOnly) | |
UnityEditor.EditorUtility.DisplayDialog("File locked", | |
paths[i] + " is locked by Anchorpoint to prevent conflicts.", | |
"Ok"); | |
else | |
pathsToSave.Add(paths[i]); | |
} | |
return pathsToSave.ToArray(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a Editor Script for Unity, so that it respects read-only files and does not save over them. This is important when locking files using version control.