-
-
Notifications
You must be signed in to change notification settings - Fork 182
Home
Dandarawy edited this page Feb 23, 2016
·
3 revisions
The "Unity3D Book Page Curl" is a unity package that is used to create a book with page flip effect using unity3D native UI tools.
Download the unity package from the Releases section, or from unity Asset Store
- Import the unity package
- Create a canvas and EventSystem objects if you don't have one (the easiest way to create them is by adding any UI object then you can delete it).
- Drag a book prefab under the Canvas element
- Resize the book on your scene and reposition the anchors as required.
- Select the book from hierarchy to show it in inspector.
- Assign the canvas to the canvas slot in inspector
- Assign the background sprite with the sprite that you want to show on the right or left side when all pages flipped to the other side.
- To edit the book pages, expand the Book Pages list in inspector, change the Size to your pages count, then start drag your pages in the Element boxes in order
- Set the current page to the page that you want to be shown initially in the right side of the book.
- If you want to call any function when any page flipped add it to the OnFlip Event List.
- If you want to resize the area that the user can drag the page from it, open the Book node in inspector to show its children, you will find two objects "RightHotSpot" and "LeftHotSpot" resize them and set their anchors as required.
- RUN and enjoy the page curl effect!
- After creating your book as mentioned above add an "Auto Flip" component on it.
- Choose flipping direction( if you choose left to right make sure that the current page of the book component is equal to your page count "last page index + 1").
- Uncheck the interactable check in the book component.
- Specify the page flipping time parameters(Page Flip Time, Time Between Pages, Delay before Start flipping, Number of Animation frames for each page flip).
- Check "Auto Start Flip" if you want the book to start flipping automatically, or uncheck it and call the
StartFlipping()
function in your code.
###Control Flipping Manually: This section will explore how to create a scene like the “Example_2_Controled Flipping” scene.
- To be able to let the user control page flipping using some buttons, create your book, add an "Auto Flip" component on it and configured them as mentioned above.
- Uncheck the “interactable” of the book and "Auto Start Flip" of the “Auto Flip” components.
- Add previous and next buttons to your scene (check Example_2_Controled Flipping scene if you have any issues setting them correctly).
- Add a new slot on each button OnClick list by clicking the (+) sign, assign the Book as the game object then select the “AutoFlip -> FlipRightPage” for the next button and “Auto Flip -> Flip Left Page” to the previous button.
- If you need to flip the page from code (based on a custom action) you can call the
FlipLeftPage()
orFlipRightPage()
.