CSharpReview in unity

CSharpReview

using System.Collections.Generic;
using UnityEngine; 
using TMPro;
using System.IO;
using System.Linq;

public class CSharpReview : MonoBehaviour
{
    public TMP_InputField contextview; public string CodeName;

    public void CodeReader()
    {
        string textreader = Application.dataPath + "/" + CodeName + ".cs";

        List<string> finallines = File.ReadAllLines(textreader).ToList();

        foreach (string line in finallines)
        {
            contextview.text += line + "\n";
        }
    }


    public void CodeSaver()
    {
        string textsaver = Application.dataPath + "/" + CodeName + ".cs";

        if (File.Exists(textsaver))
        {
            File.Delete(textsaver);
        }

        File.AppendAllText(textsaver, contextview.text + "\n");
    }
}


Content ©2023 Abolfazl Tanha All Rights Reserved​​​​​​​