rifaterdemsahin / aif

Adaptive Intelligence Framework
5 stars 7 forks source link

dynamic change text #215

Open rifaterdemsahin opened 5 years ago

rifaterdemsahin commented 5 years ago

image

rifaterdemsahin commented 5 years ago

https://americanliterature.com/author/aesop/short-story/the-tortoise-and-the-hare

1) A Hare was making fun of the Tortoise one day for being so slow.

2 ) "Do you ever get anywhere?" he asked with a mocking laugh.

"Yes," replied the Tortoise, "and I get there sooner than you think. I'll run you a race and prove it."

The Hare was much amused at the idea of running a race with the Tortoise, but for the fun of the thing he agreed. So the Fox, who had consented to act as judge, marked the distance and started the runners off.

The Hare was soon far out of sight, and to make the Tortoise feel very deeply how ridiculous it was for him to try a race with a Hare, he lay down beside the course to take a nap until the Tortoise should catch up.

The Tortoise meanwhile kept going slowly but steadily, and, after a time, passed the place where the Hare was sleeping. But the Hare slept on very peacefully; and when at last he did wake up, the Tortoise was near the goal. The Hare now ran his swiftest, but he could not overtake the Tortoise in time.

Slow and steady wins the race.

rifaterdemsahin commented 5 years ago

using UnityEngine; using UnityEngine.UI;

public class loadandUpdate : MonoBehaviour {

private readonly string[] indicator = new string[]{"<b><color='#FF3333'>", "</color></b>"};
private string[] stories = new string[2];

public Text textBox;

//works before start!//can not know when it works///nbetter to write your own init method!
private void Awake()
{
    stories[0] = "A **HareXX was making fun of the Tortoise one day for being so slow.";
    stories[1] = "A **BirdXX was making fun of the Crocodile one day for being so slow.";
}

//IF YOU WANT TO SEE IN THE INSPECTOR...MAKE SURE THE TYPE SHOULD NOT KILL THE UNITY
public void getNewStory(int index)
{
    textBox.text = stories[index].Replace("**", indicator[0]).Replace("XX", indicator[1]);
}

}

rifaterdemsahin commented 5 years ago

image