public void CreateEmailConversation(string convoID) // for Buttons. This runs when a Convo Header 'Open' Button is clicked. { // This is for optimisation. Rather than loading every email conversation on start, only load them once when opened // And then keep them open but off screen for duration of play // Check if has not been loaded, else open string window = convoID + "_convoWindow"; var convoWindow = conversationsLoaded.FirstOrDefault(conversationsLoaded => conversationsLoaded.Contains(window)); if (convoWindow == null || convoWindow == "") { // Create the Conversation Window Transform emailUIGroup = GameObject.Find("Emails UI").transform; GameObject newConvoWindow = GameObject.Instantiate(emailConvoWindowPrefab, emailUIGroup); newConvoWindow.name = convoID + "_convoWindow"; emailWindowPos = newConvoWindow.transform.localPosition; foreach (Transform t in newConvoWindow.GetComponentsInChildren <Transform>()) { if (t.name == "Content_Log") { emailConvoScrollContent = t; } } // Set up the Close Window button newConvoWindow.transform.Find("Button_Close").GetComponent <Button>().onClick.AddListener( delegate { newConvoWindow.transform.localPosition = Vector3.right * 2000; PopulateConversationsList(); } ); // Store the Conversation Window somewhere (dont load it every time) conversationsLoaded.Add(newConvoWindow.name); } else { GameObject.Find(window).transform.localPosition = emailWindowPos; } // Create each Email Entry that has NOT been loaded already foreach (EmailEntry email in EM.emailConversationsDictionary[convoID].receivedEmails) { if (email.loadedToGame == false) { CreateEmailConversationEntry(email); } if (email.opened == false) { email.opened = true; } EM.CheckNotifications(); } // Mark this Convo as 'Read' EM.emailConversationsDictionary[convoID].MarkEmailsRead(); }