标签:
最近在玩植物大战僵尸Ol打到僵尸迷阵,打了个700分倒数第一,擦。。。。。俗话说的好,失败是成功的妈妈,于是花了点时间写了一个小玩意,我相信下次我一定能拿第一
代码非常简单:
using UnityEngine; using System.Collections; using UnityEngine.UI; public class MyScript : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { if (Input.GetKeyUp(KeyCode.LeftArrow)) { Button_Left();//调用左键 } if (Input.GetKeyUp(KeyCode.RightArrow)) { Button_Regith();//调用右键 } if (Input.GetKeyUp(KeyCode.Space)) { foreach (Image i in _Nimage) { i.GetComponent<Button>().interactable = true; } } } public Image _AllImage;//存储父物体 public Image[] _Nimage; public void Button_Left() { _AllImage.transform.Rotate(0,0,90);//旋转父物体 _AllImage.transform.localScale = new Vector3(_AllImage.transform.localScale.y, _AllImage.transform.localScale.x, _AllImage.transform.localScale.z);//长和宽互换 } public void Button_Regith() { _AllImage.transform.Rotate(0, 0, -90); _AllImage.transform.localScale = new Vector3(_AllImage.transform.localScale.y, _AllImage.transform.localScale.x, _AllImage.transform.localScale.z); } public void Button_Initialize(int temp)//按钮变色 { _Nimage[temp].GetComponent<Button>().interactable = false; } public void Button_enable()//重置按钮颜色 { foreach(Image i in _Nimage) { i.GetComponent<Button>().interactable = true; } } public void Button_Scene1() { Screen.SetResolution(1280, 800, false);//屏幕大小为1280,800,窗口 } public void Button_Scene2() { Screen.SetResolution(640, 400, false);//屏幕大小为640,400,窗口 } public void Button_Scene3() { Screen.SetResolution(480, 300, false);//屏幕大小为480,300,窗口 } public void Button_Scene4() { Screen.SetResolution(320, 200, false);//屏幕大小为320,200,窗口 } }
工程案例:链接:http://pan.baidu.com/s/1mhvDVwW 密码:qm5b
标签:
原文地址:http://www.cnblogs.com/kubll/p/5086471.html