Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- public class Touch : MonoBehaviour
- {
- public Vector3 min = new Vector3(1, 1, 1);
- public Vector3 max = new Vector3(2, 2, 2);
- public float speed = 10;
- void OnMouseDown()
- {
- transform.localScale = max;
- }
- private void OnMouseUp()
- {
- transform.localScale = min;
- }
- private void Update()
- {
- if (Input.GetKey(KeyCode.LeftArrow))
- {
- Vector3 position = this.transform.position;
- position.x-=speed;
- this.transform.position = position;
- }
- if (Input.GetKey(KeyCode.RightArrow))
- {
- Vector3 position = this.transform.position;
- position.x+=speed;
- this.transform.position = position;
- }
- if (Input.GetKey(KeyCode.UpArrow))
- {
- Vector3 position = this.transform.position;
- position.y += speed;
- this.transform.position = position;
- }
- if (Input.GetKey(KeyCode.DownArrow))
- {
- Vector3 position = this.transform.position;
- position.y -= speed;
- this.transform.position = position;
- }
- if (Input.GetKey(KeyCode.Q))
- {
- Vector3 position = this.transform.position;
- position.z += speed;
- this.transform.position = position;
- }
- if (Input.GetKey(KeyCode.Z))
- {
- Vector3 position = this.transform.position;
- position.z -= speed;
- this.transform.position = position;
- }
- if (Input.GetKey(KeyCode.R))
- {
- this.transform.Rotate(new Vector3(0, speed, 0));
- }
- if (Input.GetKey(KeyCode.Z))
- {
- Vector3 position = this.transform.position;
- position.z -= speed;
- this.transform.position = position;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement