Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.UI;
- public class simple_game : MonoBehaviour
- {
- public Text text; // поле вывода
- private List<string> list;
- int r;//номер факта
- public GameObject next;//кнопка след. факта
- public void Start()
- {
- list = File.ReadAllLines(Application.dataPath + "/resources/simple_q.txt").ToList();
- // Debug.Log($"В файле найдено строк {list.Count} строк");
- GenerateFacts();
- }
- public void GenerateFacts()
- {
- if (list.Count > 0)//Если в листе есть факты то...
- {
- r = Random.Range(0, list.Count);// случайное число от 0 до кол-ва фактов
- text.text = list[r];
- list.RemoveAt(r);//удаляем факт
- //Debug.Log($"вы нажали на кнопку, осталось {list.Count} фактов");
- }
- else
- {
- next.SetActive(false);
- text.text = "Пока что на этом всё";
- //Debug.Log("факты закончились, кнопка выключена");
- }
- }
- public void close()// кнопка выход в меню
- {
- SceneManager.LoadScene("categories");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement