- Home /
The question is answered, right answer was accepted
GameObject not showing up when set active.
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." $$anonymous$$ake sure the variable waveTutorialEvenBox is pointing where it should.
I 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.
Answer by Chris333 · Jan 26, 2015 at 10:14 PM
Hi,
void Update()
{
if (wave0TutorialEvent1Status == true)
{
wave0TutorialEvent1TextBox.SetActive (true);
Debug.Log ("Wave0TutorialEvent1 Should be visible");
Invoke ("WaitForDialogue", 10.0f);
//wave0TutorialEvent1TextBox.SetActive (false);
wave0TutorialEvent1Status = false;
}
}
You set it active and than directly again to false.
Does the invoke not matter in this case? I put the invoke there so there would be time stalled so the game object would last longer.
No, it does only invoke the method which you hand over as string parameter.
What would you suggest I do to make the gameobject last longer before disappearing.
Did you tried what i posted above? Is it now showing up?
It is showing but I don't want it to stay visible forever.
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to Use DontDestroyOnLoad on my C# Script? 1 Answer
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer
Select Car - Multiple prefabs 1 Answer