unity Screen.width, Screen.height

博客指出从编译器调用某函数时,获取的值不正确,实际获取到的是editorwindow的大小,反映了编译器调用函数过程中存在的问题。

如果事从编译器调用这个函数,获取的值不正确,获取的是editorwindow的大小

using UnityEngine; using System.Collections; public class Helper : MonoBehaviour { public Texture2D[] helpTextures; public Texture2D leftArrows; public Texture2D rightArrows; private int helpValue = 0; public GUIStyle myStyle; public Texture2D backButton; public int w; public int h; // Use this for initialization void Start () { this.enabled=false; } // Update is called once per frame void Update () { if(Input.GetKeyUp(KeyCode.Escape)) { helpValue = 0; this.enabled=false; InitButton s=(InitButton)GetComponent("InitButton"); s.enabled=true; } } void OnGUI () { GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), helpTextures[helpValue], ScaleMode.StretchToFill); if(helpValue != 0 && helpValue != helpTextures.Length - 1){ if(GUI.Button(new Rect(Screen.width * 0.1f, Screen.height * 0.4f, Screen.width * 0.1f, Screen.height * 0.2f), leftArrows, myStyle)){ helpValue--; } if(GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.4f, Screen.width * 0.1f, Screen.height * 0.2f), rightArrows, myStyle)){ helpValue++; } }else if(helpValue == 0){ if(GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.4f, Screen.width * 0.1f, Screen.height * 0.2f), rightArrows, myStyle)){ helpValue++; } }else if(helpValue == helpTextures.Length - 1){ if(GUI.Button(new Rect(Screen.width * 0.1f, Screen.height * 0.4f, Screen.width * 0.1f, Screen.height * 0.2f), leftArrows, myStyle)){ helpValue--; } if(GUI.Button(new Rect(Screen.width * 0.8f, Screen.height * 0.4f, Screen.width/5, Screen.height/5), backButton, myStyle)){ helpValue = 0; Chooes s=(Chooes)GetComponent("Chooes"); s.enabled=true; GameObject fly=GameObject.Find("flyer"); Transform plane=fly.transform.Find("plane"); plane.renderer.enabled=false; Transform p=plane.transform.Find("p47 prop01"); p.renderer.enabled=false; this.enabled=false; } } } }我说的这个代码
05-29
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值