Skip to main content
Minor grammar fixes, markdown formatting
Source Link
liggiorgio
  • 4.9k
  • 6
  • 26
  • 37

I'm trying to implement readable books into my game. Much like Morrowind and Skyrim. I have a system that sort of works, but it appears as though there is a bug that is duplicating some page data, and trimming other page data. I've tried to google search for a solution, but can't seem to find one. I'm thinking this is an issue with how the pages are turned, perhaps I am missing something along the path to accomplishing this. Here'sHere are two pictures showing off the problem:

Page 1 to 2   

Page 3 to 4

<size=125%>TheThe Legend of the Quick Brown Fox

There once was a quick brown fox, who nimbly jumped over a lazy dog.

The lazy dog was not amused, and <color="red">triedtried to catch the fox. However, being that the dog was far too fat and lazy to move, the fox managed to escape the clutches of the dog.

But then, given time, the dog decided to make a change. It started eating healthy, started working out. Waiting for the day when the quick brown fox would return.

And on a cold day, that's exactly what happened. The quick brown fox came from beyond the forest, and locked eyes on the dog who was seemingly fast asleep.

Without hesitation, the quick brown fox took off across the field and lept over the dog, only to be immediately snatched out of the air and ripped to shreds by the dog.

And everyone lived happily ever after. The end.

As you can see from the images, there is some duplicated text on pagepages 2 and 3, and then some text is missing completely.

Here is a picture of the game object setup:   

enter image description here

Here is a picture of the TextMeshPro Text object:   

enter image description here

And finally, Here'sHere are the objects and data being assigned to the script.   

enter image description here

Can anyone spot why some of the text is duplicated, and why some of it is missing? I have a feeling it's related to the way the page turning-turning works, but I can't seem to fix it.

I'm trying to implement readable books into my game. Much like Morrowind and Skyrim. I have a system that sort of works, but it appears as though there is a bug that is duplicating some page data, and trimming other page data. I've tried to google search a solution, but can't seem to find one. I'm thinking this is an issue with how the pages are turned, perhaps I am missing something along the path to accomplishing this. Here's two pictures showing off the problem:

Page 1 to 2  Page 3 to 4

<size=125%>The Legend of the Quick Brown Fox

There once was a quick brown fox, who nimbly jumped over a lazy dog.

The lazy dog was not amused, and <color="red">tried to catch the fox. However, being that the dog was far too fat and lazy to move, the fox managed to escape the clutches of the dog.

But then, given time, the dog decided to make a change. It started eating healthy, started working out. Waiting for the day when the quick brown fox would return.

And on a cold day, that's exactly what happened. The quick brown fox came from beyond the forest, and locked eyes on the dog who was seemingly fast asleep.

Without hesitation, the quick brown fox took off across the field and lept over the dog, only to be immediately snatched out of the air and ripped to shreds by the dog.

And everyone lived happily ever after. The end.

As you can see from the images, there is some duplicated text on page 2 and 3, and then some text is missing completely.

Here is a picture of the game object setup:  enter image description here

Here is a picture of the TextMeshPro Text object:  enter image description here

And finally, Here's the objects and data being assigned to the script.  enter image description here

Can anyone spot why some of the text is duplicated, and why some of it is missing? I have a feeling it's related to the way the page turning works, but I can't seem to fix it.

I'm trying to implement readable books into my game. Much like Morrowind and Skyrim. I have a system that sort of works, but it appears as though there is a bug that is duplicating some page data, and trimming other page data. I've tried to google search for a solution, but can't seem to find one. I'm thinking this is an issue with how the pages are turned, perhaps I am missing something along the path to accomplishing this. Here are two pictures showing off the problem:

Page 1 to 2 

Page 3 to 4

The Legend of the Quick Brown Fox

There once was a quick brown fox, who nimbly jumped over a lazy dog.

The lazy dog was not amused, and tried to catch the fox. However, being that the dog was far too fat and lazy to move, the fox managed to escape the clutches of the dog.

But then, given time, the dog decided to make a change. It started eating healthy, started working out. Waiting for the day when the quick brown fox would return.

