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
0
Question by Arin_Jisoo · Sep 11, 2017 at 02:55 AM · unity 5uitextmessage

Disable and Enable UI text in function

so far this is my using code. what i want is. if i kill a zombie the word "zombie kill +5pts" will show up and disappear after 1 second. and appear again when i kill another zombie. like in Call Of Duty Multiplayer. any help and suggestion is accepted thanks. by the way this script is attached on zombie

Text KillZmbText;

     void Start () {
 
         anim = GetComponent<Animator> ();
 
         KillZmbText = GameObject.Find ("Zombie Hit!! + 5pts").GetComponent<Text> ();
     }
 
 
     void StopShowingZombieText(){
         KillZmbText.enabled = false;
     
     }
 
     public void AppliedDamage(float damage){
 
         health -= damage;
 
         if (health <= 0f) {
 
             anim.Play("Death");
 
             Destroy (gameObject,2);
 
             KillZmbText.enabled = true;
             Invoke ("StopShowingZombieText", 1);
 
         }
 
 
     }
         
 }
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by PersianKiller · Sep 11, 2017 at 03:19 AM

it's very simple and easy idea :). you need a UI text

 public void Zombie Hit(){
 if(zombieDied){
         StartCoroutine("aa");

 }

}

 public IEnumerator aa(){
     t1.text="Zombie Hit!! + 5pts";
     yield return new WaitForSeconds (1);
     t1.text = "";
 
 }

hope you get it :).

download this ,it might help

http://s8.picofile.com/file/8306100000/bandicam_2017_09_11_08_34_49_930.mp4.html

and then click on it to download ,it's not an English site and try not to sacre :D .

alt text


untitled.png (6.6 kB)
Comment
Add comment · Show 23 · 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 03:28 AM 0
Share

should i create UI text in my canvas ? thanks for your time

avatar image PersianKiller Arin_Jisoo · Sep 11, 2017 at 03:56 AM 0
Share

of course you should.then you can put your text when zombie died in there.

avatar image Arin_Jisoo PersianKiller · Sep 11, 2017 at 04:30 AM 0
Share

Well the text shows up from the beginning and its not disappearing after 1 seconds. maybe i am dumb. but i don't really get it haha. but i dont have errors

 ![SerializeField]private float health = 100f;
     private Animator anim;
     public Text t1;
 
 
 
     void Start () {
 
         anim = GetComponent<Animator> ();
 
     }
         
 
     public void AppliedDamage(float damage){
 
         health -= damage;
 
         if (health <= 0f) {
 
             anim.Play("Death");
 
             StartCoroutine ("a");
             Destroy (gameObject,2);    
         }
     }
 
     public IEnumerator aa(){
         t1.text = "Zombie Hit!! + 5pts";
         yield return new WaitForSeconds(1);
         t1.text = "";    
     }
 }][1]


[1]: /storage/temp/101638-screenshot-48.png

screenshot-48.png (385.9 kB)
Show more comments
avatar image PersianKiller Arin_Jisoo · Sep 11, 2017 at 04:30 AM 0
Share

@Arin_Jisoo I updated the answer check it.

avatar image Arin_Jisoo PersianKiller · Sep 11, 2017 at 04:50 AM 0
Share

Thank you Very much !! It works. but i have 1 more question i will put the IEnumerator in the AccessTheText Script so it will disappear after 1 seconds ? sorry for question but its not included in the Video xD

Show more comments
Show more comments

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

176 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

Related Questions

Pass through control on UI elements? 0 Answers

Water Drop effect on text 0 Answers

Text UI broken after changing alpha color of single letters 1 Answer

Last Entry of Dialogue displayed in separate Text (Scriptable objects) 0 Answers

Font Render Issue Unity 5.3.4f1 on Samsung devices 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