yasirkula / UnityImageCropper

A uGUI based image cropping solution for Unity 3D
MIT License
207 stars 33 forks source link

Unity Image Cropper

screenshot

Available on Asset Store: https://assetstore.unity.com/packages/tools/gui/image-cropper-116650

Forum Thread: https://forum.unity.com/threads/released-image-cropper-multiplatform-image-cropping-solution-with-oval-mask-support.526901/

Discord: https://discord.gg/UJJt549AaV

WebGL Demo: http://yasirkula.net/ImageCropperDemo/

GitHub Sponsors ☕

ABOUT

ImageCropper aims to be a powerful, customizable and easy-to-use image cropping solution for Unity 3D. It is created with Unity's UI system.

FEATURES

INSTALLATION

There are 5 ways to install this plugin:

FAQ

Add ENABLE_INPUT_SYSTEM compiler directive to Player Settings/Scripting Define Symbols (these symbols are platform specific, so if you change the active platform later, you'll have to add the compiler directive again).

Remove Unity.InputSystem assembly from ImageCropper.Runtime Assembly Definition File's Assembly Definition References list.

HOW TO

ImageCropper is a singleton object that can be accessed via ImageCropper.Instance. To start cropping a Texture object, you can call the following function:

ImageCropper.Instance.Show( Texture image, CropResult onCrop, Settings settings = null, ImageResizePolicy croppedImageResizePolicy = null )

NOTE: Before calling the Show function, you may want to check the value of ImageCropper.Instance.IsOpen to make sure that the image cropper is not already visible.

NOTE: Crop camera uses Layer 22 to render the thumbnails. On URP, make sure that that layer is included in the Layer Masks of the Forward Renderer asset.

EXAMPLE CODE

See ImageCropperDemo.cs.