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); }
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); }
internal static MethodInfo[] GetIsOpenForEditMethods() { if (AssetModificationProcessorInternal.isOpenForEditMethods == null) { List <MethodInfo> list = new List <MethodInfo>(); foreach (Type current in AssetModificationProcessorInternal.AssetModificationProcessors) { MethodInfo method = current.GetMethod("IsOpenForEdit", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { AssetModificationProcessorInternal.RequireTeamLicense(); string empty = string.Empty; bool flag = false; Type[] types = new Type[] { empty.GetType(), empty.GetType().MakeByRefType() }; if (AssetModificationProcessorInternal.CheckArgumentTypesAndReturnType(types, method, flag.GetType())) { list.Add(method); } } } AssetModificationProcessorInternal.isOpenForEditMethods = list.ToArray(); } return(AssetModificationProcessorInternal.isOpenForEditMethods); }
private static void OnWillSaveAssets(string[] assets, out string[] assetsThatShouldBeSaved, out string[] assetsThatShouldBeReverted, int explicitlySaveScene) { assetsThatShouldBeReverted = new string[0]; assetsThatShouldBeSaved = assets; bool flag = assets.Length > 0 && EditorPrefs.GetBool("VerifySavingAssets", false) && InternalEditorUtility.isHumanControllingUs; if (explicitlySaveScene != 0 && assets.Length == 1 && assets[0].EndsWith(".unity")) { flag = false; } if (flag) { AssetSaveDialog.ShowWindow(assets, out assetsThatShouldBeSaved); } else { assetsThatShouldBeSaved = assets; } foreach (Type current in AssetModificationProcessorInternal.AssetModificationProcessors) { MethodInfo method = current.GetMethod("OnWillSaveAssets", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { object[] array = new object[] { assetsThatShouldBeSaved }; if (AssetModificationProcessorInternal.CheckArguments(array, method)) { string[] array2 = (string[])method.Invoke(null, array); if (array2 != null) { assetsThatShouldBeSaved = array2; } } } } if (assetsThatShouldBeSaved == null) { return; } List <string> list = new List <string>(); string[] array3 = assetsThatShouldBeSaved; for (int i = 0; i < array3.Length; i++) { string text = array3[i]; if (!AssetDatabase.IsOpenForEdit(text)) { list.Add(text); } } assets = list.ToArray(); if (assets.Length != 0 && !Provider.PromptAndCheckoutIfNeeded(assets, string.Empty)) { Debug.LogError("Could not check out the following files in version control before saving: " + string.Join(", ", assets)); assetsThatShouldBeSaved = new string[0]; return; } }
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); }
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); }
private static bool CheckArgumentTypesAndReturnType(Type[] types, MethodInfo method, Type returnType) { bool result; if (returnType != method.ReturnType) { Debug.LogWarning(string.Concat(new string[] { "Return type mismatch. Expected: ", returnType.ToString(), " Got: ", method.ReturnType.ToString(), " in ", method.DeclaringType.ToString(), ".", method.Name })); result = false; } else { result = AssetModificationProcessorInternal.CheckArgumentTypes(types, method); } return(result); }
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); }
private static void OnWillSaveAssets(string[] assets, out string[] assetsThatShouldBeSaved, out string[] assetsThatShouldBeReverted, int explicitlySaveScene) { assetsThatShouldBeReverted = new string[0]; assetsThatShouldBeSaved = assets; bool flag = assets.Length > 0 && EditorPrefs.GetBool("VerifySavingAssets", false) && InternalEditorUtility.isHumanControllingUs; if (explicitlySaveScene != 0 && assets.Length == 1 && assets[0].EndsWith(".unity")) { flag = false; } if (flag) { AssetSaveDialog.ShowWindow(assets, out assetsThatShouldBeSaved); } else { assetsThatShouldBeSaved = assets; } foreach (System.Type modificationProcessor in AssetModificationProcessorInternal.AssetModificationProcessors) { MethodInfo method = modificationProcessor.GetMethod("OnWillSaveAssets", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { object[] objArray = new object[1] { (object)assetsThatShouldBeSaved }; if (AssetModificationProcessorInternal.CheckArguments(objArray, method)) { string[] strArray = (string[])method.Invoke((object)null, objArray); if (strArray != null) { assetsThatShouldBeSaved = strArray; } } } } if (assetsThatShouldBeSaved == null) { return; } List <string> stringList = new List <string>(); foreach (string assetOrMetaFilePath in assetsThatShouldBeSaved) { if (!AssetDatabase.IsOpenForEdit(assetOrMetaFilePath)) { stringList.Add(assetOrMetaFilePath); } } assets = stringList.ToArray(); if (assets.Length == 0 || Provider.PromptAndCheckoutIfNeeded(assets, string.Empty)) { return; } Debug.LogError((object)("Could not check out the following files in version control before saving: " + string.Join(", ", assets))); assetsThatShouldBeSaved = new string[0]; }
private static bool CheckArgumentsAndReturnType(object[] args, MethodInfo method, Type returnType) { Type[] array = new Type[args.Length]; for (int i = 0; i < args.Length; i++) { array[i] = args[i].GetType(); } return(AssetModificationProcessorInternal.CheckArgumentTypesAndReturnType(array, method, returnType)); }
private static bool CheckArgumentsAndReturnType(object[] args, MethodInfo method, System.Type returnType) { System.Type[] types = new System.Type[args.Length]; for (int index = 0; index < args.Length; ++index) { types[index] = args[index].GetType(); } return(AssetModificationProcessorInternal.CheckArgumentTypesAndReturnType(types, method, returnType)); }
private static bool CheckArgumentTypesAndReturnType(System.Type[] types, MethodInfo method, System.Type returnType) { if (returnType == method.ReturnType) { return(AssetModificationProcessorInternal.CheckArgumentTypes(types, method)); } Debug.LogWarning((object)("Return type mismatch. Expected: " + returnType.ToString() + " Got: " + method.ReturnType.ToString() + " in " + method.DeclaringType.ToString() + "." + method.Name)); return(false); }
public static void IsOpenForEdit(string[] assetOrMetaFilePaths, List <string> outNotEditablePaths, [uei.DefaultValue("StatusQueryOptions.UseCachedIfPossible")] StatusQueryOptions statusQueryOptions = StatusQueryOptions.UseCachedIfPossible) { if (assetOrMetaFilePaths == null) { throw new ArgumentNullException(nameof(assetOrMetaFilePaths)); } if (outNotEditablePaths == null) { throw new ArgumentNullException(nameof(outNotEditablePaths)); } UnityEngine.Profiling.Profiler.BeginSample("AssetDatabase.IsOpenForEdit"); AssetModificationProcessorInternal.IsOpenForEdit(assetOrMetaFilePaths, outNotEditablePaths, statusQueryOptions); UnityEngine.Profiling.Profiler.EndSample(); }
internal static Object CreateScriptAssetWithContent(string pathName, string templateContent) { AssetModificationProcessorInternal.OnWillCreateAsset(pathName); templateContent = SetLineEndings(templateContent, EditorSettings.lineEndingsForNewScripts); string fullPath = Path.GetFullPath(pathName); File.WriteAllText(fullPath, templateContent); // Import the asset AssetDatabase.ImportAsset(pathName); return(AssetDatabase.LoadAssetAtPath(pathName, typeof(Object))); }
private static void OnWillCreateAsset(string path) { foreach (System.Type modificationProcessor in AssetModificationProcessorInternal.AssetModificationProcessors) { MethodInfo method = modificationProcessor.GetMethod("OnWillCreateAsset", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { object[] objArray = new object[1] { (object)path }; if (AssetModificationProcessorInternal.CheckArguments(objArray, method)) { method.Invoke((object)null, objArray); } } } }
internal static void OnStatusUpdated() { WindowPending.OnStatusUpdated(); foreach (Type current in AssetModificationProcessorInternal.AssetModificationProcessors) { MethodInfo method = current.GetMethod("OnStatusUpdated", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { AssetModificationProcessorInternal.RequireTeamLicense(); object[] array = new object[0]; if (AssetModificationProcessorInternal.CheckArgumentsAndReturnType(array, method, typeof(void))) { method.Invoke(null, array); } } } }
private static void OnWillCreateAsset(string path) { foreach (Type current in AssetModificationProcessorInternal.AssetModificationProcessors) { MethodInfo method = current.GetMethod("OnWillCreateAsset", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { object[] array = new object[] { path }; if (AssetModificationProcessorInternal.CheckArguments(array, method)) { method.Invoke(null, array); } } } }
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); }
public static bool IsOpenForEdit(string assetPath, out string message) { return(AssetModificationProcessorInternal.IsOpenForEdit(assetPath, out message)); }
public static bool IsOpenForEdit(string assetOrMetaFilePath, out string message, StatusQueryOptions statusOptions) { return(AssetModificationProcessorInternal.IsOpenForEdit(assetOrMetaFilePath, out message, statusOptions)); }
public static bool IsOpenForEdit(string assetOrMetaFilePath, out string message, [uei.DefaultValue("StatusQueryOptions.UseCachedIfPossible")] StatusQueryOptions statusOptions) { return(AssetModificationProcessorInternal.IsOpenForEdit(assetOrMetaFilePath, out message, statusOptions)); }