How do I start with text inactive?
I figured out how to make a toggle, to turn a GUI text element on and off, and how to start with the toggle disabled. I haven't however figured out how to start with the text itself disabled. Here's the script I've attached to the text to try to make it go away at the start.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class startOff : MonoBehaviour
{
new GameObject Textbox;
void Start()
{
Textbox.gameObject.SetActive(false);
}
}
Answer by samzeman · Aug 11, 2017 at 05:24 PM
Fixed it! Basically, there were a couple things wrong. - startOff should have been StartOff - I switched Start() to Awake(), I don't know if that helped, but I did it. - I changed new gameobject to public gameobject
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StartOff : MonoBehaviour
{
public GameObject Textbox;
void Awake()
{
Textbox.gameObject.SetActive(false);
}
}
And, somehow, it works. Such is programming.
Your answer
Follow this Question
Related Questions
Display rigidbody speed to a world space canvas text 2 Answers
GUI Text showing even if the 'if' statement is not met 1 Answer
Gui Text won't turn off 0 Answers
Cannot see Text 1 Answer