Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 jorg van immerseel · Jun 01, 2014 at 04:52 PM · c#scripting problemcounting

counting in 3 different gui texts C#

i have made the code unther this text. what it should do is counting 12 times 3 arrows hitting a target. in the target are 5 rings. each ring has another tag. i have a script to count an overall score but now i need a script that counts points for three diffrent aarows and then makes the variables empty agin to count 3 arrows again. and that 12 times. but the script is not doing it. it just counts wrong. this link is a picture of what happens. the green count is my overall count and that is correct but the other tree counts ar wrong. http://prntscr.com/3oofbb

can anyone make my script work?

thanks

jorg

script:

using UnityEngine; using System.Collections; public class Count3pijlen: MonoBehaviour { public GUIText countText1; public GUIText countText2; public GUIText countText3; private static int count1; private static int count2; private static int count3; private int i; private int j; public void Start() { count1 = 0; count2 = 0; count3 = 0; SetCountText1(); SetCountText2(); SetCountText3(); } public void OnMouseUp() { for (j = 0; j < 12; j++) { for (i = 0; i < 3; i++) { if (i == 0) { switch (gameObject.tag) { case "White": count1 += 1; break; case "Black": count1 += 2; break; case "Blue": count1 += 3; break; case "Red": count1 += 4; break; case "Yellow": count1 += 5; break; } SetCountText1 (); } if (i == 1) { switch (gameObject.tag) { case "White": count2 += 1; break; case "Black": count2 += 2; break; case "Blue": count2 += 3; break; case "Red": count2 += 4; break; case "Yellow": count2 += 5; break; } SetCountText2 (); } if (i == 2) { switch (gameObject.tag) { case "White": count3 += 1; break; case "Black": count3 += 2; break; case "Blue": count3 += 3; break; case "Red": count3 += 4; break; case "Yellow": count3 += 5; break; } SetCountText3 (); } } } } void SetCountText1() { countText1.text = "Pijl 1: " + count1.ToString (); } void SetCountText2() { countText2.text = "Pijl 2: " + count3.ToString (); } void SetCountText3() { countText3.text = "Pijl 3: " + count3.ToString (); } }

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

0 Replies

· Add your reply
  • Sort: 

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

21 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

Related Questions

Getting all children of 3d model at once 1 Answer

Can't find fix for buggy camera 0 Answers

How can I make my character blink after hitting a certain object? 2 Answers

Distribute terrain in zones 3 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 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