using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public enum DialogPosition { Left, Right, } public class StoryDisplay : MonoBehaviour { public Canvas uiCanvas; public StoryBox storyBox; private StoryBox storyBoxLeft; void Awake() { Debug.Log("StoryDisplay Awake"); this.storyBoxLeft = GameObject.Instantiate(this.storyBox, this.uiCanvas.transform); RectTransform rt = this.storyBoxLeft.GetComponent(); rt.anchorMin = new Vector2(0, 0.5f); rt.anchorMax = new Vector2(0, 0.5f); rt.position = new Vector2(+200, rt.position.y); this.storyBox.gameObject.SetActive(false); this.storyBoxLeft.gameObject.SetActive(false); } public IEnumerator DisplayText(string message, DialogPosition position) { Debug.Log("DisplayText " + message); if (position == DialogPosition.Left) { yield return this.storyBoxLeft.Display(message); } else { yield return this.storyBox.Display(message); } } }