- Home /
Global Varible Problem
kk so i have a script where a console should pop up when the player bumps into a certain cube. here's the cube code.
function OnTriggerEnter(other:Collider){
if (other.tag == "Player") {
Console.consoleType = 1;
Debug.Log("COLLISION");
}
else if (other.tag == "Hack") {
Console.consoleType = 2;
}
}
function OnTriggerExit(){
Console.consoleType = 0;
}
All the collisions work perfectly fine and there no explicit errors. heres the console script.
static var consoleType = 0;
//0 = none 1 = mainframe 2 = limited mainframe
static var consoleText = "";
private var onConsole : boolean = false;
function Update() {
if (consoleType == 0) {
onConsole = false;
}
else {
onConsole = true;
}
}
function OnGui () {
if (onConsole) {
Debug.Log("Gui should be here");
GUI.Label (Rect (10, 10, 100, 30), ">" + consoleText);
consoleText = GUI.TextField (Rect (90, 10, 200, 25), consoleText, 40);
}
}
the "Gui should be here" debug never gets called. an someone help?
Answer by AlucardJay · Aug 21, 2012 at 07:15 AM
function OnGui ()
is incorrect. It should look like this (note the capitols) :
function OnGUI ()
http://docs.unity3d.com/Documentation/Components/GUIScriptingGuide.html
Answer by swordofnoah · Aug 21, 2012 at 03:05 PM
@Jay Kay WOW! Can't believe i missed that!
No problem =]
I just found this post in the moderation que too (I'm $$anonymous$$ $$anonymous$$ay). Good Luck and Have Fun =]
This is just a generic thing I post for all new users (so not a personal comment on you, ok) :
Please don't post comments as answers. Post comments by clicking the [add new comment] button, a window then open for you to type in. Answer fields are for answers only, as this is a knowledge base.
I wish this was made clearer for new users, so just some tips on using this 'site (for ALL new users) :
How to accept an answer :
On the left-hand-side of the Answer box , there are the following icons :
: Thumb Up : Number (of votes) : Thumb Down : A Tick :
If an answer worked for you , click on the 'Tick' , the answer should now be highlighted in green. If you like an answer on Any question , you can click on the Thumb UP , the thumb should now be highlighted in green , and the number of votes should rise by 1.
How to reply to an answer / post a comment :
To make a comment , USE the [add new comment] button, a window then opens to type in. The answer fields are for ANSWERS, so unless you are answering your own question , DON'T write in an answer box. This helps the 'site work properly, especially when other people are searching for answers, and want to read answers , not comments.
IF your question changes slightly while commenting and reading comments , EDIT the original Question, so anyone reading from the beginning knows what you are asking.
This will make for a happy experience for everyone. I made mistakes starting on this 'site too, but everyone is helpful if you learn and change these habits.
Following these simple steps helps the website work , and other readers to find answers also.
Happy Coding =]
the FAQ appears at the top of the page : http://answers.unity3d.com/page/faq.html
also : http://answers.unity3d.com/questions/133869/how-to-ask-a-good-question.html
Your answer
Follow this Question
Related Questions
Unable to modify a variable in another script 2 Answers
Changing static variables from another script? 1 Answer
Howto access global var from other script? 2 Answers
Static variables 1 Answer