• 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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

Inputfield text to String variable 1 Answer

Disable and Enable UI text in function 1 Answer

Font renders incorrectly 1 Answer

Cannot drag text object into inspector 2 Answers

UI Text Disappears At Some Resolutions 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges