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 /
avatar image
1
Question by Arin_Jisoo · Sep 10, 2017 at 01:31 PM · unity 5uitext

UI Text In Seconds

 public Text Damagew;
 
     void Start () {
 
         anim = GetComponent<Animator> ();
         Damagew.enabled = false;
 
     }
 
     public void AppliedDamage(float damage){
 
         health -= damage;
 
         if (health <= 0f) {
 
             anim.Play("Death");
     
             Destroy (gameObject,2);
             Damagew.enabled = true;
 
         
 
         }
 
 
     }
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 Arin_Jisoo · Sep 11, 2017 at 02:51 AM 0
Share

It still not showing up

2 Replies

· Add your reply
  • Sort: 
avatar image
-1

Answer by Arin_Jisoo · Sep 10, 2017 at 01:33 PM

This is my code. what i want to happen if. is the death animation play. the UI text shows with "Kill Zombie" and that's happen. but my problem is it not disappear what i want if after 1 seconds my text will be disappear and show up again when i kill another zombie. thanks for help :)

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
Wiki

Answer by tormentoarmagedoom · Sep 10, 2017 at 04:57 PM

Hello @Arin_Jisoo !!

Then you need this:

Have a Text with " Zombie Kill ! " and use the "enabled" attribute to show/not show. You can also use the "Invoke" to send the command "stop showing the text in 1 second".

Lets call the Text Object TheTextYouWantToShow in the GameScene. Then, we need to declare and identify it in the script:

 Text KillZmbText;
 
 private void Start ()
 {
 KillZmbText = GameObject.Find ("TheTextYouWantToShow").GetComponent<Text>();
 }

Now, lets create a method that will stop showing the text

 void StopShowingZombieText()
 {
 KillZmbText.enabled=false;
 }

Now we need to create the commands that will show the text, and will program for 1 second later the method "StopShowingZombieText". Put this in the script where will be executed when a zombie is killed:

 KillZmbText.enabled=true;
 Invoke ("StopShowingZombieText",1);

As you can imagine, the invoke calls a method writed as string (so is not possible to use methods with parameters) in a selected time (in float, you can use decimals like 1.5f or 8.256435f) :

Invoke ("Nameofmethod", time in seconds)

I think i solved your problem, if not, ask for more using @tormentoarmagedoom

Bye! :D

Comment
Add comment · Show 3 · 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 Arin_Jisoo · Sep 11, 2017 at 02:50 AM 0
Share
     Text $$anonymous$$illZmbText;
 
     void Start () {
 
         anim = GetComponent<Animator> ();
 
         $$anonymous$$illZmbText = GameObject.Find ("Zombie Hit!! + 5pts").GetComponent<Text> ();
     }
 
 
     void StopShowingZombieText(){
         $$anonymous$$illZmbText.enabled = false;
     
     }
 
     public void AppliedDamage(float damage){
 
         health -= damage;
 
         if (health <= 0f) {
 
             anim.Play("Death");
 
             Destroy (gameObject,2);
 
             $$anonymous$$illZmbText.enabled = true;
             Invoke ("StopShowingZombieText", 1);
 
         }
 
 
     }
         
 }
avatar image Arin_Jisoo · Sep 11, 2017 at 02:59 AM 0
Share

now its not showing up. but i don't get any error thank s for your time :)

avatar image tormentoarmagedoom Arin_Jisoo · Sep 13, 2017 at 10:45 AM 0
Share

$$anonymous$$aybe now you have some render problem. Try to dont use the "best Fit" text option, dont let the text ocuppy all the text box. Check the canvas render distances, layers, all this things.

You can check the iteracy to check if the text enables and disables.

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

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

Unity UI Text Component bugs out seemingly randomly 0 Answers

Text wont change to correct value 1 Answer

The variable has not been assigned error ? 0 Answers

[UI] "Best fit" in text object stretches a single word across two lines 3 Answers

How to shrink text size 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