Book Effect

Book effect lets you add a book to your scene with turning pages. And updated for 2024, you can now set the size and shape of the book.

Download


Available at the Unity Asset Store

Version 3 will be released Feburay 2024.

OlderVersion


Version 3 will be released Feburay 2024. Until then please use Version 2
If you need to check the older version Documation you can found Here


VideoOverView



Example Book


After inporting

Take a look at the two example scenes in the folder Assets\eWolf\BookEffectV3\Scene



To add a book to a scene follow the steps

Create a new empty scene
Drag in the book Prefab
Assets\eWolf\BookEffectV3\Prefabs\Book_Builder_pf.prefab
Then select the book in the scene, and in the inspector click on the Build Book Button

And the book will appear with all it's default material and pages
The Overview section (below) has all the details on what all the options are

To test the book in a running game,

Drag in the book controller Prefab
Assets\eWolf\BookEffectV2\Prefabs\BookHudControl_pf.prefab

Select the BookHudControl_pf

And then drag the Book_Builder_pf game object in to the Book Object field
So it looks like the below.


Now when you run the game, you will see the button to open and close the book, and also turn the pages.

Overview


The updated Book effect package now lets you set the size of the book

Width: The width of the book in units
Height: The height of the book in units
Thinkness: The thinkness of the book when closed
Cover Thinkness: The thinkness of the book cover
Hardback: Not used yet, for future use!


Edge Gap: Gap between the pages and the edge of the book
Page Turn Style: How the page looks when it turns

Cover Inner: Inside cover material
Cover Outter: The book outside material
Inside Back Page: Inside page right side
Inside Front Page: Inside page left side
Pages: Edge of the book. (pages)


Pages: Allow you to add as many textures as needed.


Starting Page: Sets the starting page when the book opens
Start Speed: Set the speed of the animation


When you are ready Click on the Build Book button to create the book


When built, you can use the Open and Close Buttons to view the book open and closed
Each time you change a value above you will need to rebuild the book.

We also have more options to help with defining the Book Cover, that we will take about later.


Define the book cover

As we can now set the thinkness of the book cover
We also need to be able to change how much UV are used for the edge.



This can be done my the Book Cover UV Size Options

UV Cover Width: The % of texture to use from the front cover
UV Cover Border X: The % of the texture to use for the Edge (left and right)
UV Cover Border Y: The % of the texture to use for the Edge (top and bottom)

How to use from Code

To access the book from code you will need to get the IBookControl from the Book (GameObject)

Example Code

public GameObject Book;
private IBookControl _bookControl;

And in the Start methods get the IBookControl

private void Start()
{
    _bookControl = Book.GetComponent<IBookControl>();
}

In the Update code you can open the book with

private void Update()
{
    if (Input.GetKeyDown("o"))
    {
        _bookControl.OpenBook();
    }
}

Back in Unity3D, create an empty object and add this script and then link the book game object to the Book in this script.
When you run that in game it will open the book when you press 'o'

Now you have access to the book you can add extra options like turning the pages with

_bookControl.TurnPage();

To make it safe we will first need to check the book can turn to the next page.
Here is the code to make the page turn from another keypress

if (Input.GetKeyDown("p"))
{
    if (_bookControl.CanTurnPageForward)
    {
        _bookControl.TurnPage();
    }
}


Please NOTE: This video was for Book Effect V2.
but will still work the same way, you just use the Assets\eWolf\BookEffectV3\Prefabs\Book_Builder_pf.prefab

Code Control Options

With access to the IBookControl

You have access to

Can we turn the back backwards
bool CanTurnPageBackWard { get; }


Can we turn the back forward (normal direction)
bool CanTurnPageForward { get; }


Get the book details
IDetails GetDetails { get; }


Is the book currently open
bool IsBookOpen { get; }


Close the Book
void CloseBook();


Open the Book
void OpenBook();


Open the book at a set page
void OpenBookAtPage(int pageIndex);


Set the animation speed for the book
void SetSpeed(float speed);


Trun the page forward (normal)
void TurnPage();


Turn the page backwards
void TurnPageBack();

Support


If you need any more help please email us at Contact@electricWolf.co.uk