Skip to content

Instantly share code, notes, and snippets.

@toxicFork
Last active August 29, 2015 14:07
Show Gist options
  • Save toxicFork/1e45420f11f70652ad79 to your computer and use it in GitHub Desktop.
Save toxicFork/1e45420f11f70652ad79 to your computer and use it in GitHub Desktop.
using UnityEditor;
using UnityEngine;
public class TextureAtlasSlicer : EditorWindow {
[MenuItem("CONTEXT/TextureImporter/Slice Sprite Using XML")]
public static void SliceUsingXML(MenuCommand command)
{
TextureImporter textureImporter = command.context as TextureImporter;
TextureAtlasSlicer window = ScriptableObject.CreateInstance<TextureAtlasSlicer>();
window.importer = textureImporter;
window.ShowUtility();
}
[MenuItem("CONTEXT/TextureImporter/Slice Sprite Using XML", true)]
public static bool ValidateSliceUsingXML(MenuCommand command)
{
TextureImporter textureImporter = command.context as TextureImporter;
//valid only if the texture type is 'sprite' or 'advanced'.
return textureImporter && textureImporter.textureType == TextureImporterType.Sprite ||
textureImporter.textureType == TextureImporterType.Advanced;
}
public TextureImporter importer;
public TextureAtlasSlicer()
{
title = "Texture Atlas Slicer";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment