void buildListOfNovels() { scanThreads = new List <Thread>(); novels = new List <VisualNovel>(); variables = new Dictionary <string, int>(); string[] novelFolders = Directory.GetDirectories(LIBRARY_DIRECTORY); //Scan all the novels Vector3 novelPosition = new Vector3(-270, 250, 0); Vector3 incrementPositionX = new Vector3(105, 0, 0); Vector3 incrementPositionY = new Vector3(0, -115, 0); foreach (string folder in novelFolders) { try { //Create the visual novel entity VisualNovel novel = new VisualNovel(folder); //Create an accompanying novel icon GameObject newNovelIcon = (GameObject)Instantiate(novelIconPrefab, novelPosition, gameObject.transform.rotation); newNovelIcon.transform.parent = novelSelector.gameObject.transform; newNovelIcon.transform.localScale = new Vector3(1, 1, 1); newNovelIcon.transform.localPosition = novelPosition; //Update the button's icon and text to that of the novel Button novelButton = newNovelIcon.GetComponent <Button>(); novelButton.image.sprite = Sprite.Create(novel.getThumbnail(), new Rect(0, 0, 100, 75), new Vector2(0, 0), .01f); Text novelText = newNovelIcon.GetComponentInChildren <Text>(); novelText.text = novel.getTitle(); StartNovel theNovelStarter = newNovelIcon.GetComponent <StartNovel>(); theNovelStarter.novel = novel; theNovelStarter.system = this; //Increment the position that the next icon will be created at novelPosition += incrementPositionX; if (novelPosition.x > 270) { novelPosition.x = -270; novelPosition += incrementPositionY; } } catch (System.Exception e) { Debug.Log("Could not parse directory " + folder + "\n\n because of " + e.Message); } } }
void Awake() { main = this; }