Hello everyone,
I would like to navigate through the menus like this:
the normal color (in the selectable component) is gray, the select color white and the pressed color yellow,
apart from changing color I would like the size of the font textmeshpro to be equal to 28 constant when it is gray, yellow is equal to 40 constant, and if the color is white that means selected the font size text mesh pro varies progressively between 28 and 40 according to a given speed,
I tried this code and changed the textmeshpro font setting to dynamic and it didn’t work:
1-not gradual size change font textmesh pro but abrupt
2-all the texts of the menus change at the same time whether it is in 28 or 40 suddenly whatever their colors white or gray gold I would like only the text in white to change gradually.
Please help me please, thank you very much.
here is my code:
using UnityEngine;
using TMPro;
public class Selectionne : MonoBehaviour
{
Color gray = new Color(0.5f, 0.5f, 0.5f), white = new Color(1f, 1f, 1f), yellow = new Color(1f, 1f, 0.5f);
Color bouton;
TextMeshProUGUI texte;
bool tour1 = true;
public float speed;
float totalSpeed;
// Start is called before the first frame update
void Start()
{
bouton = GetComponent<TextMeshProUGUI>().color;
texte = GetComponent<TextMeshProUGUI>();
}
// Update is called once per frame
void Update()
{
if (bouton ==white)
{
if (tour1)
{
if (texte.fontSize < 40)
{
totalSpeed+= speed * Time.deltaTime;
texte.fontSize += (int)totalSpeed;
}
else
{
tour1 = false;
totalSpeed= 0;
}
}
else
{
if (texte.fontSize > 28)
{
totalSpeed+= speed * Time.deltaTime;
texte.fontSize -= (int)totalSpeed;
}
else
{
tour1 = true;
totalSpeed = 0;
}
}
}
else if (bouton == gray)
texte.fontSize = 28;
else if (bouton == yellow)
texte.fontSize = 40;
}
}
Cordially .