using UnityEngine;
using System.Collections;
public class winTest : MonoBehaviour
{
// Use this for initialization
private Rect rect1 = new Rect(30,30,150,150);
private Rect rect2 = new Rect(30,200,150,150);
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
void OnGUI()
{
}
void onWindowOne(int winId)
{
GUI.Label (new Rect (10, 10, 140, 30), "当前窗口id是" + winId);
if (GUI.Button (new Rect (10, 30, 80, 30), "按钮1"))
{
Debug.Log ("当前窗口id"+winId);
}
}
void onWindowTwo(int winId)
GUI.Label (new Rect (10, 10, 140, 30), "当前窗口id是" + winId);
if (GUI.Button (new Rect (10, 30, 80, 30), "按钮2"))
{
Debug.Log ("当前窗口id"+winId);
}
}
}
using System.Collections;
public class winTest : MonoBehaviour
{
// Use this for initialization
private Rect rect1 = new Rect(30,30,150,150);
private Rect rect2 = new Rect(30,200,150,150);
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
void OnGUI()
{
GUI.Window (0, rect1, onWindowOne,"窗口1");
//要拖动窗口 这边要有返回值设置
rect2 = GUI.Window(1,rect2,onWindowTwo,"窗口2");}
void onWindowOne(int winId)
{
GUI.Label (new Rect (10, 10, 140, 30), "当前窗口id是" + winId);
if (GUI.Button (new Rect (10, 30, 80, 30), "按钮1"))
{
Debug.Log ("当前窗口id"+winId);
}
}
void onWindowTwo(int winId)
{
//要拖动窗口 需要调用 DragWindow
GUI.Label (new Rect (10, 10, 140, 30), "当前窗口id是" + winId);
if (GUI.Button (new Rect (10, 30, 80, 30), "按钮2"))
{
Debug.Log ("当前窗口id"+winId);
}
}
}
本文介绍了如何使用Unity引擎创建两个可拖动窗口,并实现了简单的窗口交互功能,包括窗口ID显示和按钮点击日志输出。
1246

被折叠的 条评论
为什么被折叠?



