dissertation / mainCode / UI / OptionsMenu.cs
OptionsMenu.cs
Raw
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net;
using TMPro;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;

public class OptionsMenu : MonoBehaviour
{

    public bool hasSetUp = false;
    private string filename = "GAMELOG.json";
    public TextMeshProUGUI filePathText;

    // Start is called before the first frame update
    void Start()
    {
        hasSetUp = true;
        filePathText.color = new Color(filePathText.color.r, filePathText.color.g,
            filePathText.color.b, 0);
    }
    
    

    public void GoToMainMenu()
    {
        SceneManager.LoadScene("MainMenu", LoadSceneMode.Single);
    }

    public void ExportGames()
    {
        var newPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + "/" +
                         filename;
        if (File.Exists(newPath)) {
            File.Delete(newPath);
        }
        File.Copy(Application.persistentDataPath + "/" + filename, newPath);
        var message = "Saved game log file to: " + newPath;
        StartCoroutine(FadeText(message));

    }
    
    private IEnumerator FadeText(string text)
    {
        filePathText.text = text;
        for (float i = 1; i >= 0; i -= Time.deltaTime * 0.4f)
        {
            filePathText.color = new Color(filePathText.color.r, filePathText.color.g,
                filePathText.color.b, i);
            yield return null;
        }
    }
    
}