And on a cold day, that's exactly what happened. The quick brown fox came from beyond the forest, and locked eyes on the dog who was seemingly fast asleep.

Without hesitation, the quick brown fox took off across the field and lept over the dog, only to be immediately snatched out of the air and ripped to shreds by the dog.

And everyone lived happily ever after. The end.

As you can see from the images, there is some duplicated text on pages 2 and 3, and then some text is missing completely.

Here is a picture of the game object setup: 

enter image description here

Here is a picture of the TextMeshPro Text object: 

enter image description here

And finally, Here are the objects and data being assigned to the script. 

enter image description here

Can anyone spot why some of the text is duplicated, and why some of it is missing? I have a feeling it's related to the way the page-turning works, but I can't seem to fix it.

Made the example text more readable and then had to make some meaningless tweaks to reach the edit minimums
Source Link
<size=125%>The Legend of the Quick Brown Fox</size><br><br>There once was a quick brown fox, who nimbly jumped over a lazy dog. <br><br><u>The lazy dog was not amused</u>, and <color="red">tried to catch the fox.</color> However, being that the dog was far too fat and lazy to move, the fox managed to escape the clutches of the dog.<br><br> But then, given time, the dog decided to make a change. It started eating healthy, started working out. Waiting for the day when the quick brown fox would return.<br><br>And on a cold day, that's exactly what happened. The quick brown fox came from beyond the forest, and locked eyes on the dog who was seemingly fast asleep.<br><br>Without hesitation, the quick brown fox took off across the field and lept over the dog, only to be immediately snatched out of the air and ripped to shreds by the dog.<br><br>And everyone lived happily ever after. The end.

<size=125%>The Legend of the Quick Brown Fox

There once was a quick brown fox, who nimbly jumped over a lazy dog.

The lazy dog was not amused, and <color="red">tried to catch the fox. However, being that the dog was far too fat and lazy to move, the fox managed to escape the clutches of the dog.

But then, given time, the dog decided to make a change. It started eating healthy, started working out. Waiting for the day when the quick brown fox would return.

And on a cold day, that's exactly what happened. The quick brown fox came from beyond the forest, and locked eyes on the dog who was seemingly fast asleep.

Without hesitation, the quick brown fox took off across the field and lept over the dog, only to be immediately snatched out of the air and ripped to shreds by the dog.

And everyone lived happily ever after. The end.

I would post the object for the right page, but it's literally the exact same as the left, with the only difference being that it's marked as page number 2 instead of 1.

<size=125%>The Legend of the Quick Brown Fox</size><br><br>There once was a quick brown fox, who nimbly jumped over a lazy dog. <br><br><u>The lazy dog was not amused</u>, and <color="red">tried to catch the fox.</color> However, being that the dog was far too fat and lazy to move, the fox managed to escape the clutches of the dog.<br><br> But then, given time, the dog decided to make a change. It started eating healthy, started working out. Waiting for the day when the quick brown fox would return.<br><br>And on a cold day, that's exactly what happened. The quick brown fox came from beyond the forest, and locked eyes on the dog who was seemingly fast asleep.<br><br>Without hesitation, the quick brown fox took off across the field and lept over the dog, only to be immediately snatched out of the air and ripped to shreds by the dog.<br><br>And everyone lived happily ever after. The end.

I would post the object for the right page, but it's literally the exact same as the left, with the only difference being that it's marked as page 2 instead of 1.

<size=125%>The Legend of the Quick Brown Fox

There once was a quick brown fox, who nimbly jumped over a lazy dog.

The lazy dog was not amused, and <color="red">tried to catch the fox. However, being that the dog was far too fat and lazy to move, the fox managed to escape the clutches of the dog.

But then, given time, the dog decided to make a change. It started eating healthy, started working out. Waiting for the day when the quick brown fox would return.

And on a cold day, that's exactly what happened. The quick brown fox came from beyond the forest, and locked eyes on the dog who was seemingly fast asleep.

Without hesitation, the quick brown fox took off across the field and lept over the dog, only to be immediately snatched out of the air and ripped to shreds by the dog.

