- Home /
Question by
tommy1235 · Jun 08, 2013 at 07:28 AM ·
c#javascriptusing
how to use / simulate a using declaration in unityscript
I am having trouble trying to convert this C# script to a unityscript
using UnityEngine;
using System.Collections;
using System.IO;
public class saveLoad : MonoBehaviour {
public int[] someValue;
void SaveData()
{
using(var writer = new BinaryWriter(File.OpenWrite("FileName")))
{
for(int o = 0; o < someValue.Length; o++){
writer.Write(someValue[o]);
}
writer.Close();
}
}
void LoadData()
{
using(var reader = new BinaryReader(File.OpenRead("FileName")))
{
for(int o = 0; o < someValue.Length; o++){
someValue[o] = reader.ReadInt32();
}
reader.Close();
}
}
void OnGUI(){
if(GUI.Button(new Rect(100,100,100,25),"Save")){
SaveData();
}
if(GUI.Button(new Rect(100,125,100,25),"Load")){
LoadData();
}
for(int i = 0; i < someValue.Length; i++){
GUI.Label(new Rect(225,100+(i*25),100,25),"Data Value "+i+" :" + someValue[i]);
}
}
}
My problem is with the using declarations, does anybody have any suggestions on how to convert this to unityscript?
Comment
Best Answer
Answer by tommy1235 · Jun 15, 2013 at 06:00 AM
Never mind I have decided to just change the whole game to C#
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Help converting C# to Unityscript 1 Answer