private static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions options) { AssetDeleteResult didNotDelete = AssetDeleteResult.DidNotDelete; if (!InternalEditorUtility.HasTeamLicense()) { return(didNotDelete); } foreach (System.Type type in AssetModificationProcessors) { MethodInfo method = type.GetMethod("OnWillDeleteAsset", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); if (method != null) { RequireTeamLicense(); object[] args = new object[] { assetPath, options }; if (CheckArgumentsAndReturnType(args, method, didNotDelete.GetType())) { didNotDelete |= (AssetDeleteResult)method.Invoke(null, args); } } } if (didNotDelete != AssetDeleteResult.DidNotDelete) { return(didNotDelete); } return(AssetModificationHook.OnWillDeleteAsset(assetPath, options)); }
private static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions options) { AssetDeleteResult assetDeleteResult = AssetDeleteResult.DidNotDelete; if (!InternalEditorUtility.HasTeamLicense()) { return(assetDeleteResult); } foreach (Type current in AssetModificationProcessorInternal.AssetModificationProcessors) { MethodInfo method = current.GetMethod("OnWillDeleteAsset", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { AssetModificationProcessorInternal.RequireTeamLicense(); object[] array = new object[] { assetPath, options }; if (AssetModificationProcessorInternal.CheckArgumentsAndReturnType(array, method, assetDeleteResult.GetType())) { assetDeleteResult |= (AssetDeleteResult)((int)method.Invoke(null, array)); } } } if (assetDeleteResult != AssetDeleteResult.DidNotDelete) { return(assetDeleteResult); } assetDeleteResult = AssetModificationHook.OnWillDeleteAsset(assetPath, options); return(assetDeleteResult); }
static AssetMoveResult OnWillMoveAsset(string fromPath, string toPath, string[] newPaths, string[] NewMetaPaths) { AssetMoveResult finalResult = AssetMoveResult.DidNotMove; finalResult = AssetModificationHook.OnWillMoveAsset(fromPath, toPath); foreach (var assetModificationProcessorClass in AssetModificationProcessors) { const string methodName = "OnWillMoveAsset"; MethodInfo method = assetModificationProcessorClass.GetMethod(methodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); if (method != null) { object[] args = { fromPath, toPath }; if (!CheckArgumentsAndReturnType(args, method, finalResult.GetType())) { continue; } using (new EditorPerformanceMarker($"{assetModificationProcessorClass.Name}.{methodName}", assetModificationProcessorClass).Auto()) finalResult |= (AssetMoveResult)method.Invoke(null, args); } } return(finalResult); }
static bool GetOpenForEdit(bool canOpenForEditVariant, string assetPath, out string message, StatusQueryOptions statusOptions) { message = string.Empty; if (string.IsNullOrEmpty(assetPath)) { return(true); // treat empty/null paths as editable (might be under Library folders etc.) } var editability = GetPathEditability(assetPath); if (editability == Editability.Always) { return(true); } if (editability == Editability.Never) { return(false); } if (!AssetModificationHook.GetOpenForEdit(canOpenForEditVariant, assetPath, out message, statusOptions)) { return(false); } return(GetOpenForEditViaScriptCallbacks(canOpenForEditVariant, new[] { assetPath }, new List <string>(), out message, statusOptions)); }
private static AssetMoveResult OnWillMoveAsset(string fromPath, string toPath, string[] newPaths, string[] NewMetaPaths) { AssetMoveResult didNotMove = AssetMoveResult.DidNotMove; if (InternalEditorUtility.HasTeamLicense()) { didNotMove = AssetModificationHook.OnWillMoveAsset(fromPath, toPath); IEnumerator <Type> enumerator = AssetModificationProcessors.GetEnumerator(); try { while (enumerator.MoveNext()) { MethodInfo method = enumerator.Current.GetMethod("OnWillMoveAsset", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); if (method != null) { RequireTeamLicense(); object[] args = new object[] { fromPath, toPath }; if (CheckArgumentsAndReturnType(args, method, didNotMove.GetType())) { didNotMove |= (int)method.Invoke(null, args); } } } } finally { if (enumerator == null) { } enumerator.Dispose(); } } return(didNotMove); }
internal static bool IsOpenForEdit(string assetPath, out string message) { message = string.Empty; if (string.IsNullOrEmpty(assetPath)) { return(true); } bool result = AssetModificationHook.IsOpenForEdit(assetPath, out message); MethodInfo[] array = AssetModificationProcessorInternal.GetIsOpenForEditMethods(); for (int i = 0; i < array.Length; i++) { MethodInfo methodInfo = array[i]; object[] array2 = new object[] { assetPath, message }; if (!(bool)methodInfo.Invoke(null, array2)) { message = (array2[1] as string); return(false); } } return(result); }
internal static bool IsOpenForEdit(string assetPath, out string message, StatusQueryOptions statusOptions) { message = ""; if (String.IsNullOrEmpty(assetPath)) { return(true); // assetPath can be empty in some cases where Unity is checking for stuff in Library folder } bool rootFolder, readOnly; bool validPath = AssetDatabase.GetAssetFolderInfo(assetPath, out rootFolder, out readOnly); if (validPath && readOnly) { return(false); } bool finalResult = AssetModificationHook.IsOpenForEdit(assetPath, out message, statusOptions); foreach (var method in GetIsOpenForEditMethods()) { object[] args = { assetPath, message }; if (!((bool)method.Invoke(null, args))) { message = args[1] as string; return(false); } } return(finalResult); }
static AssetMoveResult OnWillMoveAsset(string fromPath, string toPath, string[] newPaths, string[] NewMetaPaths) { AssetMoveResult finalResult = AssetMoveResult.DidNotMove; if (!InternalEditorUtility.HasTeamLicense()) { return(finalResult); } finalResult = AssetModificationHook.OnWillMoveAsset(fromPath, toPath); foreach (var assetModificationProcessorClass in AssetModificationProcessors) { MethodInfo method = assetModificationProcessorClass.GetMethod("OnWillMoveAsset", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); if (method != null) { RequireTeamLicense(); object[] args = { fromPath, toPath }; if (!CheckArgumentsAndReturnType(args, method, finalResult.GetType())) { continue; } finalResult |= (AssetMoveResult)method.Invoke(null, args); } } return(finalResult); }
static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions options) { AssetDeleteResult finalResult = AssetDeleteResult.DidNotDelete; foreach (var assetModificationProcessorClass in AssetModificationProcessors) { MethodInfo method = assetModificationProcessorClass.GetMethod("OnWillDeleteAsset", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); if (method != null) { object[] args = { assetPath, options }; if (!CheckArgumentsAndReturnType(args, method, finalResult.GetType())) { continue; } finalResult |= (AssetDeleteResult)method.Invoke(null, args); } } if (finalResult != AssetDeleteResult.DidNotDelete) { return(finalResult); } finalResult = AssetModificationHook.OnWillDeleteAsset(assetPath, options); return(finalResult); }
private static AssetMoveResult OnWillMoveAsset(string fromPath, string toPath, string[] newPaths, string[] NewMetaPaths) { AssetMoveResult assetMoveResult1 = AssetMoveResult.DidNotMove; if (!InternalEditorUtility.HasTeamLicense()) { return(assetMoveResult1); } AssetMoveResult assetMoveResult2 = AssetModificationHook.OnWillMoveAsset(fromPath, toPath); foreach (System.Type modificationProcessor in AssetModificationProcessorInternal.AssetModificationProcessors) { MethodInfo method = modificationProcessor.GetMethod("OnWillMoveAsset", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { AssetModificationProcessorInternal.RequireTeamLicense(); object[] objArray = new object[2] { (object)fromPath, (object)toPath }; if (AssetModificationProcessorInternal.CheckArgumentsAndReturnType(objArray, method, assetMoveResult2.GetType())) { assetMoveResult2 |= (AssetMoveResult)method.Invoke((object)null, objArray); } } } return(assetMoveResult2); }
internal static bool IsOpenForEdit(string assetPath, out string message, StatusQueryOptions statusOptions) { message = string.Empty; if (string.IsNullOrEmpty(assetPath)) { return(true); // treat empty/null paths as editable (might be under Library folders etc.) } var editability = GetPathEditability(assetPath); if (editability == Editability.Always) { return(true); } if (editability == Editability.Never) { return(false); } if (!AssetModificationHook.IsOpenForEdit(assetPath, out message, statusOptions)) { return(false); } if (!IsOpenForEditViaScriptCallbacks(assetPath, ref message)) { return(false); } return(true); }
private static AssetMoveResult OnWillMoveAsset(string fromPath, string toPath, string[] newPaths, string[] NewMetaPaths) { AssetMoveResult assetMoveResult = AssetMoveResult.DidNotMove; if (!InternalEditorUtility.HasTeamLicense()) { return(assetMoveResult); } assetMoveResult = AssetModificationHook.OnWillMoveAsset(fromPath, toPath); foreach (Type current in AssetModificationProcessorInternal.AssetModificationProcessors) { MethodInfo method = current.GetMethod("OnWillMoveAsset", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { AssetModificationProcessorInternal.RequireTeamLicense(); object[] array = new object[] { fromPath, toPath }; if (AssetModificationProcessorInternal.CheckArgumentsAndReturnType(array, method, assetMoveResult.GetType())) { assetMoveResult |= (AssetMoveResult)((int)method.Invoke(null, array)); } } } return(assetMoveResult); }
internal static bool IsOpenForEdit(string assetPath, out string message, StatusQueryOptions statusOptions) { message = ""; bool result; if (string.IsNullOrEmpty(assetPath)) { result = true; } else { bool flag = AssetModificationHook.IsOpenForEdit(assetPath, out message, statusOptions); MethodInfo[] array = AssetModificationProcessorInternal.GetIsOpenForEditMethods(); for (int i = 0; i < array.Length; i++) { MethodInfo methodInfo = array[i]; object[] array2 = new object[] { assetPath, message }; if (!(bool)methodInfo.Invoke(null, array2)) { message = (array2[1] as string); result = false; return(result); } } result = flag; } return(result); }
internal static void IsOpenForEdit(string[] assetOrMetaFilePaths, List <string> outNotEditablePaths, StatusQueryOptions statusQueryOptions = StatusQueryOptions.UseCachedIfPossible) { outNotEditablePaths.Clear(); if (assetOrMetaFilePaths == null || assetOrMetaFilePaths.Length == 0) { return; } var queryList = new List <string>(); foreach (var path in assetOrMetaFilePaths) { if (string.IsNullOrEmpty(path)) { continue; // treat empty/null paths as editable (might be under Library folders etc.) } var editability = GetPathEditability(path); if (editability == Editability.Always) { continue; } if (editability == Editability.Never) { outNotEditablePaths.Add(path); continue; } queryList.Add(path); } // check with VCS AssetModificationHook.IsOpenForEdit(queryList, outNotEditablePaths, statusQueryOptions); // check with possible script callbacks var scriptCallbacks = GetIsOpenForEditMethods(); if (scriptCallbacks != null && scriptCallbacks.Length > 0) { var stillEditable = assetOrMetaFilePaths.Except(outNotEditablePaths).Where(f => !string.IsNullOrEmpty(f)); var message = string.Empty; foreach (var path in stillEditable) { if (!IsOpenForEditViaScriptCallbacks(path, ref message)) { outNotEditablePaths.Add(path); } } } }
internal static bool IsOpenForEdit(string assetPath, out string message) { message = string.Empty; if (string.IsNullOrEmpty(assetPath)) { return(true); } bool flag = AssetModificationHook.IsOpenForEdit(assetPath, out message); foreach (MethodInfo info in GetIsOpenForEditMethods()) { object[] parameters = new object[] { assetPath, message }; if (!((bool)info.Invoke(null, parameters))) { message = parameters[1] as string; return(false); } } return(flag); }
// ReSharper disable once UnusedMember.Local - invoked from native code static void FileModeChanged(string[] assets, FileMode mode) { AssetModificationHook.FileModeChanged(assets, mode); object[] args = { assets, mode }; foreach (var type in AssetModificationProcessors) { const string methodName = "FileModeChanged"; var method = type.GetMethod(methodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); if (method == null) { continue; } if (!CheckArgumentsAndReturnType(args, method, typeof(void))) { continue; } using (new EditorPerformanceMarker($"{type.Name}.{methodName}", type).Auto()) method.Invoke(null, args); } }
internal static bool CanOpenForEdit(string[] assetOrMetaFilePaths, List <string> outNotEditablePaths, StatusQueryOptions statusQueryOptions) { outNotEditablePaths.Clear(); if (assetOrMetaFilePaths == null || assetOrMetaFilePaths.Length == 0) { return(true); } var queryList = GetQueryList(assetOrMetaFilePaths, outNotEditablePaths); if (queryList.Count == 0) { return(outNotEditablePaths.Count == 0); } // Get a list of paths that are not open for edit. var notOpenForEditPaths = new List <string>(); AssetModificationHook.GetOpenForEdit(false, queryList, notOpenForEditPaths, statusQueryOptions); GetOpenForEditViaScriptCallbacks(false, queryList.ToArray(), notOpenForEditPaths, out var message, statusQueryOptions); if (notOpenForEditPaths.Count == 0) { return(outNotEditablePaths.Count == 0); } // Status has just been updated so there's no need to force update again. if (statusQueryOptions == StatusQueryOptions.ForceUpdate) { statusQueryOptions = StatusQueryOptions.UseCachedIfPossible; } // Check paths that are not open for edit. if (!AssetModificationHook.GetOpenForEdit(true, notOpenForEditPaths, outNotEditablePaths, statusQueryOptions)) { return(false); } return(GetOpenForEditViaScriptCallbacks(true, notOpenForEditPaths.ToArray(), outNotEditablePaths, out message, statusQueryOptions)); }
private static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions options) { AssetDeleteResult didNotDelete = AssetDeleteResult.DidNotDelete; if (!InternalEditorUtility.HasTeamLicense()) { return(didNotDelete); } IEnumerator <Type> enumerator = AssetModificationProcessors.GetEnumerator(); try { while (enumerator.MoveNext()) { MethodInfo method = enumerator.Current.GetMethod("OnWillDeleteAsset", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); if (method != null) { RequireTeamLicense(); object[] args = new object[] { assetPath, options }; if (CheckArgumentsAndReturnType(args, method, didNotDelete.GetType())) { didNotDelete |= (int)method.Invoke(null, args); } } } } finally { if (enumerator == null) { } enumerator.Dispose(); } if (didNotDelete != AssetDeleteResult.DidNotDelete) { return(didNotDelete); } return(AssetModificationHook.OnWillDeleteAsset(assetPath, options)); }
private static AssetMoveResult OnWillMoveAsset(string fromPath, string toPath, string[] newPaths, string[] NewMetaPaths) { AssetMoveResult didNotMove = AssetMoveResult.DidNotMove; if (InternalEditorUtility.HasTeamLicense()) { didNotMove = AssetModificationHook.OnWillMoveAsset(fromPath, toPath); foreach (System.Type type in AssetModificationProcessors) { MethodInfo method = type.GetMethod("OnWillMoveAsset", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); if (method != null) { RequireTeamLicense(); object[] args = new object[] { fromPath, toPath }; if (CheckArgumentsAndReturnType(args, method, didNotMove.GetType())) { didNotMove |= (AssetMoveResult)method.Invoke(null, args); } } } } return(didNotMove); }
internal static bool IsOpenForEdit(string assetPath, out string message) { message = string.Empty; if (string.IsNullOrEmpty(assetPath)) { return(true); } bool flag = AssetModificationHook.IsOpenForEdit(assetPath, out message); foreach (MethodInfo openForEditMethod in AssetModificationProcessorInternal.GetIsOpenForEditMethods()) { object[] parameters = new object[2] { (object)assetPath, (object)message }; if (!(bool)openForEditMethod.Invoke((object)null, parameters)) { message = parameters[1] as string; return(false); } } return(flag); }
internal static bool IsOpenForEdit(string[] assetOrMetaFilePaths, List <string> outNotEditablePaths, StatusQueryOptions statusQueryOptions) { outNotEditablePaths.Clear(); if (assetOrMetaFilePaths == null || assetOrMetaFilePaths.Length == 0) { return(true); } var queryList = GetQueryList(assetOrMetaFilePaths, outNotEditablePaths); if (queryList.Count == 0) { return(outNotEditablePaths.Count == 0); } // check with VCS if (!AssetModificationHook.GetOpenForEdit(false, queryList, outNotEditablePaths, statusQueryOptions)) { return(false); } // check with possible script callbacks return(GetOpenForEditViaScriptCallbacks(false, queryList.ToArray(), outNotEditablePaths, out var message, statusQueryOptions)); }
static void OnWillDeleteAssets(string[] assetPaths, AssetDeleteResult[] outPathDeletionResults, RemoveAssetOptions options) { for (int i = 0; i < outPathDeletionResults.Length; i++) { outPathDeletionResults[i] = (int)AssetDeleteResult.DidNotDelete; } List <string> nonDeletedPaths = new List <string>(); List <int> nonDeletedPathIndices = new List <int>(); foreach (var assetModificationProcessorClass in AssetModificationProcessors) { MethodInfo method = assetModificationProcessorClass.GetMethod("OnWillDeleteAsset", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); if (method == null) { continue; } for (int i = 0; i < assetPaths.Length; i++) { object[] args = { assetPaths[i], options }; if (!CheckArgumentsAndReturnType(args, method, typeof(AssetDeleteResult))) { continue; } AssetDeleteResult callbackResult = (AssetDeleteResult)method.Invoke(null, args); outPathDeletionResults[i] |= callbackResult; } } for (int i = 0; i < assetPaths.Length; i++) { if (outPathDeletionResults[i] == (int)AssetDeleteResult.DidNotDelete) { nonDeletedPaths.Add(assetPaths[i]); nonDeletedPathIndices.Add(i); } } if (nonDeletedPaths.Count > 0) { if (!Provider.enabled || EditorUserSettings.WorkOffline) { return; } for (int i = 0; i < nonDeletedPaths.Count; i++) { if (!Provider.PathIsVersioned(nonDeletedPaths[i])) { nonDeletedPaths.RemoveAt(i); nonDeletedPathIndices.RemoveAt(i); i--; } } var nonDeletedPathDeletionResults = new AssetDeleteResult[nonDeletedPaths.Count]; AssetModificationHook.OnWillDeleteAssets(nonDeletedPaths.ToArray(), nonDeletedPathDeletionResults, options); for (int i = 0; i < nonDeletedPathIndices.Count; i++) { outPathDeletionResults[nonDeletedPathIndices[i]] = nonDeletedPathDeletionResults[i]; } } }