Currently i have a dialogue box setup, but i’d like to add an image of the character that was clicked on to the dialogue box. This is what i have. Please help, not sure what the best way to approach this is.
DialogueManager
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class DialogueManager : MonoBehaviour
{
public GameObject dialogueBox;
public Text dialogueText;
public bool dialogueActive;
public string[] dialogueLines;
public int currentLine;
public Image Character;
public Sprite[] CharacterImages;
public int currentCharacter;
void Start ()
{
}
void Update ()
{
if (dialogueActive && Input.GetButtonDown("Fire2"))
{
currentLine++;
currentCharacter++;
}
if (currentLine >= dialogueLines.Length)
{
dialogueBox.SetActive(false);
dialogueActive = false;
currentLine = 0;
currentCharacter = 0;
}
dialogueText.text = dialogueLines[currentLine];
}
public void ShowDialogue()
{
dialogueActive = true;
dialogueBox.SetActive(true);
}
}
using UnityEngine;
using System.Collections;
public class DialogueHolder : MonoBehaviour
{
public string dialogueLines;
public Sprite CharacterImages;
private DialogueManager DialogueManager;
void Start ()
{
DialogueManager = FindObjectOfType<DialogueManager>();
}
void Update ()
{
}
void OnTriggerStay2D(Collider2D other)
{
if (other.gameObject.name == "Player")
{
if (Input.GetButtonUp("Fire2"))
{
if (!DialogueManager.dialogueActive)
{
DialogueManager.dialogueLines = dialogueLines;
DialogueManager.currentLine = 0;
DialogueManager.ShowDialogue();
DialogueManager.CharacterImages = CharacterImages;
DialogueManager.currentCharacter = 0;
}
}
}
}
}