Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by swordofnoah · Aug 21, 2012 at 06:33 AM · variablestaticglobal

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?
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AlucardJay · Aug 21, 2012 at 03:10 PM 0
Share

I'm a comment ! =D

avatar image
0

Answer by swordofnoah · Aug 21, 2012 at 03:05 PM

@Jay Kay WOW! Can't believe i missed that!

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AlucardJay · Aug 21, 2012 at 03:09 PM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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

Accessing another var on another script 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges