Unity3d GUI弹窗】的更多相关文章

ArrayList w_position = new ArrayList(); void OnGUI() { if (GUILayout.Button("Open")) { if (allowMove) { allowMove = false; } w_position.Add(new Rect(200 + w_position.Count * 40, 200 + w_position.Count * 50, 100, 200)); } for (int i = 0; i < w…
Unity3D内置有GUI, 首先,使用GUI实现一个按钮,并且点击实现触发, void OnGUI() { //GUI.Button (new Rect (10,10,50,50), "nihaoa "); if(GUI.Button(new Rect (50, 50, 50, 50),"Button")) { Debug.Log("wo shi yi ge an niu"); } } 这里屏幕上会创建一个按钮,点击按钮,会出现下面那句话: 文…
unity3d里面,也是包含window窗体的,下面看一下GUI.Window方法的详情 下面我们用代码实现一个通过开关显示窗体的隐藏和显示的功能,代码如下: public class windowsscript : MonoBehaviour { bool windowshow=true; Rect windowrect=,,,); void OnGUI() { //定义一个toggle控制窗体的显示和隐藏 windowshow=GUI.Toggle(,,,),windowshow ,"是否显…
邻近年底,心也有些散乱,加上工作忙了一阵,在达内培训的课程也落下了不少.对unity3d的热度似乎也有点点下降.痛定思痛,又在淘宝上买了写蛮牛网的视频.总之不管是用任何手段都要逼着自己不要浪费了培训的那些钱.言归正传,现在开启GUI篇章. GUI这东西在我脑子里,自动归结为.net的用户交互控件,实际上应该也就是这个样子,类似于button,lable,textbox....的这些东西在GUI里面都有. 这一节讲一些简单的GUI. 先来看效果图: 1,红框部分,button按钮的text值随着在…
var Mid : Texture2D; var mouse : Texture2D; //鼠标图片 var mousePs = Vector2.zero; //鼠标的位置 private var angle : float; function Update () { mousePs = Input.mousePosition;//获取鼠标位置 angle = 180 - Mathf.Atan2(mousePs.x - 250, Screen.height -mousePs.y - 250) *…
GUI还可以定义一个窗口,在窗口里面进行控件的添加: using UnityEngine; using System.Collections; public class getbutton : MonoBehaviour { private Rect windowRect; void Start () { windowRect = new Rect(20, 20, 200, 200); } // Update is called once per frame void Update () { }…
GUI中可以使用一些默认的组件,里面的最后一个参数一般情况下,不设置就是默认的 ,当然也可以进行手动的指定,比如: GUI.Button(new Rect(0,0,100,100),"开始游戏","button"); 同样是实现一个按钮,同过最后一个参数进行定义. 当然你要在定义按钮的时候使用别的风格也是可以的,如: GUI.Button(new Rect(0,0,100,100),"开始游戏","toggle"); 定义了一…
控件组可以看成一个大的容器,控件组里面的控件,相对位置已该控件组为基准,而不再已屏幕左上角为基准. 下面来看一下代码实例及其效果截图: public class GUI2 : MonoBehaviour { int toolbarInt=0;//代表默认第n-1个按钮是激活的 string[] toolbarstring={"工具","窗体","帮助"};//按钮名称个数和集合 int selectgrid=0; string[] selectg…
复合控件极其使用,toolbar,selectgrid 先看效果图: toolbar可以看作是一个button按钮的集合,一次只能点击一个按钮, selectgrid又可以堪称是一个toolbar的集合. 代码如下: using UnityEngine; using System.Collections; public class GUI2 : MonoBehaviour { int toolbarInt=0;//代表默认第n-1个按钮是激活的 string[] toolbarstring={"…
float sourceWidth = 1024f; float sourceHeight = 768f; float m_fScaleWidth; float m_fScaleHeight; void OnGUI() { m_fScaleWidth = Screen.width / sourceWidth; m_fScaleHeight = Screen.height / sourceHeight; GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0)…