Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by theredkey · Dec 09, 2016 at 03:06 PM · uitextresethide

How to hide/reset a Text object (without disabling)

I want to add dialogue to my little game and i ran into a problem. I can get the text to show up and play the way i want but when I leave the triggerzone which sets active/inactive the text in the middle of the dialogue, it seems to freeze. When I reenter the triggerzone only the frozen part of the dialogue shows up and i can no longer interact with the text (go to the next part of it etc.)

It seems this freezing is caused by my deactivation of the text through the trigger zone. disableing the renderer also does not seem to help as neither the text nor the panel use one.

are there ways or commands (preferably c#) that can hide UI elements or reset them (position/size/rotation resetting is what i found but not general resetting in terms of everything)

Comment
Add comment · Show 1
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 Ralp7 · Dec 09, 2016 at 03:45 PM 0
Share

You can create a button and change its color alpha to 0. Then create a child text object. You can set active or inactive the text by using button object. I wrote this code, when mouse enters the button object, text shows up. When mouse exits the button, the text disappear. Think this button as a Game$$anonymous$$anager. I hope it is want you want.

 using UnityEngine;
 using UnityEngine.UI;
 using UnityEngine.EventSystems;
 
 public class ActiveText : $$anonymous$$onoBehaviour, IPointerEnterHandler, IPointerExitHandler
 {
     Text myText;
 
     void Start ()
     {
         myText = GetComponentInChildren<Text>();    
     }
     
     public void OnPointerEnter(PointerEventData eventData)
     {
         myText.gameObject.SetActive(true);
     }
 
     public void OnPointerExit(PointerEventData eventdata)
     {
         myText.gameObject.SetActive(false);
     }
 }
 

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by RobAnthem · Dec 10, 2016 at 09:57 AM

  using UnityEngine;
  using UnityEngine.UI;
  using UnityEngine.EventSystems;
  
  public class ActiveText : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
  {
      string myString;
      Text myText;
  
      void Start ()
      {
          myText = GetComponentInChildren<Text>();    
      }
      
      public void OnPointerEnter(PointerEventData eventData)
      {
          myText.Text = myString;
      }
  
      public void OnPointerExit(PointerEventData eventdata)
      {
          myText.Text = "";
      }
  }
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 theredkey · Dec 10, 2016 at 08:36 AM

@Ralp7

Thank you, but the ".SetActive(false);" command (which is in your code as well) is what causes my text to freeze. I am looking for alternatives for it.

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

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

110 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 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 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 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 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

Hide (not delete) text after given time..? 1 Answer

UI Canvas Anchor points are stuck in the bottom left corner and disabled when in overlay mode. 1 Answer

How To Load TTF Font From External File 0 Answers

Adventure Game Help 0 Answers

How to make Textmesh Pro effects on only one text object? 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