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 hjd22 · Oct 08, 2015 at 12:20 AM · cs

How to make ammo appear on screen in c sharp

Hi, I am working on a game with my friend and I have made a shoot script and it works fine, it uses ammo and the ammo part works i just dont know how to make the ammo count appear on screen. I have looked for tutorials, but i only found them in javascript. I was hoping to figure out how to do this in c#. If you know of any good videos or websites that could help me do this or you know how to do this please show me, thank you. Also this is the first time i have posted a question sorry if i did it wrong

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

2 Replies

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

Answer by OctoMan · Oct 08, 2015 at 01:13 PM

When you use Unity 4.6 and the Canvas system, create a textfield where ever you want the count.
In your script add the namespace:

 using UnityEngine.UI;

So you have access to textfields and stuff Now you create a connection to that Textfield.

 public Text AmmoAmount;

Now drag the textfield in Slot in your inspector.
Finally write data into that textfield whenever you use a shot or relaod.

 AmmoAmount.text = yourAmmoValue.toString();

Thats it. Cheers

Comment
Add comment · Show 2 · 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 hjd22 · Oct 08, 2015 at 04:05 PM 0
Share

Will this work in unity 5.1.1?

avatar image hjd22 · Oct 08, 2015 at 09:41 PM 0
Share

Thank you so much, I have been trying to get this to work for the past week, lots of thanks.

avatar image
0

Answer by etopsirhc · Oct 08, 2015 at 01:17 AM

add a label ui element, then in the script add a public variable of that type and drag it into the slot in the inspector. after that you just need to set variableName.text to the number you want to display.

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 hjd22 · Oct 08, 2015 at 12:45 PM 0
Share

But is the number i add constantly changing because thats what the ammo would be doing?

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Inter Script Communication fail 1 Answer

transform.eulerAngles not working 2 Answers

error CS0101: The namespace `global::' already contains a definition for `SceneManagerLoadScene' 0 Answers

NullReferenceException (Updated) 1 Answer

HELP I would like a button that leverage the AAA graphics 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