-
-
Save toxicFork/1e45420f11f70652ad79 to your computer and use it in GitHub Desktop.
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 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