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