public void Save(string name, byte[] data) { if (data == null) { return; } string path = null; //#if UNITY_STANDALONE_WIN || UNITY_STANDALONE_WIN // path = Environment.CurrentDirectory + "\\Assets\\StreamingAssets\\"; //#else // Debug.Log("I don't know where to save data on this platform."); //#endif path = LoaderScript.getPath(); if (path != null) { try { File.WriteAllBytes(path + name + ".sav", data); } catch (System.Exception e) { Debug.Log("Couldn't save data file."); Debug.Log(e.Message); } } }
void Update() { // Input foreach (KeyValuePair <KeyCode, EmulatorBase.Button> entry in _keyMapping) { if (this.transform.parent.transform.position.x == 0) { if (Input.GetKeyDown(entry.Key)) { Emulator.SetInput(entry.Value, true); } else if (Input.GetKeyUp(entry.Key)) { Emulator.SetInput(entry.Value, false); } } } if (Input.GetKeyDown(KeyCode.T)) { byte[] screenshot = ((DefaultVideoOutput)Emulator.Video).Texture.EncodeToPNG(); File.WriteAllBytes(LoaderScript.getPath() + "screenshot" + DateTime.Today.Year.ToString() + DateTime.Today.Month.ToString() + DateTime.Today.Day.ToString() + DateTime.Today.Hour.ToString() + DateTime.Today.Minute.ToString() + DateTime.Today.Second.ToString() + ".png", screenshot); Debug.Log("Screenshot saved. " + LoaderScript.getPath()); } }
public byte[] Load(string name) { string path = null; path = LoaderScript.getPath(); byte[] loadedData = null; if (path != null) { try { loadedData = File.ReadAllBytes(path + name + ".sav"); } catch (System.Exception e) { Debug.Log("Couldn't load data file."); Debug.Log(e.Message); } } return(loadedData); }
private IEnumerator LoadRom(string filename) { LoaderScript.findRoms(); string path; path = "file://" + LoaderScript.getPath() + filename; Debug.Log("Loading rom: " + path); WWW www = new WWW(path); yield return(www); if (www.error == null) { Emulator.LoadRom(www.bytes); StartCoroutine(Run()); } else { Debug.Log("Error during loading the rom.\n" + www.error); } }