コード例 #1
0
ファイル: DirPad.cs プロジェクト: zzufire/unity-examples
    void OnMouseDrag()
    {
        Ray        mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(mouseRay, out hit, 1 << 8))
        {
            Debug.DrawLine(mouseRay.origin, hit.point);

            Vector3 delta = hit.point - this.transform.position;

            if (delta.x > 0.5)
            {
                this.dPadState = DirPadState.Right;
            }
            else if (delta.x < -0.5)
            {
                this.dPadState = DirPadState.Left;
            }
            else if (delta.y > 0.5)
            {
                this.dPadState = DirPadState.Up;
            }
            else if (delta.y < -0.5)
            {
                this.dPadState = DirPadState.Down;
            }
            else
            {
                this.dPadState = DirPadState.Center;
            }
        }
        else
        {
            this.dPadState = DirPadState.Center;
        }
    }
コード例 #2
0
ファイル: DirPad.cs プロジェクト: zfergus2/Unity-Examples
	void OnMouseDrag()
	{
		Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
		RaycastHit hit;
		if (Physics.Raycast (mouseRay, out hit, 1 << 8)) {
			Debug.DrawLine (mouseRay.origin, hit.point);

			Vector3 delta = hit.point - this.transform.position;

			if (delta.x > 0.5) {
				this.dPadState = DirPadState.Right;
			} else if (delta.x < -0.5) {
				this.dPadState = DirPadState.Left;
			} else if (delta.y > 0.5) {
				this.dPadState = DirPadState.Up;
			} else if (delta.y < -0.5) {
				this.dPadState = DirPadState.Down;
			} else {
				this.dPadState = DirPadState.Center;
			}
		}else {
			this.dPadState = DirPadState.Center;
		}
	}
コード例 #3
0
ファイル: DirPad.cs プロジェクト: zzufire/unity-examples
 void OnMouseUp()
 {
     this.dPadState = DirPadState.Center;
 }
コード例 #4
0
ファイル: DirPad.cs プロジェクト: zfergus2/Unity-Examples
	void OnMouseUp()
	{
		this.dPadState = DirPadState.Center;
	}