void CropTextures(GraphicsDeviceManager Graphics) { BackgraoundTexture = CropTexture.Crop(Graphics, OriginalTexture, BackgraoundSourceRec); TopLineTexture = CropTexture.Crop(Graphics, OriginalTexture, TopLineSourceRec); RightLineTexture = CropTexture.Crop(Graphics, OriginalTexture, RightSourceLineRec); BottomLineTexture = CropTexture.Crop(Graphics, OriginalTexture, BottomSourceLineRec); LeftLineTexture = CropTexture.Crop(Graphics, OriginalTexture, LeftSourceLineRec); TopLeftCornerTexture = CropTexture.Crop(Graphics, OriginalTexture, TopLeftCorenerSourceRec); TopRightCornerTexture = CropTexture.Crop(Graphics, OriginalTexture, TopRightCorenerSourceRec); BottomRightCornerTexture = CropTexture.Crop(Graphics, OriginalTexture, BottomRightCorenerSourceRec); BottomLeftCornerTexture = CropTexture.Crop(Graphics, OriginalTexture, BottomLeftCorenerSourceRec); }
static void _CropTexture(MenuCommand menuCommand) { if (Selection.objects[0] != null && Selection.objects[0] is Texture2D) { texture = Selection.objects[0] as Texture2D; string path = AssetDatabase.GetAssetPath(Selection.objects[0].GetInstanceID()); TextureImporter importer = AssetImporter.GetAtPath(path) as TextureImporter; if (!importer.isReadable) { Debug.Log("Texture is not read/write enabled."); } else { CropTexture window = ScriptableObject.CreateInstance <CropTexture>(); window.position = new Rect(Screen.width / 2, Screen.height / 2, 200, 370); window.maxSize = new Vector2(200, 370); window.minSize = window.maxSize; window.ShowUtility(); } } }