I am new to C# and unity in general, so just putting that out there but while working I wanted to have some auto type, I know how frustrating programming something like that can be when you don’t know the language as I have had to do it once before in another language so I tried to find an some Auto Type code already made. All I can really find was an outdated script on the community wiki or something and a bunch of other forum threads that were talking of thinks I had no Idea about. So I took the old script and tried updating it. When I finished and had no errors Unity said that the i had to fix the compiler errors and assign a valid script due to the script not being valid. I feel like this is a really redundant problem that has been answered many times but I am just stumped. Any help will be greatly appreciated.
Here’s the code.
using UnityEngine;
using System.Collections.Generic;
using System.Collections;
public class AutoType : MonoBehaviour
{
public float letterPause = 0.2f;
public AudioClip bite;
string message;
private UnityEngine.UI.Text UIText;
private AudioSource sound;
// Use this for initialization
void Start()
{
UIText = GetComponent<UnityEngine.UI.Text>();
message = "welcome to the game!";
StartCoroutine(TypeText());
sound = GetComponent<AudioSource>();
}
IEnumerator TypeText()
{
foreach (char letter in message.ToCharArray())
{
UIText.text += letter;
sound.PlayOneShot(bite);
yield return 0;
yield return new WaitForSeconds(letterPause);
}
}
}
**note: A part of me feels like it could be the Audio that’s bugging out which would be annoying since the main part of the script is just writing text.