Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
No se muestra el botón Continuar incluso después de que el Diálogo se realiza en Unity

No quiero que el jugador envíe correo no deseado al botón continuar, por lo tanto, solo quiero que aparezca después de que finalice el diálogo.

Funciona en el primer índice pero para el siguiente elemento no aparece el botón continuar. Aquí está mi código:

 using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class DialogueSE : MonoBehaviour { public TextMeshProUGUI textDisplaySE; public string[] sentencesSE; private int index; public float typingSpeedSE; public GameObject continueButtonSE; void Start() { StartCoroutine(Type()); } void Update() { if(textDisplaySE.text == sentencesSE[index]) { continueButtonSE.SetActive(true); } } IEnumerator Type() { foreach (char letter in sentencesSE[index].ToCharArray()) { textDisplaySE.text += letter; yield return new WaitForSeconds(typingSpeedSE); } } public void NextSentenceSE() { continueButtonSE.SetActive(false); if (index < sentencesSE.Length - 1) { index++; textDisplaySE.text = " "; StartCoroutine(Type()); } else { textDisplaySE.text = " "; continueButtonSE.SetActive(false); } } }

He deshabilitado el botón de continuar SE desde el principio para que solo pueda aparecer una vez que las oraciones SE [índice] hayan terminado de aparecer.

ingrese la descripción de la imagen aquí

ingrese la descripción de la imagen aquí

ingrese la descripción de la imagen aquí ingrese la descripción de la imagen aquí

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Está anteponiendo un espacio cuando dice textDisplaySE.text = " "; y luego agrega cosas en la corrutina, por lo tanto if(textDisplaySE.text == sentencesSE[index]) nunca es cierto porque en el segundo caso, textDisplaySE.text es en realidad [space]test2 en lugar de solo test2 , que es lo que sentenciasSE [índice] .

En la línea 31, en cambio, puede inicializar a textDisplaySE.text = string.Empty; para no tener ningún espacio en blanco.

over 4 years ago · Santiago Trujillo Report

0

Además de la explicación de su problema de esta respuesta

¿Por qué necesita el cheque en absoluto?

Simplemente puede dejar que su Coroutine maneje el final de la escritura y habilitar el botón continuar como, por ejemplo

 IEnumerator Type() { foreach (char letter in sentencesSE[index].ToCharArray()) { textDisplaySE.text += letter; yield return new WaitForSeconds(typingSpeedSE); } if (index < sentencesSE.Length - 1) { continueButtonSE.SetActive(true); } } public void NextSentenceSE() { continueButtonSE.SetActive(false); if (index < sentencesSE.Length - 1) { index++; textDisplaySE.text = ""; StartCoroutine(Type()); } else { textDisplaySE.text = ""; Debug.Log("Reached end of dialog"); } }

De esta manera, no necesita el método de Update y la comparación de cadenas en absoluto y ni siquiera entraría en el problema con el carácter de espacio antepuesto;)

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!