• 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 t$$anonymous$$s (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 Jay Kay). 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

Howto access global var from other script? 2 Answers

Static variables 1 Answer

Accessing another var on another script 1 Answer

How to use same code at multiple scenes ? 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