I need to write and read config from a external file, the problem is... The function that write changes in the file is written (evidently) in C#, but the GUI script that calls the C# function is written in Js... If I call it like a Js function not works...
c# function is here: (Writer.cs)
using UnityEngine;
using System.Collections;
using System;
using System.IO;
public class Writer : MonoBehaviour {
private FileInfo theSourceFile = null;
private StreamWriter writer = null;
private string sPath = System.Environment.GetEnvironmentVariable("HOMEDRIVE")
+ System.Environment.GetEnvironmentVariable("HOMEPATH");
// Function that saves the settings in the config file...
public void write (int resWidth, int resHeight, int Quality) {
if (Application.platform != RuntimePlatform.OSXWebPlayer &&
Application.platform != RuntimePlatform.WindowsWebPlayer){
if (File.Exists(sPath + "/VHconfig.txt")){
Debug.Log("Configuration file found in " + sPath + "/VHconfig.txt" + ". Deleting...");
File.Delete(sPath + "/VHconfig.txt");
}
theSourceFile = new FileInfo (sPath + "/VHconfig.txt");
writer = theSourceFile.CreateText();
writer.WriteLine(resWidth);
writer.WriteLine(resHeight);
writer.WriteLine(Quality);
writer.Close();
}
}
}
Is called from Js here:
Writer.write(changedResWidth, changedResHeight, changedQuality);
Any way to call it from Js??
Thanks a lot.