Hello, I am trying to make a gameobject appear when set to active but its really confusing me why it isn’t doing just that.
I have it set to active in the scene and in script set to unactive in the start method. With the script its supposed to tell the game object to reappear but its not. The compiler reaches the Debug.Log (“Wave0TutorialEvent1 Should be visible”); so I don’t understand why it is not appearing.
I would really like for your advise on how I should change this and what is wrong. Thanks in advance.
Here’s the code I’m messing around with.
using UnityEngine;
using System.Collections;
public class Wave0TutorialGUIEnabler : MonoBehaviour
{
private bool wave0TutorialEvent1Status;
private bool wave0TutorialEvent2Status;
private GameObject wave0TutorialEvent1TextBox;
void Start()
{
wave0TutorialEvent1TextBox = GameObject.Find("Wave0TuturialEvent1TextBox");
wave0TutorialEvent1TextBox.SetActive (false); //In scene is active but is set to unactive when game is started.
}
void Update()
{
if (wave0TutorialEvent1Status == true)
{
wave0TutorialEvent1TextBox.SetActive (true);
Debug.Log ("Wave0TutorialEvent1 Should be visible");
Invoke ("WaitForDialogue", 10.0f);
wave0TutorialEvent1TextBox.SetActive (false);
wave0TutorialEvent1Status = false;
}
}
void WaitForDialogue()
{
}
void Wave0TutorialEvent1 (bool status)
{
Debug.Log ("Activating event");
wave0TutorialEvent1Status = status;
}
}
Pause and check the object in the Inspector. It might be active, but just not visible. See if you can move it to where it is. Or it may have an inactive parent. Click around to try to "turn it on." Make sure the variable waveTutorialEvenBox is pointing where it should.
– Owen-ReynoldsI tried that but to no avail. The Gameobject is still inactive after the fact that it should be active. The parent aren't put in inactive by accident either and the gameobject is pointing in the right direction so that the normal isn't facing the opposite direction of the camera.
– Ujean917