43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
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() {
|
|
Debug.Log("StoryDisplay Awake");
|
|
this.storyBoxLeft = GameObject.Instantiate(this.storyBox, this.uiCanvas.transform);
|
|
RectTransform rt = this.storyBoxLeft.GetComponent<RectTransform>();
|
|
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);
|
|
}
|
|
}
|
|
|
|
public void SetBackground(string fileName) {
|
|
Sprite sprite = Resources.Load<Sprite>("BGBattle/" + fileName);
|
|
this.background.sprite = sprite;
|
|
}
|
|
}
|