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 Conect11 · Nov 15, 2013 at 06:27 PM · guiarrayguitext

[SOLVED] Puzzled why one particular GUIText won't appear

EDIT 3: Praise God, it's solved! Line 59 was the offender: if(inventoryArray[2] > 0) {

Once I commented that out, and removed the closing bracket, it was all good in the hood.

EDIT 2: FASCINATING! I think I've figured out that GuiText5 is somehow "parented" to the "water" object in the array, rather than the "film," like it's supposed to be. (though that's not a perfect description. Let me put it this way: Array([2] is water, [3] is Apple Brew, and [4] is film. Each has a GuiText attached to it so that when the player picks the item up it's visible in the inventory. Everything up to [2] appears fine, but let's say I pick up film; it won't appear in the inventory until I pick up water, but then it appears. I haven't tried Apple Brew [3] yet, but am thinking the same thing will happen. Looking at my script, everything has its own function, so am puzzled where I'm going wrong.

EDIT: I think I understand WHAT's going on here, but have no idea at the moment how to fix it.

Essentially, each GUIText is waiting on the previous GUIText to become active. In other words, the way I have it set up now, GUIText3 will not become enabled unless GUIText2 is, and 2 won't until 1 is, etc. Clearly, it's in how I've written the script :( (human error) If anyone can point out what exactly I did wrong, you'll be my hero.

OP:

So, this one has me stumped.

My pause menu has an inventory script attached to it. When I pick up an item, a GUIText appears on the pause screen stating that I have it. EXCEPT for one item, the Film. No matter what, it never appears, or rather, never enables in the inspector. Every other one does. The pickup item script is working fine, as another gameobject relies on having the film, and it runs perfectly, but the GUIText simply never appears. I have it attached to the gameobject properly, and set up in the inspector right. I think the issue is in the script itself, but am not positive. Any help is humbly appreciated. The offending object is inventoryText5. God bless.

         //inventory
 static var inventoryArray : int[] = [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
 var inventoryText : GameObject;
 var inventoryText2 : GameObject;
 var inventoryText3 : GameObject;
 var inventoryText4 : GameObject;
 var inventoryText5 : GameObject;
 var inventoryText5b : GameObject;
 static var PrisonKey : int = 0;
 static var TempleKey : int = 0;
 static var HealthPotion : int = 1;
 static var HardTack : int = 0;
 static var Water : int = 0;
 static var AppleBrew : int = 0;
 static var FilmforCam : int = 0;
 //inventoryText.guiText.text = "Health Potion " + "[" + inventoryArray[0] + "]" + "\n" + "Hard Tack " + "[" + inventoryArray[1] + "]" + "\n" + "Water " + "[" + inventoryArray[2] + "]" + "\n" + "Apple Brew " + "[" + inventoryArray[3] + "]" + "\n";
 function Start () {
 
 if(inventoryArray[0] < 1) {
    inventoryText.guiText.enabled = false;
 if(inventoryArray[1] < 1) {
    inventoryText2.guiText.enabled = false;
 if(inventoryArray[2] < 1) {
    inventoryText3.guiText.enabled = false;   
 if(inventoryArray[3] < 1) {
    inventoryText4.guiText.enabled = false;
 if(inventoryArray[4] < 1) {
    inventoryText5.guiText.enabled = false; 
 }
 }
 }
 }
 }
 }
 
 function Update () {
 
 
 
 if(inventoryArray[0] > 0) {//THIS LINE**
  inventoryText5b.guiText.enabled = true;
  //inventoryText5b.guiText.text = "" + "[" + inventoryArray[0] + "]" + "\n";
  //if(inventoryArray[0] > 0) {
  //if(Input.GetButtonDown("Stuff"))
   //healthPotion();
 //}
 if(inventoryArray[1] > 0) 
 {
   inventoryText2.guiText.enabled = true;
   inventoryText2.guiText.text = "Hard Tack " + "[" + inventoryArray[1] + "]" + "\n";
   //if(inventoryArray[1] > 0) {
   if(Input.GetButtonDown("Sword Slash"))
   hardTack();
 }
 if(inventoryArray[2] > 0) {
 inventoryText3.guiText.enabled = true;
 inventoryText3.guiText.text = "Water " + "[" + inventoryArray[2] + "]" + "\n";
 if(inventoryArray[2] > 0) {
 if(Input.GetButtonDown("Jump"))
 water();
 }
 if(inventoryArray[3] > 0) {
 inventoryText4.guiText.enabled = true;
 inventoryText4.guiText.text = "Apple Brew " + "[" + inventoryArray[3] + "]" + "\n";
 //if(AppleBrew > 0) {
 if(Input.GetButtonDown("Weapon Switch"))
 appleBrew();
 }
 if(inventoryArray[4] > 0) {
 inventoryText5.guiText.enabled = true;
 inventoryText5.guiText.text = "Film " + "[" + inventoryArray[4] + "]" + "\n";
 if(Input.GetButtonDown("Start"))
 Film();
 }
 //}
 //}
 }
 if(inventoryArray[5] > 0) {//THIS LINE**
   inventoryText.guiText.enabled = true;
   inventoryText.guiText.text = "Health Potion " + "[" + inventoryArray[0] + "]" + "\n";
   //if(inventoryArray[0] > 0) {
   if(Input.GetButtonDown("Stuff"))
   healthPotion();
   }
 }
 }
 function healthPotion ()  {
 //if(inventoryArray[0] > 0) {
 Playerhealth.curHealth += 15;
 inventoryArray[0] -=1;
 HealthPotion -=1;
 
 if(inventoryArray[5] == 0) {
 inventoryText.guiText.enabled = false;
 }
 }
 
 function hardTack ()  {
 
 Playerhunger.curHunger -= 5;
 inventoryArray[1] -=1;
 HardTack -=1;
 
 if(inventoryArray[1] == 0) {
 inventoryText2.guiText.enabled = false;
 }
 }
 
 function water ()  {
 
 Playerthirst.curThirst -= 100;
 inventoryArray[2] -=1;
 Water -=1;
 if(inventoryArray[2] == 0) {
 inventoryText3.guiText.enabled = false;
 }
 }
 function appleBrew ()  {
 Playerthirst.curThirst -= 300;
 Playerthirst.curHunger -= 200;
 inventoryArray[3] -=1;
 AppleBrew -=1;
 if(inventoryArray[3] == 0) {
 inventoryText4.guiText.enabled = false;
 }
 }
 function Film ()  {
 
 
 if(inventoryArray[4] == 0) {
 inventoryText5.guiText.enabled = false;
 }
 }
Comment
Add comment · Show 2
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 Seth-McCumber · Nov 16, 2013 at 08:53 PM 0
Share

Are you just adding GUIText to an existing object, and not creating a GUIText object?

avatar image Conect11 · Nov 16, 2013 at 09:26 PM 0
Share

that's correct. Just double checked and see that indeed the prior guitexts block this one. Once they're obtained, the last one appears. I must have lost my $$anonymous$$d, because upon going through my own posts I see that I've had this very same issue before, here and fixed the issue according to the answer on that post, but nothing has changed this time. Poor sainted fafase is probably shaking their head at my stupidity.

0 Replies

· Add your reply
  • Sort: 

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

18 People are following this question.

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

Related Questions

Appear after set number of seconds 2 Answers

What's wrong with my function? It keeps telling me 'loseText' is not a member of 'UnityEngine.GUIText'. Please help, please and thank you! 0 Answers

Fix Blurry UI text? 10 Answers

How to show an array of custom objects in Inspector? 2 Answers

GameObject Array in Editor GUI 3 Answers


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