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 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 void RebuildLists(bool selected) { this.m_LV.totalRows = this.m_Assets.Count; this.m_SelectedItems = new bool[this.m_Assets.Count]; this.m_Content = new List <GUIContent>(this.m_Assets.Count); for (int i = 0; i < this.m_Assets.Count; i++) { this.m_SelectedItems[i] = selected; this.m_Content.Add(AssetSaveDialog.GetContentForAsset(this.m_Assets[i])); } }
public static void ShowWindow(string[] inAssets, out string[] assetsThatShouldBeSaved) { int numMetaFiles = 0; foreach (string path in inAssets) { if (path.EndsWith("meta")) { numMetaFiles++; } } int numAssets = inAssets.Length - numMetaFiles; if (numAssets == 0) { assetsThatShouldBeSaved = inAssets; return; } string[] assets = new string[numAssets]; string[] metaFiles = new string[numMetaFiles]; numAssets = 0; numMetaFiles = 0; foreach (string path in inAssets) { if (path.EndsWith("meta")) { metaFiles[numMetaFiles++] = path; } else { assets[numAssets++] = path; } } AssetSaveDialog win = EditorWindow.GetWindowDontShow <AssetSaveDialog>(); win.titleContent = EditorGUIUtility.TrTextContent("Save Assets"); win.SetAssets(assets); win.minSize = new Vector2(400, 100); win.maxSize = new Vector2(550, 550); win.ShowModalUtility(); win.ShowModal(); assetsThatShouldBeSaved = new string[win.m_AssetsToSave.Count + numMetaFiles]; win.m_AssetsToSave.CopyTo(assetsThatShouldBeSaved, 0); metaFiles.CopyTo(assetsThatShouldBeSaved, win.m_AssetsToSave.Count); }
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 type in AssetModificationProcessors) { MethodInfo method = type.GetMethod("OnWillSaveAssets", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); if (method != null) { object[] args = new object[] { assetsThatShouldBeSaved }; if (CheckArguments(args, method)) { string[] strArray = (string[])method.Invoke(null, args); if (strArray != null) { assetsThatShouldBeSaved = strArray; } } } } if (assetsThatShouldBeSaved != null) { List <string> list = new List <string>(); foreach (string str in assetsThatShouldBeSaved) { if (!AssetDatabase.IsOpenForEdit(str, StatusQueryOptions.ForceUpdate)) { list.Add(str); } } assets = list.ToArray(); if ((assets.Length != 0) && !Provider.PromptAndCheckoutIfNeeded(assets, "")) { Debug.LogError("Could not check out the following files in version control before saving: " + string.Join(", ", assets)); assetsThatShouldBeSaved = new string[0]; } } }
public static void ShowWindow(string[] inAssets, out string[] assetsThatShouldBeSaved) { int num = 0; for (int i = 0; i < inAssets.Length; i++) { string text = inAssets[i]; if (text.EndsWith("meta")) { num++; } } int num2 = inAssets.Length - num; if (num2 == 0) { assetsThatShouldBeSaved = inAssets; } else { string[] array = new string[num2]; string[] array2 = new string[num]; num2 = 0; num = 0; for (int j = 0; j < inAssets.Length; j++) { string text2 = inAssets[j]; if (text2.EndsWith("meta")) { array2[num++] = text2; } else { array[num2++] = text2; } } AssetSaveDialog windowDontShow = EditorWindow.GetWindowDontShow <AssetSaveDialog>(); windowDontShow.titleContent = EditorGUIUtility.TextContent("Save Assets"); windowDontShow.SetAssets(array); windowDontShow.ShowUtility(); windowDontShow.ShowModal(); assetsThatShouldBeSaved = new string[windowDontShow.m_AssetsToSave.Count + num]; windowDontShow.m_AssetsToSave.CopyTo(assetsThatShouldBeSaved, 0); array2.CopyTo(assetsThatShouldBeSaved, windowDontShow.m_AssetsToSave.Count); } }
public static void ShowWindow(string[] inAssets, out string[] assetsThatShouldBeSaved) { int num = 0; foreach (string str in inAssets) { if (str.EndsWith("meta")) { num++; } } int num3 = inAssets.Length - num; if (num3 == 0) { assetsThatShouldBeSaved = inAssets; } else { string[] assets = new string[num3]; string[] strArray3 = new string[num]; num3 = 0; num = 0; foreach (string str2 in inAssets) { if (str2.EndsWith("meta")) { strArray3[num++] = str2; } else { assets[num3++] = str2; } } AssetSaveDialog windowDontShow = EditorWindow.GetWindowDontShow <AssetSaveDialog>(); windowDontShow.titleContent = EditorGUIUtility.TextContent("Save Assets"); windowDontShow.SetAssets(assets); windowDontShow.ShowUtility(); windowDontShow.ShowModal(); assetsThatShouldBeSaved = new string[windowDontShow.m_AssetsToSave.Count + num]; windowDontShow.m_AssetsToSave.CopyTo(assetsThatShouldBeSaved, 0); strArray3.CopyTo(assetsThatShouldBeSaved, windowDontShow.m_AssetsToSave.Count); } }
public static void ShowWindow(string[] inAssets, out string[] assetsThatShouldBeSaved) { int length1 = 0; foreach (string inAsset in inAssets) { if (inAsset.EndsWith("meta")) { ++length1; } } int length2 = inAssets.Length - length1; if (length2 == 0) { assetsThatShouldBeSaved = inAssets; } else { string[] assets = new string[length2]; string[] strArray = new string[length1]; int num1 = 0; int num2 = 0; foreach (string inAsset in inAssets) { if (inAsset.EndsWith("meta")) { strArray[num2++] = inAsset; } else { assets[num1++] = inAsset; } } AssetSaveDialog windowDontShow = EditorWindow.GetWindowDontShow <AssetSaveDialog>(); windowDontShow.titleContent = EditorGUIUtility.TextContent("Save Assets"); windowDontShow.SetAssets(assets); windowDontShow.ShowUtility(); windowDontShow.ShowModal(); assetsThatShouldBeSaved = new string[windowDontShow.m_AssetsToSave.Count + num2]; windowDontShow.m_AssetsToSave.CopyTo(assetsThatShouldBeSaved, 0); strArray.CopyTo((Array)assetsThatShouldBeSaved, windowDontShow.m_AssetsToSave.Count); } }
// Postprocess on all assets once an automatic import has completed // ReSharper disable once UnusedMember.Local - invoked from native code static void OnWillSaveAssets(string[] assets, out string[] assetsThatShouldBeSaved, out string[] assetsThatShouldBeReverted, bool explicitlySaveAsset) { assetsThatShouldBeReverted = new string[0]; assetsThatShouldBeSaved = assets; bool showSaveDialog = assets.Length > 0 && EditorPrefs.GetBool("VerifySavingAssets", false) && InternalEditorUtility.isHumanControllingUs; // If we are only saving a single scene or prefab and the user explicitly said we should, skip the dialog. We don't need // to verify this twice. if (explicitlySaveAsset && assets.Length == 1 && (assets[0].EndsWith(".unity") || assets[0].EndsWith(".prefab"))) { showSaveDialog = false; } if (showSaveDialog) { AssetSaveDialog.ShowWindow(assets, out assetsThatShouldBeSaved); } else { assetsThatShouldBeSaved = assets; } foreach (var assetModificationProcessorClass in AssetModificationProcessors) { MethodInfo method = assetModificationProcessorClass.GetMethod("OnWillSaveAssets", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); if (method != null) { object[] args = { assetsThatShouldBeSaved }; if (!CheckArguments(args, method)) { continue; } string[] result = (string[])method.Invoke(null, args); if (result != null) { assetsThatShouldBeSaved = result; } } } if (assetsThatShouldBeSaved == null) { return; } var assetsNotOpened = new List <string>(); AssetDatabase.IsOpenForEdit(assetsThatShouldBeSaved, assetsNotOpened, StatusQueryOptions.ForceUpdate); assets = assetsNotOpened.ToArray(); // Try to checkout if needed var notEditableAssets = new List <string>(); if (assets.Length != 0 && !AssetDatabase.MakeEditable(assets, null, notEditableAssets)) { // only save assets that can be made editable (not locked by someone else, etc.), // unless we are in the behavior mode that just overwrites everything anyway if (!EditorUserSettings.overwriteFailedCheckoutAssets) { assetsThatShouldBeReverted = notEditableAssets.ToArray(); assetsThatShouldBeSaved = assetsThatShouldBeSaved.Except(assetsThatShouldBeReverted).ToArray(); } } }
// Postprocess on all assets once an automatic import has completed static void OnWillSaveAssets(string[] assets, out string[] assetsThatShouldBeSaved, out string[] assetsThatShouldBeReverted, int explicitlySaveAsset) { assetsThatShouldBeReverted = new string[0]; assetsThatShouldBeSaved = assets; bool showSaveDialog = assets.Length > 0 && EditorPrefs.GetBool("VerifySavingAssets", false) && InternalEditorUtility.isHumanControllingUs; // If we are only saving a single scene or prefab and the user explicitly said we should, skip the dialog. We don't need // to verify this twice. if (explicitlySaveAsset != 0 && assets.Length == 1 && (assets[0].EndsWith(".unity") || assets[0].EndsWith(".prefab"))) { showSaveDialog = false; } if (showSaveDialog) { AssetSaveDialog.ShowWindow(assets, out assetsThatShouldBeSaved); } else { assetsThatShouldBeSaved = assets; } foreach (var assetModificationProcessorClass in AssetModificationProcessors) { MethodInfo method = assetModificationProcessorClass.GetMethod("OnWillSaveAssets", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); if (method != null) { object[] args = { assetsThatShouldBeSaved }; if (!CheckArguments(args, method)) { continue; } string[] result = (string[])method.Invoke(null, args); if (result != null) { assetsThatShouldBeSaved = result; } } } if (assetsThatShouldBeSaved == null) { return; } var assetsNotOpened = new List <string>(); foreach (string asset in assetsThatShouldBeSaved) { if (!AssetDatabase.IsOpenForEdit(asset, StatusQueryOptions.ForceUpdate)) { assetsNotOpened.Add(asset); } } assets = assetsNotOpened.ToArray(); // Try to checkout if needed. This may fail but is catched below. if (assets.Length != 0 && !Provider.PromptAndCheckoutIfNeeded(assets, "")) { Debug.LogError("Could not check out the following files in version control before saving: " + string.Join(", ", assets)); assetsThatShouldBeSaved = new string[0]; return; } }
// Postprocess on all assets once an automatic import has completed static void OnWillSaveAssets(string[] assets, out string[] assetsThatShouldBeSaved, out string[] assetsThatShouldBeReverted, bool explicitlySaveAsset) { assetsThatShouldBeReverted = new string[0]; assetsThatShouldBeSaved = assets; bool showSaveDialog = assets.Length > 0 && EditorPrefs.GetBool("VerifySavingAssets", false) && InternalEditorUtility.isHumanControllingUs; // If we are only saving a single scene or prefab and the user explicitly said we should, skip the dialog. We don't need // to verify this twice. if (explicitlySaveAsset && assets.Length == 1 && (assets[0].EndsWith(".unity") || assets[0].EndsWith(".prefab"))) { showSaveDialog = false; } if (showSaveDialog) { AssetSaveDialog.ShowWindow(assets, out assetsThatShouldBeSaved); } else { assetsThatShouldBeSaved = assets; } foreach (var assetModificationProcessorClass in AssetModificationProcessors) { MethodInfo method = assetModificationProcessorClass.GetMethod("OnWillSaveAssets", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); if (method != null) { object[] args = { assetsThatShouldBeSaved }; if (!CheckArguments(args, method)) { continue; } string[] result = (string[])method.Invoke(null, args); if (result != null) { assetsThatShouldBeSaved = result; } } } if (assetsThatShouldBeSaved == null) { return; } var assetsNotOpened = new List <string>(); foreach (string asset in assetsThatShouldBeSaved) { if (!AssetDatabase.IsOpenForEdit(asset, StatusQueryOptions.ForceUpdate)) { assetsNotOpened.Add(asset); } } assets = assetsNotOpened.ToArray(); // Try to checkout if needed. This may fail but is caught below. var editableAssets = new string[assets.Length]; if (assets.Length != 0 && !Provider.MakeEditable(assets, editableAssets)) { // TODO: fix this behaviour to make save asset honour version control result // keep previous behaviour which is save all assets even if checkout fails // TODO: this needs to consider and handle saving assets which have not been // added to version control. They have to be added to version control before // calling MakeEditable. //assetsThatShouldBeSaved = editableAssets; return; } }