Question by
xx_Blackwolf99 · Jan 28, 2021 at 08:37 AM ·
c#unity 5gameobjectsetactive
gameObject.SetActive (false); Not working
I have a strange problem with the SetActive funktion. First i got a callback from an Event:
private void im_LoginOK(object sender, EventArgs e)
{
Debug.Log("Connected");
ChanceScreen(1);
try
{
Debug.Log("Online User: " + im.Users().ToString());
}
catch (Exception ex)
{
Debug.Log("Error: " + ex.Message);
}
}
The "Connected" is showed correctly in the console. But the ChanceScreen will not executed.
private void ChanceScreen(int Screen)
{
Debug.Log("2");
if (Screen == 0)
{
LoginForm.SetActive(true);
//MainForm.SetActive(false);
MainForm.GetComponent<DisableScript>().DisableThis();
Debug.Log("Chance Screen to Login");
}
else if (Screen == 1)
{
Debug.Log("3");
//LoginForm.SetActive(false);
LoginForm.GetComponent<DisableScript>().DisableThis();
Debug.Log("4");
MainForm.SetActive(true);
Debug.Log("5");
Debug.Log("Chance Screen to Main");
}
}
The last Console log is 2 from the Debug.Logs... The Forms i will deaktivate are gameobjects which are not on this script. They are at a completely different position in the scene.
Anyone has an idea why this isnt working? ty
Comment
Your answer
Follow this Question
Related Questions
gameObject.SetActive (false); Not working 0 Answers
How can I change GameObject's texture? 1 Answer
All GameObjects list to a GameObject? 0 Answers
How to destroy only a clone in Unity 3d? 0 Answers
How do you activate a game object ? 1 Answer