Hello!
I am running into a weird issue. I know that when that error is thrown 9/10 times it is because something isn’t assigned in the inspector. However, everything is.
Basically, I am instantiating the class that holds that write method as M.
When I call M.Write(gameobject1, “test”, true) it throws an error when the code reaches gameobject1.
I don’t understand why? gameobject1 is assigned in the inspector.
public GameObject Object { get; set; }
public string ObjectString { get; set; }
public Text ObjectText { get; set; }
public void Write(GameObject g, string text, bool TypewriterEffect)
{
ObjectString=text;
Object=g;
if(TypewriterEffect)
{
Debug.Log("Typing!");
Effect_TypeWrite(text);
}
else
{
var text_string = Object.GetComponent<Text>();
text_string.text=text;
}
}
public IEnumerator Effect_TypeWrite(string text)
{
var text_string = Object.GetComponent<Text>();
foreach(char letter in text.ToCharArray())
{
text_string.text+=letter;
yield return null;
}
}
public void Transition(GameObject former, GameObject wish)
{
if(Input.GetKeyDown(KeyCode.Space))
{
former.SetActive((false));
wish.SetActive((true));
}
}