I am creating an Arcade GUI in Unity 5. The main feature I wish to implement is a system that automatically creates buttons for each game (in the file structure) and loads 1 sprite and some text from files not included in the build. I want the Arcade to read files in the same folder as the build without having to include those files in the build. Here's some code I experimented with:
DirectoryInfo DirectoryToFiles = new DirectoryInfo ("Games");
DirectoryInfo[] Folders = DirectoryToFiles.GetDirectories ();
foreach (DirectoryInfo Folder in Folders) {
FileInfo[] Files = Folder.GetFiles ();
string filename = Files [0].Name.Substring(0,Files [0].Name.IndexOf("."));
//Loads Image
Image = Resources.Load ("Games" + "/" + Folder.Name + "/" + filename + ".png") as Texture2D;
ButtonSprite = Sprite.Create (Image, new Rect (0, 0, Image.width, Image.height), new Vector2 (0f, 0f));
//The Declaration of "ButtonSprite" returns a NullReferenceException
//Reads Description File
GameDescription = ReadFile (Folder,filename);
//Gives Path to Play Button
GameObject.Find ("Play").GetComponent<PlayButton> ().UpdatePath ("Games" + "/" + Folder.Name + "/" + filename + ".exe");
//Transfers All Variables to the new Button
CurrentButton = Instantiate (GameButton, GameObject.Find ("Content").GetComponent<Transform> ());
CurrentButton.GetComponent<Transform> ().localPosition = new Vector3 (x,0f,1f);
x += 230;
CurrentButton.GetComponent<ButtonInstantiate> ().UpdateVariables (ButtonSprite, GameName.Substring(0,GameName.IndexOf(".")), GameDescription, Hours);
This is what my Build file looks like.
This is what the File structure looks like
If anyone can let me know a specific method I need to use, I would appreciate it. Thanks!