using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;


public class NeoMouse : MonoBehaviour
{
	[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
	[return: MarshalAs(UnmanagedType.Bool)]
	public static extern bool ClipCursor(ref RECT rcClip);
	[DllImport("user32.dll")]
	[return: MarshalAs(UnmanagedType.Bool)]
	public static extern bool GetClipCursor(out RECT rcClip);
	[DllImport("user32.dll")]
	static extern int GetForegroundWindow();
	[DllImport("user32.dll")]
	[return: MarshalAs(UnmanagedType.Bool)]
	static extern bool GetWindowRect(int hWnd, ref RECT lpRect);

	[StructLayout(LayoutKind.Sequential)]
	public struct RECT
	{
		public int Left;
		public int Top;
		public int Right;
		public int Bottom;
		public RECT(int left, int top, int right, int bottom)
		{
			Left = left;
			Top = top;
			Right = right;
			Bottom = bottom;
		}
	}

	RECT currentClippingRect;
	RECT originalClippingRect = new RECT();
	int hWnd = 0;

	void Start()
	{
		hWnd = GetForegroundWindow();
		GetWindowRect(hWnd, ref currentClippingRect);
		GetClipCursor(out originalClippingRect);
		ClipCursor(ref currentClippingRect);
	}

	void OnApplicationQuit()
	{
		ClipCursor(ref originalClippingRect);
	}
}


윈도우 용임. 
2011/09/19 11:45 2011/09/19 11:45
Posted by Junios

트랙백 보낼 주소 : http://junios.net/tc/trackback/289

<< PREV : [1] : ... [6] : [7] : [8] : [9] : [10] : [11] : [12] : [13] : [14] : ... [187] : NEXT >>

BLOG main image
Junios World by Junios

카테고리

전체 (187)
주저리 (60)
Tips (8)
적어놓기 (7)
Hacking (1)
Programming (110)
(1)

최근에 받은 트랙백

글 보관함

달력

«   2012/05   »
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Total : 121508
Today : 20 Yesterday : 60