多米诺 发表于 2012-6-15 15:57

Unity3D Drag.DragWindow()拖动效果实现


using UnityEngine;
using System.Collections;

public class GUI_try10 : MonoBehaviour
{

      // Use this for initialization

    public Rect window01 = new Rect(20,20,150,100);   //定义窗体初始状态:X、Y位置及长宽

   

      void Start () {
      
      }
      
      // Update is called once per frame
      void Update () {
      
      }

    void OnGUI ()
   {
         window01 = GUI.Window(0,window01,DoMyWindow,"My Windows");    //定义为window窗体,”My Windows”为窗体标题
   }
    void DoMyWindow(int windowID)
    {

      //GUI.DragWindow(new Rect(0,0,10000,20));
      GUI.DragWindow(new Rect(0, 0, 150,20));             //使用DragWindow设置window窗体为可被鼠标拖动移动,并设置window窗体的鼠标响应范围,四个值分别是窗体中响应区的开始X、Y位置(窗体中的局部坐标),响应区的长宽。
      

    }
}
新手必备回帖有奖励{:soso__17542699376449522055_4:}

cclove 发表于 2012-12-29 08:13

哈哈 回帖。

koei1111 发表于 2013-1-13 12:49

大大分享好多帖 受益良多 謝謝!!

Joy 发表于 2013-3-15 13:43

不错,借鉴一下……

oscarlew 发表于 2013-4-12 20:53

收藏 了   谢谢楼zhu

ymrong 发表于 2013-6-1 21:31

谢谢{:5_427:}{:5_427:}

bzw 发表于 2013-7-12 15:26

{:5_397:}来那奖励啊

丨夜愿 发表于 2014-2-21 15:54

回帖是好习惯

chenjack2000 发表于 2017-4-27 16:57

很不错

佳Ivan 发表于 2017-4-27 17:32

楼主是超人
页: [1]
查看完整版本: Unity3D Drag.DragWindow()拖动效果实现