public void Execute(string duplicatedFilePath, ref ExpectedDuplicationHandling result) { var duplicatedFileName = Path.GetFileName(duplicatedFilePath); if (!m_DecisionID.HasValue) { m_DecisionID = EditorUtility.DisplayDialogComplex("Asset duplication detected!", "File: " + duplicatedFileName + " is duplicated.\n" + "Would you like to move it to the new directory, keep it at previous directory (skip importing this asset), or move it to shared duplications directory?", "New", "Previous", "Shared duplications"); } switch (m_DecisionID.Value) { case 0: // "Move to new directory" UnityEditor.AssetDatabase.DeleteAsset(duplicatedFilePath); break; case 1:// "Keep asset at previous directory" result.ShouldCopyFileNormal = false; break; case 2:// "Move to shared duplications directory" UnityEditor.AssetDatabase.DeleteAsset(duplicatedFilePath); result.DestDirectoryOverride = DuplicationFilesDirectory; break; default: Debug.LogError("[AssetsCopyingHelper] Duplications resolving error! Incorrect decision result!"); break; } }
public ExpectedDuplicationHandling NotifyDuplications(string sourcePath, List <string> duplicatedFilePaths) { string filename = Path.GetFileName(sourcePath); string extension = Path.GetExtension(filename); ExpectedDuplicationHandling result = new ExpectedDuplicationHandling(); if (duplicatedFilePaths.Count == 1) { var duplicatedFilePath = duplicatedFilePaths[0]; DuplicatedBehaviourDecision decision = null; if (s_SavedExtensionsDecisions.ContainsKey(extension)) { decision = s_SavedExtensionsDecisions[extension]; } else { decision = new DuplicatedBehaviourDecision(extension, DuplicationFilesDirectory); } decision.Execute(duplicatedFilePath, ref result); if (!s_SavedExtensionsDecisions.ContainsKey(extension) && EditorUtility.DisplayDialog("Remember decision", "Do you want to remember this decision for further \"*" + extension + "\"duplications resolving?", "Yes", "No")) { s_SavedExtensionsDecisions.Add(extension, decision); } } else if (duplicatedFilePaths.Count > 1) { Debug.LogError("[AssetsCopying] Multiple assets with the same guid detected! Skipping a file (" + sourcePath + ")! Assets:"); foreach (var asset in duplicatedFilePaths) { Debug.LogError("[AssetsCopying] Guid duplication: " + asset); } result.ShouldCopyFileNormal = false; } return(result); }