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; public Image background; private StoryBox storyBoxLeft; void 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) { if (position == DialogPosition.Left) { yield return this.storyBoxLeft.Display(message); } else { yield return this.storyBox.Display(message); } } public void SetBackground(string fileName) { Sprite sprite = Resources.Load("BGBattle/" + fileName); this.background.sprite = sprite; } }