• 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 hyunnismly · Mar 05, 2019 at 01:56 AM · unity 3.5

Score board do not respond..,Quiz score board does not respond

Hello. I am trying to do quiz game though youtube Patrik youtubers Quiz Game But somehow the score board does not respond . Any idea what wrong in the code ?

respond.cs

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine.UI;
 using UnityEngine;
 
 public class respond : MonoBehaviour
 {
     private int idthemes;
 
     public Text Question;
     public Text answerA;
     public Text answerB;
     public Text answerC;
     public Text answerD;
     public Text infoAnswer;
 
     public string[] questions;      //store question
     public string[] alternateA;     //store alternateA
     public string[] alternateB;     //store alternateB
     public string[] alternateC;     //store alternateC
     public string[] alternateD;      //store alternateD
     public string[] correct;            //store alternatecorrect
 
 
     private int idQuestion;
 
     private float hitQ;
     private float questionsss;
     private float media;
     private int notaFinal;
 
 
     // Start is called before the first frame update
     void Start()
     {
         idthemes = PlayerPrefs.GetInt("idthemes");
         idQuestion = 0;
         questionsss = questions.Length;
 
         Question.text = questions[idQuestion];
         answerA.text = alternateA[idQuestion];
         answerB.text = alternateB[idQuestion];
         answerC.text = alternateC[idQuestion];
         answerD.text = alternateD[idQuestion];
 
         infoAnswer.text = "Answer " + (idQuestion + 1).ToString() + " of " + questionsss.ToString() + " Questions.";
 
 
     }
 
     public void answer (string alternate)
     {
         if (alternate == "A")
         {
 
             //execute answer A
             if(alternateA[idQuestion] == correct[idQuestion])
             {
                 hitQ += 1;
             }
 
 
         }
 
         else if (alternate == "B")
         {
 
             //execute answer B
             if (alternateA[idQuestion] == correct[idQuestion])
             {
                 hitQ += 1;
             }
         }
 
         else if (alternate == "C")
         {
 
             //execute answer C
             if (alternateA[idQuestion] == correct[idQuestion])
             {
                 hitQ += 1;
             }
         }
 
         else if (alternate == "D")
         {
 
             //execute answer D
             if (alternateA[idQuestion] == correct[idQuestion])
             {
                 hitQ += 1;
             }
         }
 
         nextQuestion();
 
     }
 
 
     void nextQuestion()
     {
 
         idQuestion += 1;
 
         if (idQuestion <= (questionsss - 1))
         {
 
             Question.text = questions[idQuestion];
             answerA.text = alternateA[idQuestion];
             answerB.text = alternateB[idQuestion];
             answerC.text = alternateC[idQuestion];
             answerD.text = alternateD[idQuestion];
 
             infoAnswer.text = "Answer " + (idQuestion + 1).ToString() + "of " + questionsss.ToString() + " Questions.";
 
         }
 
         else
         {
             //what to do if question finish
             media = 10 * (hitQ / questionsss);  //calculate into percent
             notaFinal = Mathf.RoundToInt(media); //round off
 
             if(notaFinal > PlayerPrefs.GetInt("notaFinal"+idthemes.ToString()))
             {
                 PlayerPrefs.SetInt("notaFinal"+idthemes.ToString(),notaFinal);
                 PlayerPrefs.SetInt("hitQ"+idthemes.ToString(),(int) hitQ);
             }
 
             PlayerPrefs.SetInt("notaFinalTemp" + idthemes.ToString(), notaFinal);
             PlayerPrefs.SetInt("hitQTemp" + idthemes.ToString(), (int)hitQ);
 
 
 
             Application.LoadLevel("notaFinal");
 
         }
     }
 
 
 
 
 
 
 }

notaFinal.cs

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine.UI;
 using UnityEngine;
 
 public class notaFinal : MonoBehaviour
 {
 
     private int idthemes;
 
     public Text txtnota;
     public Text txtinfothemes;
 
 
     public GameObject star1;
     public GameObject star2;
     public GameObject star3;
 
     private int notaF;
     private int acertos;
 
 
 
     // Start is called before the first frame update
     void Start()
     {
 
         idthemes = PlayerPrefs.GetInt("idthemes");
         notaF = PlayerPrefs.GetInt("notaFinalTemp" + idthemes.ToString());
         acertos = PlayerPrefs.GetInt("hitQTemp" + idthemes.ToString());
 
         txtnota.text = notaF.ToString();
         txtinfothemes.text= "Correct "+acertos.ToString();
         
         
     }
 
     // Update is called once per frame
     void Update()
     {
         
     }
 }
 

Comment
Add comment · Show 3
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 hyunnismly · Mar 05, 2019 at 01:59 AM 0
Share
 txtnota.text = notaF.ToString();  // display score 
          txtinfothemes.text= "Correct "+acertos.ToString(); //display correct question

avatar image king_opping · Mar 05, 2019 at 05:02 AM 0
Share

what the error, and what do you mean by not respond? it doesn't return a value(wether correct/not)?

avatar image hyunnismly · Mar 05, 2019 at 01:35 PM 0
Share

@king_opping sorry... it respond .. but always " 0 " even though i answer the questions correctly.

alt text

screenshot-4.png (489.5 kB)

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

101 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

Related Questions

Webcam Unity 3.5 not working on Android? 0 Answers

GrayscaleEffect shader broken in 3.5? 0 Answers

Error with Camera.allCameras on building flash build for unity 3.5 0 Answers

'text' is not a member of 'OBJECT' JavaScript Not Working in Unity 3.5 - Lost Commands? 2 Answers

Unity 3.5 w/android&IOS vs 4.0 free? 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