Book Effect(2023) Version

Book effect lets you add a book to your scene with turning pages. And by using the interface you have actions to open, close the book and turn the pages forward and back. All pages are added to the Inspector as textures.

Demo Video


Download


Available at the Unity Asset Store


How to use Unity

Add the eWolf\BookEffectV2\Prefabs\Book_Normal_pf.prefab into your scene.

Next you will need add the pages


Set the number of pages size for wish to use

Then add all the pages in to the array



You can quicky test the book by adding the prefab
eWolf\BookEffectV2\Prefabs\BookHudControl_pf

Then link this to your book.



And run the game and use the HUD options to use the book.


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();
    }
}



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