Exemplo n.º 1
0
    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;
        }
    }
Exemplo n.º 2
0
	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;
		}
	}
Exemplo n.º 3
0
 void OnMouseUp()
 {
     this.dPadState = DirPadState.Center;
 }
Exemplo n.º 4
0
	void OnMouseUp()
	{
		this.dPadState = DirPadState.Center;
	}