unity hide/show text

using UnityEngine;
using System.Collections;

public class PlayerController:MonoBehaviour
{

    public UnityEngine.UI.Text winText;
    void Start(){
        winText.text = "You Win!";
        winText.gameObject.SetActive (false); //hide winText
    }

   ....
   
    void OnTriggerEnter(Collider other){
        if (other.gameObject.tag == "Coin") {
            other.gameObject.SetActive(false); //hide coin
         winText.gameObject.SetActive(true); //show winText
            
        }

    }

}

你可能感兴趣的:(unity)