using UnityEngine;
using System.Collections;

public class Text1 : MonoBehaviour {

    public GameObject Label;
    public GameObject Button2;
    public GameObject Sprite1;

    public int mousedown;

 // Use this for initialization
 void Start () {

 }

 // Update is called once per frame
 void Update () {

 }

    void OpendButton(GameObject obj)
    {
        //获取label里面的字体
        UILabel txt = Label.GetComponent<UILabel>();
        //获取button里面的组件
        UIButton exe = Button2.GetComponent<UIButton>();

        if (obj.name == "Button1")
        {
            txt.text = "随便1";
            txt.password = true;
        }
        else if (obj.name == "Button2")
        {
            txt.text = "随便2";
            txt.password = false;
        }

        if (obj.name == "Button1")
        {   
            mousedown++;

            if (mousedown%2==1)
            {
                exe.isEnabled = false;
                GameObject target1 = Instantiate(Sprite1) as GameObject;
                target1.transform.parent = this.transform.parent;
                target1.transform.localPosition = Vector3.zero;
                target1.transform.localScale = new Vector3(255,76,0);
                target1.name = "target1";
                //Sprite1.SetActive(true);
            }
            else if (mousedown%2 == 0) 
            {
                exe.isEnabled = true;
                //Sprite1.SetActive(false);
                Destroy(GameObject.Find("target1"));

            }

        }

    }

}