Ejemplo n.º 1
0
        /// <summary>
        /// Gets a preview of the Bulk Rename that shows the rename steps that will be applied
        /// to each object, if this renamer is used to rename the objects.
        /// </summary>
        /// <returns>The results preview.</returns>
        /// <param name="objectsToRename">Objects to rename.</param>
        public BulkRenamePreview GetBulkRenamePreview(List <UnityEngine.Object> objectsToRename)
        {
            var previews = new RenamePreview[objectsToRename.Count];

            for (int i = 0; i < objectsToRename.Count; ++i)
            {
                var singlePreview = new RenamePreview(
                    objectsToRename[i],
                    this.operationSequence.GetRenamePreview(objectsToRename[i].name, i));
                previews[i] = singlePreview;
            }

            // First collect all assets in directories of preview objects into the assetCache.
            for (int i = 0; i < objectsToRename.Count; ++i)
            {
                var obj = objectsToRename[i];
                if (obj.IsAsset())
                {
                    CacheAsestsInSameDirectoryAsAsset(obj, ref this.assetCache);
                }
            }

            var renameResultPreviews = new BulkRenamePreview(previews, this.assetCache);

            return(renameResultPreviews);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a preview of the Bulk Rename that shows the rename steps that will be applied
        /// to each object, if this renamer is used to rename the objects.
        /// </summary>
        /// <returns>The results preview.</returns>
        /// <param name="objectsToRename">Objects to rename.</param>
        public BulkRenamePreview GetBulkRenamePreview(List <UnityEngine.Object> objectsToRename)
        {
            var renameResultPreviews = new BulkRenamePreview();

            for (int i = 0; i < objectsToRename.Count; ++i)
            {
                var singlePreview = new RenamePreview(
                    objectsToRename[i],
                    this.operationSequence.GetRenamePreview(objectsToRename[i].name, i));
                renameResultPreviews.AddEntry(singlePreview);
            }

            var previewsWithDuplicateNames = GetPreviewsWithDuplicateNames(renameResultPreviews, ref this.assetCache);

            foreach (var preview in previewsWithDuplicateNames)
            {
                preview.WarningMessage = "New name matches an existing file or another renamed object.";
            }

            var previewsWithInvalidCharacters = GetPreviewsWithInvalidCharacters(renameResultPreviews);

            foreach (var preview in previewsWithInvalidCharacters)
            {
                preview.WarningMessage = "Name includes invalid characters (usually symbols such as ?.,).";
            }

            var previewsEmptyNames = GetPreviewsWithEmptyNames(renameResultPreviews);

            foreach (var preview in previewsEmptyNames)
            {
                preview.WarningMessage = "Asset has blank name.";
            }

            return(renameResultPreviews);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds a preview entry into the bulk preview
 /// </summary>
 /// <param name="singlePreview">Single preview.</param>
 public void AddEntry(RenamePreview singlePreview)
 {
     // Keeping a list and a dictionary for fast access by index and by object...
     // Not good to have to keep both structures in sync, though.
     this.RenamePreviews.Add(singlePreview.ObjectToRename, singlePreview);
     this.RenamePreviewsList.Add(singlePreview);
 }
Ejemplo n.º 4
0
 private static string GetWarningMessageForRenamePreview(RenamePreview preview)
 {
     if (preview.HasInvalidEmptyFinalName)
     {
         return("Asset has blank name.");
     }
     else if (preview.FinalNameContainsInvalidCharacters)
     {
         return("Name includes invalid characters (usually symbols such as ?.,).");
     }
     else
     {
         return(string.Empty);
     }
 }
Ejemplo n.º 5
0
 private void AddEntry(RenamePreview singlePreview)
 {
     // Keeping a list and a dictionary for fast access by index and by object...
     this.renamePreviews.Add(singlePreview.ObjectToRename, singlePreview);
     this.renamePreviewsList.Add(singlePreview);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Check if the RenamePreview's final name will match an existing asset's name. This means it will fail
 /// to be renamed if we try.
 /// </summary>
 /// <returns><c>true</c>, if the renamed object's name will collide with existing asset, <c>false</c> otherwise.</returns>
 /// <param name="preview">Preview to check.</param>
 public bool WillRenameCollideWithExistingAsset(RenamePreview preview)
 {
     return(this.duplicatePreviews.Contains(preview));
 }