VRGB – In-world rom list update #2

oculusGameboy 2014-05-21 16-37-34-01


I managed to write some code that will scan the \Roms\ directory for any file ending in “.gb” and store them in an array of strings so that they may be called whenever the user wants to load a new game!

Then we instantiate a 3D model for each ROM and store that in a list.

var info = new DirectoryInfo(path);
var fileInfo = info.GetFiles();
int i = -1;
foreach (FileInfo file in fileInfo)
  string romName = file.Name.TrimEnd('.', 'g', 'b');
  if (file.Name.EndsWith(".gb"))
    GameObject InstantiatedRom = Instantiate(romToInstantiate, 
      new Vector3(transform.position.x - (i * 0.1f), transform.position.y, 
        transform.position.z - (i * 0.1f)), transform.rotation) as GameObject;
    InstantiatedRom.transform.parent = gameObject.transform;

I also added the ability for the user to pull in any labels for their ROM collection. In the loop we put the following:
if (file.Name.EndsWith(".png"))
  if (romCarts[i].name == romList[i])
    StartCoroutine(GetLabel("file://" + path + file.Name, i));

Then we make the function that pulls the images in as Textures:
public IEnumerator GetLabel(string URL, int index)
  var www = new WWW(URL);
  yield return www;

  romCarts[index].GetComponent().labelGO.renderer.material.mainTexture = www.texture;

I just need to add some controls to help navigate through them and then I’ll be releasing a new version!

Leave a Reply

Your email address will not be published. Required fields are marked *