- Home /
Sprite cropping
Is there still no good way to accomplish this within the current version of Unity3D (2D)?
What would be the best way to crop a sprite in Unity 4.3. I have a Sprite object and I want to crop it as displayed in the images below:-
Original sprite Cropped sprite
I could just create separate images to achieve my goal. However being new to Unity I am sure there is a more elegant way of doing this in code that I am unaware of?
Answer by Andres-Fernandez · Jul 07, 2014 at 09:58 AM
You can use the Sprite Packer to create 2 different sprites from the same image (one sprite for the original sprite and another sprite for the cropped sprite).
Answer by Dave-Carlile · Jul 01, 2015 at 08:51 PM
You can create a sprite from anywhere in a texture using Sprite.Create.
Answer by impdesign · Jan 31, 2017 at 12:11 PM
Found this solution on a different forum post:
Try using UI image, change the image type to Filled, change the fill method to Horizontal, change the Fill origin to Right ,change the Fill amount to 1/2 or 0.5.
image.GetComponent<Image>().fillAmount = .5f;
Your answer
Follow this Question
Related Questions
Sprite not visible from behind 0 Answers
ShaderGraph Position from Texture Sample Issue 0 Answers
"Blend SrcFactor DstFactor, SrcFactorA DstFactorA" Does not work 2 Answers
Sprite masking 3 Answers
Shader sprite overlay other sprites 0 Answers