DragWindow 拖动窗口

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()
{

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.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);
}
}
}

你可能感兴趣的:(DragWindow 拖动窗口)