Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2017
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. [System.Serializable]
  2. public class TextOfTweet
  3. {
  4. public string text;
  5. }
  6.  
  7. [System.Serializable]
  8. public class RootObject
  9. {
  10. public List<TextOfTweet> tweetTexts;
  11. }
  12.  
  13. public class MoveTweetDown : MonoBehaviour {
  14. private int thisSpeed;
  15.  
  16. private void OnEnable()
  17. {
  18. thisSpeed = LevelManager.current.speedOfTweets;
  19. string path = Application.streamingAssetsPath + "/Covfefefiltered.json";
  20. string jsonString = File.ReadAllText(path);
  21. RootObject textForTweet = JsonUtility.FromJson<RootObject>(jsonString);
  22. Debug.Log(textForTweet.tweetTexts[0].text); //Error ArgumentOutOfRangeException here
  23. int randomTweetN = Random.Range(0, textForTweet.tweetTexts.Count);
  24.  
  25. gameObject.GetComponentInChildren<TextMesh>().text = textForTweet.tweetTexts[randomTweetN].text;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement