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 james 6 · Apr 06, 2011 at 07:32 AM · guitextiphone

hey how do i enable and disable a guitext object? i have

hey how do i enable and disable a guitext object? i have var Guitext : GameObject; //for gui text

Guitext = GameObject.Find("GUI Text"); Guitext.guiText.enabled = false;

then re-abling it i have

Guitext.guiText.enabled = true;

i have disable it no problem, however i could not reenable it need 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

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Bampf · Apr 06, 2011 at 06:16 PM

The problem is that GameObject.Find doesn't find objects after they have been disabled.

One solution is, keep an instance variable set to that object, so you don't have to Find it again to enable it.

Another approach is to keep your own list of objects that you might want to find. (This list can contain any objects you want, active or inactive, gui or other.) Then you can search that array instead of calling Find.

See: http://answers.unity3d.com/questions/14178/cannot-toggle-active-on-gameobjects-that-are-inactive

Comment
Add comment · 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
0

Answer by taoa · Apr 06, 2011 at 08:25 AM

There's no reason why this shouldn't work. The only place where something wrong could happen is that if

Guitext.guiText.enabled = true;

never gets called. Put a

Debug.log("whatever");

Right before or after to see if it gets called, and if not, try to figure out why this is (for instance inside an Update function of an object that is disabled or something)

Comment
Add comment · 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
0

Answer by Lewenos 1 · Apr 24, 2011 at 06:09 PM

var textObject : GUIText;

function OnMouseOver () { textObject.text = gameObject.name; textObject.GetComponent(GUIText).enabled = true; }

function OnMouseExit () { textObject.text = gameObject.name; textObject.GetComponent(GUIText).enabled = false; }

Comment
Add comment · 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
0

Answer by jwilliamsen · Feb 26, 2012 at 10:50 PM

I'm no coder - far from it - but I modified another script for toggling the visibility of an object via a key (Tab in this case) and it works perfectly:

 #pragma strict

function Update() {

 if (Input.GetKeyDown(KeyCode.Tab)) {
     // toggle visibility:
     guiText.enabled = !guiText.enabled;
 }

}

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 logicalOctopus · Feb 13, 2016 at 06:28 AM 0
Share

congratulations, you are now officially a coder!

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

2 People are following this question.

avatar image avatar image

Related Questions

iPhone GUI Text asks for edit on touch 0 Answers

Iphone gui text 2 Answers

UI.Text glitch when building for iOS device 0 Answers

gui text button dont work 1 Answer

Problem with GuiFont - Not appearing 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