- Home /
What is the cause of the bug?
Someone understands what is the cause of the bug?
void OnGUI() { GUI.Label(new Rect(210, 430, 100, 100), "This Works!");
variable = GUI.TextField(new Rect(210, 110, 160, 30), variable);
if (GUI.Button(new Rect(40, 430, 160, 30), "Show a message"))
{
if (variable != "")
{
GUI.Label(new Rect(210, 430, 100, 100), "This DOES NOT Work!");
Debug.Log("This works as well");
}
else
{
//Write an error
}
} }
Comment
Answer by reddead12 · Dec 06, 2015 at 05:21 PM
using UnityEngine;
using System.Collections;
public class SomeCode : MonoBehaviour{
void OnGUI()
{
variable = GUI.TextField(new Rect(210, 110, 160, 30), variable);
if (GUI.Button(new Rect(40, 430, 160, 30), "Show a message"))
{
if (variable != "")
{
GUI.Label(new Rect(210, 430, 100, 100), "This DOES NOT Work!");
Debug.Log("This works as well");
}
else
{
//Write an error
}
}
}
}
I tested this code in Microsoft visual studio with unity plugin and it gave no errors.
Your answer
