button

public class button : MonoBehaviour {
    public GameObject obj;//声明Text游戏对象
    private int counter = 1;//声明计数器连良
    void Update() 
    {
        if (counter % 2 == 0)//当计数器可以整除2时
        {
            obj.SetActive(true);//Text游戏对象的active设为true
        }
        else { 
            obj.SetActive(false);//否则Text游戏对象的active设为false
        
        }
    }
    public void OnClick()
    {
        counter++;//计数器自加
    }

    
}

 

posted @ 2020-03-09 20:07  七只蚂蚁  阅读(178)  评论(0)    收藏  举报