Stratos: Punto de Encuentro de Desarrolladores

¡Bienvenido a Stratos!

Acceder

Foros





¿Como se hace un marcador de puntos en c# unity con TextMeshPro?

Iniciado por paco, 27 de Febrero de 2022, 08:35:17 AM

« anterior - próximo »

paco

https://videojuegosenlineaasaco4.blogspot.com/2022/02/pinball-detalles-con-c-game-over.html

¿Como se hace un marcador de puntos en c# unity con TextMeshPro?

aqui el c# para texto simple...pero yo quiero hacerlo con TextMeshPro para mejorarlo visualmente porque con Text es muy simple el resultado....
bueno el sript no es un marcador de puntos es un contador de tiempo que al ponerse a 0 desde 8 hace un cambio de escena...¿ como lo ago para usarlo con TextMeshPro???

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;/// <summary>
public class reiniciojuego2 : MonoBehaviour {


      public Text contador1;
      public Text fin1;
      private float tiempo = 8f;




   

      // Use this for initialization
      void Start () {
         contador1.text = " " + tiempo;
         fin1.enabled = false;

      }

      
      void Update ()
      {
      
         tiempo -= Time.deltaTime;
         contador1.text = " " + tiempo.ToString ("f0");
         if (tiempo <= 0) {
            contador1.text = "0";
            fin1.enabled = true;

            {
   

               {



                  Application.LoadLevel (0);

               }
            }
         }
      }

   }


MikasaAckerman

To achieve the same functionality using TextMeshPro in Unity, you'll need to make a few adjustments to your script. Here's the modified version of your script using TextMeshPro: fnf
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class resetgame2 : MonkeyBehaviour
{
    public TextMeshProUGUI counter1; // Use TextMeshProUGUI instead of Text
    public TextMeshProUGUI fin1; // Use TextMeshProUGUI instead of Text
    private float time = 8f;

    void Start()
    {
        counter1.text = " " + time.ToString("f0");
        fin1.enabled = false;
    }

    void Update()
    {
        time -= Time.deltaTime;
        counter1.text = " " + time.ToString("f0");
       
        if (time <= 0)
        {
            counter1.text = "0";
            fin1.enabled = true;
           
            // Load the scene
            Application.LoadLevel(0); // Note: Application.LoadLevel is deprecated in Unity 2019.3 and later. Use SceneManager.LoadScene instead.
        }
    }
}






Stratos es un servicio gratuito, cuyos costes se cubren en parte con la publicidad.
Por favor, desactiva el bloqueador de anuncios en esta web para ayudar a que siga adelante.
Muchísimas gracias.