- Home /
Splitting an image to puzzle pieces
I'm trying to develop a game like zigsaw puzzle. what I need is trying to give the player to select any image from the gallery and put it as a puzzle. e.g if I have a picture of 500X500 size in the gallary and if I put it as the puzzle picture. Then I need that picture to crop or split whatever the right word is to particular 9 custom shapes. Is it possible by programming or is there any resource available which will help me in finding the solution of this problem.
As seen below this will be flat image before and i want to convert that flat image into the custom pieces of the given grid. the shape is not rectangle nor square. if cell is custom so Please let me know how can i achieve this. thanks
Answer by NeverHopeless · Aug 03, 2015 at 12:35 PM
You are possibly looking for Masking feature of UI component. You can interact with Show mask graphic
check box to show/hide the mask or enable/disable mask script as well. For masking you need 9 custom shape image and use image for each.
EDIT:
Goto Hierarchy window and follow these steps:
Right click -> UI -> Panel
Inside Panel - right click -> UI -> Image (say Mask)
Inside Panel - right click -> UI -> Image (say BG)
Add
Mask component
on Mask GameObjectSet
Image Source
of BG gameobject.Set
Image Source
of Mask GameObjectSet Mask gameobject over any part of BG gameobject
Make BG child of Mask.
Hi Thanks for your answer. But can you explain a little bit more how should I crop that image into the 12 different maskable image.
Answer by 2Mtech ADMIN · Aug 03, 2015 at 01:41 PM
You have to split the image into the parts you want with a photo editor program, and have several images that fit. Create a UI button for each image and drag the image to the button. Make a script to make them fit when they are the correct combination.
Your answer
![](https://koobas.hobune.stream/wayback/20220611234222im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
polygon crop an image 0 Answers
how to crop image using opencv 1 Answer
Crop face and made it texture for 3d model 0 Answers
jibjab (insert your own face) implementation in Unity 0 Answers