using UnityEngine;
using System.Collections;
public class winTest : MonoBehaviour
{
// Use this for initialization
private Rect rect1 = new Rect(30,30,150,150);
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
void OnGUI()
{
GUI.skin = mySkin;
}
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.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);
}
}
}
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);
//asset中创建一个GUISkin
public GUISkin mySkin;void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
void OnGUI()
{
GUI.skin = mySkin;
GUI.Window (0, rect1, onWindowOne,"窗口1");
// 恢复Skin为缺省
GUI.skin = null;
}
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.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);
}
}
}