views
193
likes
2

Comments

What do you think?
No comments yet.

I still can't get a library that reads .gba to program it, but I already have 3 scenes for the game .... I also already have a script that reads the file (but not correctly) so I don't think I'll be able to finish it anytime soon.

see the main scene:

captura_de_tela_2020-09-29_132944.png

this is my code, by the way, don't judge me, because I'm still new to this program thing !!! (I'm still 13 years old!)

		
			using System.IO;
using UnityEngine;
using UnityEditor;
using UnityEngine.UI;
public class FileManager : MonoBehaviour {
    public byte[] fileContent;
    public string[] fileLinesContent;
    public string path;
	
    public GameObject devGuiParent;

    public void OpenFile(){
        path = EditorUtility.OpenFilePanel("Select a Rom", "Download", "gba");
        if(path == ""){
	    return;
	}
	if(Path.GetExtension(path) != ".gba"){
	    var alert = EditorUtility.DisplayDialog("No Gba!", "Please select a \".gba\" file,\nYou selected \"" + Path.GetExtension(path) + "\".", "SELECT AGAIN", "CANCEL");
	    if(alert){
	        OpenFile();
	    }
	    else {
		return;
            }
	}
        else if(path.Length != 0)
        {
            fileContent = File.ReadAllBytes(path);
	    fileLinesContent = File.ReadAllLines(path);
	    devGuiParent.SetActive(true);
	    Debug.Log("Rom Loaded!");
        }
    }
    public void SaveFile(){
	if(path.Length != 0){
	    File.WriteAllBytes(path, fileContent);
	    Debug.Log("Rom Saved!");
	}
	else {
            EditorUtility.DisplayDialog("Please Select", "You need to select a Rom to Save.", "OK");
	    return;
	}
    }
    public void RunFile(){
	if(path.Length != 0){
	    Debug.Log("Opening...");
	    System.Diagnostics.Process.Start(path);
	}
	else {
            EditorUtility.DisplayDialog("Please Select", "You need to select a Rom to play.", "OK");
	    return;
	}
    }
    void Start(){
	devGuiParent.SetActive(false);
    }
}

		
	

can i make the code better?

#retro



all-ages

Can someone help me?

AlguƩm pode me ajuda?