void OnGUI() { if (bookControl == null) return; // we don't have the book set. // is the book open ? if (!bookControl.IsOpen()) { if (GUI.Button(new Rect(0, 5, 164, 90), "Open")) { // Open the book bookControl.Open_Book(); } } else { if (GUI.Button(new Rect(0, 50, 164, 90), "Close")) { // Close the book bookControl.Close_Book(); } // Check to see if we can turn the page if (bookControl.CanTurnPage()) { if (GUI.Button(new Rect(0, 200, 164, 90), "Turn page")) { // Turn the page bookControl.Turn_Page(); } } // Check to see if we can turn back the page. if (bookControl.CanGoBackAPage()) { // Turn back the page. if (GUI.Button(new Rect(0, 300, 164, 90), "Turn page back")) { bookControl.Turn_BackPage(); } } } }
private void SwipeDetector_OnSwipe(SwipeData data) { Debug.Log("Swipe in Direction: " + data.Direction); if (data.Direction == SwipeDirection.Up) { Timeline.SetActive(true); StartCoroutine(TimelineDeactivator()); } if (bookControl == null) return; // we don't have the book set. // is the book open ? if (!bookControl.IsOpen()) { if (data.Direction == SwipeDirection.Left && activePage == 0) { // Open the book bookControl.Open_Book(); activePage =1; Debug.Log(activePage); } } else { if (data.Direction == SwipeDirection.Right && activePage == 1) { // Close the book bookControl.Close_Book(); activePage--; Debug.Log(activePage); } // Check to see if we can turn the page if (bookControl.CanTurnPage()) { if (data.Direction == SwipeDirection.Left && activePage <4) { // Turn the page bookControl.Turn_Page(); activePage++; Debug.Log(activePage); } } // Check to see if we can turn back the page. if (bookControl.CanGoBackAPage()) { // Turn back the page. if (data.Direction == SwipeDirection.Right && activePage > 0) { bookControl.Turn_BackPage(); activePage--; Debug.Log(activePage); } } } }