Example #1
0
		public async Task<DialogItem.Button> ShowAsync(string speech, params DialogItem.Button[] buttons)
		{
			this.DestroySpawnedButtons();

			if (buttons.Length == 0)
			{
				buttons = new [] { new DialogItem.Button { text = "Continue", choice = PlayerChoice.Undefined }};
			}

			this.speechText.text = speech;

			DialogItem.Button chosenButton = null;
			foreach (var button in buttons)
			{
				var buttonInstance = Instantiate(this.buttonPrefab, this.transform);
				buttonInstance.Setup(button, () => chosenButton = button);
				this.spawnedButtons.Add(buttonInstance);
			}
			
			this.gameObject.SetActive(true);

			while (chosenButton == null)
			{
				await Task.Yield();
			}
			
			this.gameObject.SetActive(false);
			
			return chosenButton;
		}
 public void Setup(DialogItem.Button buttonData, UnityAction onClick)
 {
     this.buttonText.text = buttonData.text;
     this.button.onClick.AddListener(onClick);
 }