Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 Stoyanow · Jul 20, 2015 at 03:06 PM · 2duitextglitch

UI text glitch/bug in 2D game

I have a text. I enable/disable it. On some object it works fine. On another it doesn't show at all. Here is the script, maybe I'm doing something wrong idk.

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 
 public class TextInfoPop : MonoBehaviour {
     
     
     public Text text;
     bool playerInZone;
     // Use this for initialization
     void Start () {
         
         text.enabled = false;
     }
     
     // Update is called once per frame
     void Update () {
         if(Input.GetKeyDown(KeyCode.Space) && playerInZone){
             text.enabled = !text.enabled;
             
         }
         
         else if(playerInZone == false){
             text.enabled = false;
             
         }
     }
     
     void OnTriggerEnter2D(Collider2D other){
         if(other.name == "Player")
             playerInZone = true;
     }
     
     
     void OnTriggerExit2D(Collider2D other){
         if(other.name == "Player")
             playerInZone = false;
     }
     
     
 }

Anny help is greatly appriciated, cause I'm gonna go crazy soon if i don't find out what's wrong.

Comment
Add comment · Show 3
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 Nerevar · Jul 20, 2015 at 03:12 PM 0
Share

make sure that all you items have a collider set to trigger, have you tried to build the game to see if the bug was still here?

avatar image Veldars · Jul 20, 2015 at 03:16 PM 0
Share

Hi,

Your second object has a Collider2D and a Rigidbody2D too ?

As I can't saw that I cannot be sure of the problem but did you try your script without the playerInZone condition to be sure that the problem come from the collider.

avatar image Stoyanow · Jul 20, 2015 at 03:32 PM 0
Share

I attach this script to a Vase(for example), and when player presses Space, UI text says "This is a vase".

The Vase GameObject doesn't need a rigidbody. The Player has Rigidbody2D and box + circle collider.

I tried attaching Rb2D to the Vase too.. Doesn't work. To be more specific, the text flickers, it shows for 0.001sec, and dissapears again. And when collide with another objects, it shows up just fine.

Built the game and ran it. Bug is still there.

Here are Images of the 2 gameobjects, 1 shows the texts when collided, and hides when player is not in zone, and the other shows for 0.01 sec and disappears. I must press 100 times Space, to read what the text says.

alt text

alt text

1.jpg (35.4 kB)
2.jpg (37.2 kB)

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

23 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Having a lot of trouble with GUI scaling 1 Answer

Text Appearance Glitch in Unity UI, 5.3 0 Answers

UI Text won't appear at all. 1 Answer

How to detect button presses and change child object text in the button's Parent Object script 0 Answers

UI text won't appear 0 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