And everyone lived happily ever after. The end.

I would post the object for the right page, but it's literally the exact same as the left, with the only difference being that it's marked as page number 2 instead of 1.

Source Link
Krythic
  • 790
  • 8
  • 17

TextMeshPro Page Mode Issue (Readable Books In game)

I'm trying to implement readable books into my game. Much like Morrowind and Skyrim. I have a system that sort of works, but it appears as though there is a bug that is duplicating some page data, and trimming other page data. I've tried to google search a solution, but can't seem to find one. I'm thinking this is an issue with how the pages are turned, perhaps I am missing something along the path to accomplishing this. Here's two pictures showing off the problem:

Page 1 to 2 Page 3 to 4

And here is the text that it's supposed to be displaying:

<size=125%>The Legend of the Quick Brown Fox</size><br><br>There once was a quick brown fox, who nimbly jumped over a lazy dog. <br><br><u>The lazy dog was not amused</u>, and <color="red">tried to catch the fox.</color> However, being that the dog was far too fat and lazy to move, the fox managed to escape the clutches of the dog.<br><br> But then, given time, the dog decided to make a change. It started eating healthy, started working out. Waiting for the day when the quick brown fox would return.<br><br>And on a cold day, that's exactly what happened. The quick brown fox came from beyond the forest, and locked eyes on the dog who was seemingly fast asleep.<br><br>Without hesitation, the quick brown fox took off across the field and lept over the dog, only to be immediately snatched out of the air and ripped to shreds by the dog.<br><br>And everyone lived happily ever after. The end.

As you can see from the images, there is some duplicated text on page 2 and 3, and then some text is missing completely.

Here is the code I'm using to achieve this:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using TMPro;


public class BookContents : MonoBehaviour
{
    [TextArea(10, 20)][SerializeField] private string content;
    [Space][SerializeField] private TMP_Text leftSide;
    [SerializeField] private TMP_Text rightSide;
    [Space][SerializeField] private TMP_Text leftPagination;
    [SerializeField] private TMP_Text rightPagination;

    private void OnValidate()
    {
        UpdatePagination();

        if (leftSide.text == content)
        {
            return;
        }

        SetupContent();
    }

    private void Awake()
    {
        SetupContent();
        UpdatePagination();
    }

    private void SetupContent()
    {
        leftSide.text = content;
        rightSide.text = content;
    }

    private void UpdatePagination()
    {
        leftPagination.text = leftSide.pageToDisplay.ToString();
        rightPagination.text = rightSide.pageToDisplay.ToString();
    }

    public void PreviousPage()
    {
        if (leftSide.pageToDisplay < 1)
        {
            leftSide.pageToDisplay = 1;
            return;
        }

        if (leftSide.pageToDisplay - 2 > 1)
        {
            leftSide.pageToDisplay -= 2;
        }
        else
        {
            leftSide.pageToDisplay = 1;
        }
        rightSide.pageToDisplay = leftSide.pageToDisplay + 1;

        UpdatePagination();
    }

    public void NextPage()
    {
        if (rightSide.pageToDisplay >= rightSide.textInfo.pageCount)
        {
            return;
        }

        if (leftSide.pageToDisplay >= leftSide.textInfo.pageCount - 1)
        {
            leftSide.pageToDisplay = leftSide.textInfo.pageCount - 1;
            rightSide.pageToDisplay = leftSide.pageToDisplay + 1;
        }
        else
        {
            leftSide.pageToDisplay += 2;
            
        }
        rightSide.pageToDisplay = leftSide.pageToDisplay + 1;

        UpdatePagination();
    }
}

Here is a picture of the game object setup: enter image description here

Here is a picture of the TextMeshPro Text object: enter image description here

I would post the object for the right page, but it's literally the exact same as the left, with the only difference being that it's marked as page 2 instead of 1.

And finally, Here's the objects and data being assigned to the script. enter image description here

Can anyone spot why some of the text is duplicated, and why some of it is missing? I have a feeling it's related to the way the page turning works, but I can't seem to fix it.