Beispiel #1
0
 void OnGUI()
 {
     if (touchLookView == TouchLookView.TlVw_Normal)
     {
         if (GUI.RepeatButton(new Rect(posLeft, posTop, guiboxWidth, guiboxHeight), "<<"))
         {
             touchLookCmd = TouchLookCommand.TlCmd_TurnLeft;
         }
         if (GUI.RepeatButton(new Rect(Screen.width - posLeft - guiboxWidth, posTop, guiboxWidth, guiboxHeight), ">>"))
         {
             touchLookCmd = TouchLookCommand.TlCmd_TurnRight;
         }
         if (GUI.Button(new Rect(Screen.width / 2 - guiboxWidth / 2, posTop, guiboxWidth, guiboxHeight), "Top View"))
         {
             touchLookView = TouchLookView.TlVw_Top;
             changeView    = true;
         }
     }
     else if (touchLookView == TouchLookView.TlVw_Top)
     {
         if (GUI.Button(new Rect(Screen.width / 2 - guiboxWidth / 2, posTop, guiboxWidth, guiboxHeight), "Normal View"))
         {
             touchLookView = TouchLookView.TlVw_Normal;
             changeView    = true;
         }
         if (GUI.Button(new Rect(posLeft, posTop, guiboxWidth, guiboxHeight), "Width"))
         {
             roomScaleWidth += roomWidthChange;
             if (roomScaleWidth > 2.0F)
             {
                 roomWidthChange = -1 * roomWidthChange;
                 roomScaleWidth  = 2.0F;
             }
             if (roomScaleWidth < 1.0F)
             {
                 roomWidthChange = -1 * roomWidthChange;
                 roomScaleWidth  = 1.0F;
             }
             touchLookCmd = TouchLookCommand.TlCmd_ChangeRoomScale;
         }
         if (GUI.Button(new Rect(Screen.width - posLeft - guiboxWidth, posTop, guiboxWidth, guiboxHeight), "Length"))
         {
             roomScaleLength += roomLengthChange;
             if (roomScaleLength > 2.0F)
             {
                 roomLengthChange = -1 * roomLengthChange;
                 roomScaleLength  = 2.0F;
             }
             if (roomScaleLength < 1.0F)
             {
                 roomLengthChange = -1 * roomLengthChange;
                 roomScaleLength  = 1.0F;
             }
             touchLookCmd = TouchLookCommand.TlCmd_ChangeRoomScale;
         }
     }
 }
Beispiel #2
0
    void Update()
    {
        //if (!Input.GetMouseButton (0))
        //	return;
        //transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);

        if (touchLookCmd != TouchLookCommand.TlCmd_None && !changeView)
        {
            switch (touchLookCmd)
            {
            case TouchLookCommand.TlCmd_TurnLeft:
                // Turn Left
                transform.Rotate(0, -sensitivityX, 0);
                break;

            case TouchLookCommand.TlCmd_TurnRight:
                // Turn Right
                transform.Rotate(0, sensitivityX, 0);
                break;

            case TouchLookCommand.TlCmd_ChangeRoomScale:
                GameObject floor = GameObject.Find("Floor");
                if (floor)
                {
                    Vector3 scale = floor.transform.localScale;
                    scale.x = roomScale * roomScaleWidth;
                    scale.z = roomScale * roomScaleLength;
                    floor.transform.localScale = scale;
                    changeCurrentView(touchLookView, true);
                }
                break;
            }
            touchLookCmd = TouchLookCommand.TlCmd_None;
        }
        if (changeView)
        {
            changeCurrentView(touchLookView, false);
            changeView = false;
        }
    }