Random text with GUI {c#}

I have a little problem with GUI in Unity. I am randomly picking one number 0 or 1 and depends on it i am trying to show a text but nothing shows up. Debug says that evertyhing is working perfectly but it is not.

Here is code

using UnityEngine;
using System.Collections;

public class glowny : MonoBehaviour {
	int i, k;
	int lapacz;
	
	
	void wylosowany(int lapacz){
		Debug.Log("to dziala?");
		Debug.Log(lapacz);
		if(lapacz == 0){
			GUI.Label(new Rect(10, 10, 200, 300), "pytanie 1");	
			Debug.Log("wykonuje sie 0");
		}
		if(lapacz == 1){
			GUI.Label(new Rect(10, 10, 200, 300), "pytanie 2");
			Debug.Log("wykonuje sie 1");
		}
		
		
	}
	
	void OnGUI(){
		if(GUI.Button(new Rect(100,100,100,100), "losuj")){
		i = Random.Range(0, 2);
			Debug.Log(i);
			
			wylosowany(i);
		}
		
		
	}
	
}

Greetings,

This seems like an interesting thing to test out, add me on Skype and I will test it out!

marius.alexander.winsjansen

Works fine for me! :slight_smile:

int myTest;
bool isTheButtonPushed;

void Start () {

}

void Update () {
Debug.Log (myTest);
Debug.Log (isTheButtonPushed);
}

void OnGUI () {
if(GUI.Button(new Rect(Screen.width / 2 - 250, Screen.height / 2 - 62.5F, 500, 125), “myTesting”)) {
myTest = Random.Range(0, 2);
isTheButtonPushed = true;
}

if(isTheButtonPushed) {

if(myTest == 0) {
GUI.Label (new Rect(0, 0, 100, 100), “YOU GOT 0”);
}

if(myTest == 1) {
GUI.Label (new Rect(0, 0, 100, 100), “YOU GOT 1”);
}

}
}
}

works perfectly. Thanks for your help.