Exemple #1
0
        internal static bool DeleteAssets(List <int> instanceIDs, bool askIfSure)
        {
            bool result;

            if (instanceIDs.Count == 0)
            {
                result = true;
            }
            else
            {
                bool flag = instanceIDs.IndexOf(ProjectBrowserColumnOneTreeViewDataSource.GetAssetsFolderInstanceID()) >= 0;
                if (flag)
                {
                    string title = "Cannot Delete";
                    EditorUtility.DisplayDialog(title, "Deleting the 'Assets' folder is not allowed", "Ok");
                    result = false;
                }
                else
                {
                    List <string> list = ProjectWindowUtil.GetMainPathsOfAssets(instanceIDs).ToList <string>();
                    if (list.Count == 0)
                    {
                        result = false;
                    }
                    else
                    {
                        if (askIfSure)
                        {
                            string text = "Delete selected asset";
                            if (list.Count > 1)
                            {
                                text += "s";
                            }
                            text += "?";
                            int    num   = 3;
                            string text2 = "";
                            int    num2  = 0;
                            while (num2 < list.Count && num2 < num)
                            {
                                text2 = text2 + "   " + list[num2] + "\n";
                                num2++;
                            }
                            if (list.Count > num)
                            {
                                text2 += "   ...\n";
                            }
                            text2 += "\nYou cannot undo this action.";
                            if (!EditorUtility.DisplayDialog(text, text2, "Delete", "Cancel"))
                            {
                                result = false;
                                return(result);
                            }
                        }
                        bool flag2 = true;
                        AssetDatabase.StartAssetEditing();
                        foreach (string current in list)
                        {
                            if (!AssetDatabase.MoveAssetToTrash(current))
                            {
                                flag2 = false;
                            }
                        }
                        AssetDatabase.StopAssetEditing();
                        result = flag2;
                    }
                }
            }
            return(result);
        }