doctorbin

Touch

Apr 30th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.93 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3.  
  4. public class Touch : MonoBehaviour
  5. {
  6.  
  7.  
  8.     public Vector3 min = new Vector3(1, 1, 1);
  9.     public Vector3 max = new Vector3(2, 2, 2);
  10.     public float speed = 10;
  11.  
  12.     void OnMouseDown()
  13.     {
  14.         transform.localScale = max;
  15.     }
  16.     private void OnMouseUp()
  17.     {
  18.         transform.localScale = min;  
  19.     }
  20.  
  21.     private void Update()
  22.     {
  23.         if (Input.GetKey(KeyCode.LeftArrow))
  24.         {
  25.             Vector3 position = this.transform.position;
  26.             position.x-=speed;
  27.             this.transform.position = position;
  28.         }
  29.         if (Input.GetKey(KeyCode.RightArrow))
  30.         {
  31.             Vector3 position = this.transform.position;
  32.             position.x+=speed;
  33.             this.transform.position = position;
  34.         }
  35.         if (Input.GetKey(KeyCode.UpArrow))
  36.         {
  37.             Vector3 position = this.transform.position;
  38.             position.y += speed;
  39.             this.transform.position = position;
  40.         }
  41.         if (Input.GetKey(KeyCode.DownArrow))
  42.         {
  43.             Vector3 position = this.transform.position;
  44.             position.y -= speed;
  45.             this.transform.position = position;
  46.         }
  47.         if (Input.GetKey(KeyCode.Q))
  48.         {
  49.             Vector3 position = this.transform.position;
  50.             position.z += speed;
  51.             this.transform.position = position;
  52.         }
  53.         if (Input.GetKey(KeyCode.Z))
  54.         {
  55.             Vector3 position = this.transform.position;
  56.             position.z -= speed;
  57.             this.transform.position = position;
  58.         }
  59.  
  60.         if (Input.GetKey(KeyCode.R))
  61.         {
  62.             this.transform.Rotate(new Vector3(0, speed, 0));
  63.         }
  64.         if (Input.GetKey(KeyCode.Z))
  65.         {
  66.             Vector3 position = this.transform.position;
  67.             position.z -= speed;
  68.             this.transform.position = position;
  69.         }
  70.  
  71.     }
  72. }
Add Comment
Please, Sign In to add comment