Fade In/out text after zooming.

Hey there!

I am currently trying to make a simulation of our solar system in Unity. Right now I am dealing with the nametags for the planets. I got the text to follow the planet!

My question: Is it possible to make that text fade out when I zoom in close to my planet. And fade it in when I am far away.

This is the code I currently have for the text:

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

public class PlanetTag : MonoBehaviour
{
    public Text nameLable;


    // Update is called once per frame
    void Update()
    {
        Vector3 namePose = Camera.main.WorldToScreenPoint(this.transform.position);
        nameLable.transform.position = namePose;
    }
}

How would I go about implementing this fade system?

I would approach this this the other way around. I would have a list/array of all of the planets, their names and positions, then I would find the planets on the list based on distance and use that list to show the names…

There’s a star map example somewhere, and if I find it, I’ll post it.

[edit]
Found it:

[/edit]

1 Like