Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by AERR0W · May 16, 2016 at 12:24 AM · c#androidemulation

Android Game boy emulator: How to set directory in C# Script

i found a open source game boy emulator and decide port to android but im new in unity and in c# and I'm doubt this part of this code

 // Get what path to use depending on platform
     static public string getPath() {
         if (path == "") {
             // Check platforms, change this to different platfoms as needed
             // I've set SAV games and ROMs to be in the same folder.
             switch (Application.platform) {
             case (RuntimePlatform.Android):
                 path = "/accounts/1000/shared/misc/roms/gb/";
                 break;
             default:
                 path = System.Environment.CurrentDirectory + "//storage//sdcard0//Download//";
                 break;
             }
         }

how to set path to android and directory to downloads folder for example, as directory diversify as do look for another directory if not find it,It would be a variable, show me examples for this. (Sorry my english)

complete code

 using UnityEngine;
 using System.Collections;
 using System.IO;
 
 public class LoaderScript : MonoBehaviour {
 
     static public string path = "";
     static public string[] roms;
     static public int romIndex;
     static public GUIText guiText;
     static public FileInfo[] fileInfo;
 
     // Prevent long strings and show only the end of the text string
     static public string mStr(string inString) {
         int maxLen = 28;
         if (inString.Length > maxLen) {
             inString = "..." + inString.Substring(inString.Length - maxLen);
         }
         return inString;
     }
 
     // Find all the roms in the folder and display it based on romIndex
     static public void findRoms() {
 
         updateText ("Loading...");
 
         if (romIndex == null)
             romIndex = 0;
 
         string extension = "*.gb";
         DirectoryInfo dirInfo = new DirectoryInfo(getPath());
         fileInfo = dirInfo.GetFiles(extension);
 
         string tString = "";
 
         int mIndex = romIndex + 10;
         tString = "<I>" + mStr("Path: " + getPath() + "\n\n") + "</I>";
         if (fileInfo.Length > mIndex) {
             for (int i = romIndex; i < mIndex; i++) {
                 if (i == romIndex)
                     tString = tString + "> ";
                 else
                     tString = tString + "  ";
                 tString = tString + fileInfo[i].Name +"\n";
             }
             tString = tString + "... more";
         }
         else
         {
             for (int i = romIndex; i < fileInfo.Length; i++) {
                 if (i == romIndex)
                     tString = tString + "> ";
                 tString = tString + fileInfo[i].Name +"\n";
             }
             tString = tString + "... end";
         }
         tString = tString + "\n\nQ Keys WSAD [Arrows], OP [Buttons]\nSpace & Enter, T Screenshot";
 
         updateText (tString);
     }
 
     // Update our text box
     static public void updateText(string text) {
         if (guiText == null)
             guiText = GameObject.Find("Text").GetComponent<GUIText>();
         guiText.text = text;    
     }
 
     // Get what path to use depending on platform
     static public string getPath() {
         if (path == "") {
             // Check platforms, change this to different platfoms as needed
             // I've set SAV games and ROMs to be in the same folder.
             switch (Application.platform) {
             case (RuntimePlatform.BlackBerryPlayer):
                 path = "/accounts/1000/shared/misc/roms/gb/";
                 break;
             default:
                 path = System.Environment.CurrentDirectory + "\\Assets\\ROM\\";
                 break;
             }
         }
         Debug.Log("ROM path set to: " + path);
         return path;
     }
 
     // Not used
     static public void createFolder(string path) {
         Debug.Log ("Creating path: " + path);
         File.Create (path);
     }
 }
 
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

166 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Gyroscope Samsung S7 doesn't work properly 4 Answers

Errors trying to build apk for Daydream mirage solo headset 0 Answers

2021.2.7: DownloadHandlerTexture and UnityWebRequestTexture not recognized? 1 Answer

Unity2D I wanna use a delay time on Entering an Trigger. 0 Answers

create calendar in canvas using c# 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges