Hi all, i have previously ask regarding writing data to text file and reading from text file. Mostly is written in C#. So i decide to use C# to code the write data to file. All along i am using javascript for the games. So now i am asking whether javascript and C# can communicate with each other? I create a static array in javascript. So what my C# need to do is to get the data from my js file and then write to the file. Any ideas how i can do it? or the task is impossible?
using UnityEngine;
using System.Collections;
using System;
using System.Text;
using System.IO;
public class Monitor : MonoBehaviour {
String path;
String fileName;
// Use this for initialization
void Start ()
{
fileName = "/Monitoring.txt";
}
// Update is called once per frame
void Update ()
{
path = Application.dataPath + fileName;
using(FileStream fs = File.Create(path))
{
AddText(fs, "hello");
AddText(fs, "______________________________________________");
AddText(fs, "
and this is on a new line");
AddText(fs, "
The following is a subset of characters:
");
}
}
private static void AddText(FileStream fs, string value)
{
byte[] info = new UTF8Encoding(true).GetBytes(value);
fs.Write(info, 0, info.Length);
}
}