GameObject CreateOptionWindow(Yarn.Options optionsCollection) { GameObject optionWindow = Instantiate <GameObject> (optionWindowPrefab); OptionSetController setController = optionWindow.GetComponent <OptionSetController> (); setController.Init(this); setController.transform.SetParent(dialogueCanvas.transform, false); //setController.rectTransform.sizeDelta = new Vector2 (); GameObject newButton; // populate it with buttons string parsedOptString; foreach (var optionString in optionsCollection.options) { parsedOptString = YarnUtils.ParseYarnText(dialogueRunner.variableStorage, optionString); newButton = Instantiate <GameObject>(setController.buttonPrefab); setController.AddOption(newButton, parsedOptString); } // let's put it in the middle-right of the screen //setController.rectTransform.ApplyAnchorPreset(TextAnchor.MiddleRight, false, false); setController.rectTransform.PositionRelativeToParent(TextAnchor.MiddleRight); return(optionWindow); }
public void AddEntry(string text, string imageName) { Debug.Log("Adding testimony!"); GameObject newEntryGo = Instantiate <GameObject>(entryPrefab, entryPrefab.transform.position, Quaternion.identity); TestimonyEntry entry = newEntryGo.GetComponent <TestimonyEntry>(); // The text may contain a variable, so make sure that the right value is shown instead // of the variable name string entryText = YarnUtils.ParseYarnText(variableStorage, text); // Load the sprite based on the name Sprite giverSprite = Resources.Load <Sprite>("Graphics/Portraits/" + imageName); if (giverSprite == null) { throw new System.ArgumentException(imageName + " is not in the Portraits subfolder of the Graphics folder."); } entry.text = entryText; entry.giverMugshot = giverSprite; newEntryGo.transform.SetParent(testimonyHolder, false); // Make it expand when clicked, go back to normal when clicked while expanded Button entryButton = newEntryGo.GetComponent <Button>(); crewManager.buttonsManaged[newEntryGo] = ButtonState.normal; entryButton.onClick.AddListener(() => { if (crewManager.EntryNormal(newEntryGo)) { //crewManager.expandNews(newEntryGo); crewManager.ExpandTestimony(entry); } else { //crewManager.shrinkNews(newEntryGo); crewManager.ShrinkTestimony(entry); } }); entries.Add(entry); }
public void AddEntry(string text, string imageName) { Debug.Log("Adding verbal clue!"); GameObject newEntryGo = Instantiate <GameObject>(entryPrefab); VerbalClueEntry entryDetails = newEntryGo.GetComponent <VerbalClueEntry>(); // The text may contain a variable, so make sure that the right value is shown instead // of the variable name string entryText = YarnUtils.ParseYarnText(variableStorage, text); // load the sprite based on the name Sprite giverSprite = Resources.Load <Sprite>("Graphics/Portraits/" + imageName); if (giverSprite == null) { throw new System.ArgumentException(imageName + " is not in the Portraits subfolder of the Graphics folder."); } entryDetails.text = entryText; entryDetails.giverMugshot = giverSprite; newEntryGo.transform.SetParent(testimonyHolder, false); }
void GetTextDisplayed() { // make the textbox visible CanvasGroup cGroup = textbox.GetComponent <CanvasGroup>(); cGroup.alpha = 1; cGroup.blocksRaycasts = true; //Debug.Log ("Text to display, gathered between the textbox tags: " + textToShow.ToString ()); if (textboxController.nameTag != null) { textboxController.nameTagText = nameTagText; } if (textboxController.portrait != null) { textboxController.portraitSprite = portrait; } print("Right before displaying text, culprit is: " + dialogueRunner.variableStorage.GetValue("$Culprit").AsString); string varParsedText = YarnUtils.ParseYarnText(dialogueRunner.variableStorage, textToShow.ToString()); textboxController.DisplayText(varParsedText); }