Search Unity

Next & Previous

Discussion in 'Scripting' started by CyberGolem, Jun 13, 2014.

  1. CyberGolem

    CyberGolem

    Joined:
    May 1, 2013
    Posts:
    21
    Hi,
    I'm aiming to create an illustrated book with page controls/features similar to a Kindle. Currently I have the ability to go page to page via a GUI button (next and previous) but it doesn't know what page it's on which is creating some issues. The most obvious problem is having to click like crazy to get the button action to grab when I want to change directions (e.g. if there's 20 pages in the book and I go from page 11 to 12, but decide to go back to 11 then I have to click the "previous" button 9 times to get it to finally go to the previous page).

    This is probably due to using an iterative list which always starts from the beginning of its respective list (and goes through every item until it reaches the current page) so I'm searching for a solution that will know what page is being viewed and go from there so that a single click in the opposite direction nets the expected result.

    Any help would be greatly appreciated. BTW I'm using C#.

    Thanks much.
     
  2. Deleted User

    Deleted User

    Guest

    Why don't you just store an integer which counts which page you're on? Increase it when you want to go up a page and decrease it when you want to go down a page.
     
  3. CyberGolem

    CyberGolem

    Joined:
    May 1, 2013
    Posts:
    21