Multiple object same script work only one object

时间:2017-02-12 10:10:35

标签: c# unity5

When I'm enter into my Tptext(2) then press "E" my canvas will show dialogue, but when I walk into another Tptext(3) it doesn't work.

My 2 pinkpath My 2 pinkpath

调用html
public GameObject readCV;
public GameObject Teext;
public bool guishow = false;
string Readstr = "too high";

void Update(){
    if(guishow == true && Input.GetKeyDown(KeyCode.E)){
        Reader();
    }
    else if(Input.anyKeyDown)
    {
        readCV.SetActive(false);
    }
}

private void OnTriggerEnter2D(Collider2D other)
{
    guishow = true;
}

private void OnTriggerExit2D(Collider2D other)
{
    guishow = false;
}

void Reader(){
    Teext.GetComponent<UnityEngine.UI.Text>().text = Readstr;
    readCV.SetActive(true);
}

ps.sorry for my bad language

0 个答案:

没有答案