• 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
Question by Mauriortiz · Nov 26, 2022 at 04:20 PM · error messageerror builderrormessage

error CS1061: 'QuestionData' does not contain a definition for 'textoDaPergunta' and no accessible extension method 'textoDaPergunta' accepting a first argument of type 'QuestionData' could be found

No encuentro el ERROR que podría estar fallando, alguien que me pueda ayudar:

alt text

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement;

public class GameController : MonoBehaviour{

 public Text textoPergunta;
 public Text textoPontos;
 public Text textoTimer;
 public Text $$anonymous$$ghScoreText;

 public SimpleObjectPool answerButtonObjectPool;
 public Transform answerButtonParent;
 public GameObject painelDePerguntas;
 public GameObject painelFimRodada;
     
 private DataController dataController;
 private RoundData rodadaAtual;
 private QuestionData [] questionPool;

 private bool rodadaAtiva;
 private float tempoRestante;
 private int questionIndex;
 private int playerScore;

 List<int> usedValues = new List<int>();

 private List<GameObject> answerButtonGameObjects = new List<GameObject>();
 
 // Start is called before the first frame update
 void Start() {
     
     dataController = FindObjectOfType<DataController>();
     rodadaAtual = dataController.GetCurrentRoundData();

     questionPool = rodadaAtual.perguntas;
     tempoRestante = rodadaAtual.limiteDeTempo; 

     UpdateTimer();

     playerScore = 0;
     questionIndex = 0;
     ShowQuestion();
     rodadaAtiva = true;
 }

 // Update is called once per frame
 void Update() {
     
     if (rodadaAtiva)
     {
         tempoRestante -= Time.deltaTime;
         UpdateTimer();
         if(tempoRestante <= 0)
         {
             EndRound();
 }

} } private void UpdateTimer() { textoTimer.text = "Timer: " + Mathf.Round(tempoRestante).ToString(); } private void ShowQuestion() { RemoveAnswerButtons(); int random = Random.Range(0, questionPool.Length); w$$anonymous$$le (usedValues.Contains(random)) { random = Random.Range(0, questionPool.Length); }

 QuestionData questionData = questionPool[random];
 usedValues.Add(random);
 textoPergunta.text = questionData.textoDaPergunta;

 for (int i = 0; i < questionData.respostas.Length; i++)
  {
     GameObject answerButtongameObject = answerButtonObjectPool.GetObject();

     answerButtongameObject.transform.SetParent(answerButtonParent);

     answerButtonGameObjects.Add(answerButtongameObject);

     AnswerButton answerButton = answerButtongameObject.GetComponent<AnswerButton>();
     answerButton.Setup(questionData.respostas[i]);
     }
     }

 private void RemoveAnswerButtons()
  {
     w$$anonymous$$le(answerButtonGameObjects.Count > 0)
     {
         answerButtonObjectPool.ReturnObject(answerButtonGameObjects[0]);
         answerButtonGameObjects.RemoveAt(0);

} }

     public void AnswerButtonClicked(bool estaCorreto)
      {
         if (estaCorreto)
          {
             playerScore += rodadaAtual.pontosPorAcerto;
             textoPontos.text = "Score: " + playerScore.ToString();
               }
               if(questionPool.Length > questionIndex + 1)
               {
                 questionIndex++;
                 ShowQuestion();
                   }
                   else
                   {
                     EndRound();
                     }
                     }
             public void EndRound()
             {
                 rodadaAtiva = false;

                 painelDePerguntas.SetActive(false);
                 painelFimRodada.SetActive(true);
                 }

             public void ReturnToMenu()
             {
                 SceneManager.LoadScene("Menu");
                }
                } 


error-1.jpg (73.4 kB)
Comment

People who like this

0 Show 0
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

Answer by Artmarab · Nov 26, 2022 at 05:18 PM

Go to your QuestionData class and check if it contains a public variable of string type named textoDaPregunta.

Comment

People who like this

0 Show 0 · 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

Answer by SurreyMuso · Nov 26, 2022 at 05:23 PM

In the second block of code (line 4) you have:

 textoPergunta.text = questionData.textoDaPergunta;
 


that is the only time you use textoDaPergunta. Do you have the right name? perhaps textoPergunta

Comment

People who like this

0 Show 0 · 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

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

152 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

Related Questions

Build and Run not working Error Message 0 Answers

error CS0019: Operator `-' cannot be applied to operands of type `System.DateTime' and `string' 1 Answer

Unity Gradle Build Failed 0 Answers

Internal build system error. Backend exited with code -1073741511.,Internal build system error. Backend exited with code -1073741511 1 Answer

How to resolve the error on build "drawable/app_banner not found in AndriodManifest.xml:57" 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