How to change RawImage when the dialogue array at specific length?,How to change image in middle of Array?
How to change RawImage when the dialogue array length is at 4?
I use gameobject as the image.Help!
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement;
public class introDialogue : MonoBehaviour {
public Text textDisplay;
public string[] sentences;
private int index;
public float typingSpeed;
public GameObject continueButton;
public GameObject continueLevelButton;
public Animator textDisplayanim;
public GameObject image1;
public GameObject image2;
void Start()
{
StartCoroutine(Type());
continueLevelButton.SetActive(false);
image2.SetActive(false);
}
void Update()
{
if (textDisplay.text == sentences[index])
{
continueButton.SetActive(true);
ChangeRawImage();
}
}
IEnumerator Type()
{
foreach (char letter in sentences[index].ToCharArray())
{
textDisplay.text += letter;
yield return new WaitForSeconds(typingSpeed);
}
}
public void NextSentence()
{
textDisplayanim.SetTrigger("Change");
continueButton.SetActive(false);
if (index < sentences.Length - 1)
{
index++;
textDisplay.text = "";
StartCoroutine(Type());
} else
{
textDisplay.text = "";
continueButton.SetActive(false);
continueLevelButton.SetActive(true);
}
}
public void GotoLevel1()
{
SceneManager.LoadScene("Level 1");
}
public void GotoLevel2()
{
SceneManager.LoadScene("Level 2");
}
public void ChangeRawImage()
{
if (index.Length == 4)
{
image2.SetActive(true);
image1.SetActive(false);
}
}
}
Comment
Your answer

Follow this Question
Related Questions
SendMessage to Object in Array 1 Answer
How do I access an object script variable that is in a 2D array? 0 Answers
One script with multiple Gameobject only one Works 0 Answers
How can I assign swipe positions to the array as parameters? 0 Answers
Genetic Algorithm OverflowException: Number overflow: 1 Answer