4
I have a problem in unity3d and I don’t know how to solve.
I have a certain script
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class CharacterSelector : MonoBehaviour
{
    [SerializeField]
    private Text bio1 = null;
    private Text data2 = null;
    private Text name = null;
    private Text subname = null;
    private GameObject[] characterList;
    private int index;
    private void Start()
    {
        characterList = new GameObject[transform.childCount];
        for (int i = 0; i < transform.childCount; i++)
        {
            characterList[i] = transform.GetChild(i).gameObject;
            foreach (GameObject f in characterList)
            {
                f.SetActive(false);
                if (characterList[0])
                    characterList[0].SetActive(true);
            }
        }
    }
    public void ToggleLeft()
    {
        //desligar o modelo atual
        characterList[index].SetActive(false);
        index--;
        if (index < 0)
            index = characterList.Length - 1;
        //ligar o modelo atual
        characterList[index].SetActive(true);
    }
    public void ToggleRight()
    {
        //desligar o modelo atual
        characterList[index].SetActive(false);
        index++;
        if (index == characterList.Length)
            index = 0;
        //ligar o modelo atual
        characterList[index].SetActive(true);
    }
    public void COnfirmButton()
    {
        if (index == 0) 
        {
            SceneManager.LoadScene("NeroRoom");             
        }
        if (index == 1) 
        {
            SceneManager.LoadScene("Menu");
        }
    }
    public void ChangeText() 
    {
        if (index == 0) 
        {
            name.text = "Mac Logan";
            subname.text = "O coração valente";
        }
    }
}
This script is linked to a gameobject that has the characters of the game that depending on each the biography and specifications will change. This can be seen in Public void Confirmbutton.
So how do I change a text depending on the characters that are appearing?
The part of [Serializefield] up to private Text subname = null; I saw it in a tutorial but it didn’t work.

Have you tried to enable and disable text ? Ex: use the following condition in script:
xis enabled the text ofx, if you have the characteryactive shows the text ofy, and so successively making the response of each character to each text activating and disabling texts and Objects.– Miguel Soeiro