Last active
December 29, 2015 10:19
Unity3D Editor Script that renames .atlas files on import to .atlas.txt. Put this script in an "Editor" subfolder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using System.IO; | |
/// <summary> | |
/// editor script that renames imported .atlas files to .atlas.txt files | |
/// </summary> | |
public class AtlasFileRenamer : AssetPostprocessor | |
{ | |
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) | |
{ | |
bool refresh = false; | |
foreach (string importedAssetPath in importedAssets) | |
{ | |
string ext = Path.GetExtension(importedAssetPath); | |
// rename .atlas file to .atlas.txt | |
if (ext == ".atlas") | |
{ | |
string newFileName = Path.ChangeExtension(importedAssetPath, ".atlas.txt"); | |
// delete old file if it exists | |
AssetDatabase.DeleteAsset(newFileName); | |
// rename new file | |
FileUtil.MoveFileOrDirectory(importedAssetPath, newFileName); | |
// mark editor for refresh after all renamings | |
refresh = true; | |
} | |
} | |
if (refresh) | |
{ | |
AssetDatabase.Refresh(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment