12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Room : MonoBehaviour
- {
- public float Height = 0.5f;
- public int Rounding = 1;
- public bool move = false;
- public bool BoxColliderEnabled = true;
- private Vector3 screenPoint;
- private Vector3 offset;
- private Vector3 curScreenPoint;
- private Vector3 curPosition;
- // Start is called before the first frame update
- void Start()
- {
- gameObject.GetComponent<BoxCollider>().enabled = BoxColliderEnabled;
- }
- // Update is called once per frame
- void Update()
- {
- if (gameObject.GetComponent<BoxCollider>().enabled != BoxColliderEnabled) gameObject.GetComponent<BoxCollider>().enabled = BoxColliderEnabled;
- }
- void OnMouseDown()
- {
- //Debug.Log(StagesEditorController.indexCursor);
-
- screenPoint = Camera.main.WorldToScreenPoint(gameObject.transform.position);
- offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
-
- }
- // Перемещение
- void OnMouseDrag()
- {
- curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z);
- curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset;
- var x = (float)Math.Round(curPosition.x, Rounding);
- var z = (float)Math.Round(curPosition.z, Rounding);
- //transform.position = new Vector3(x, Height, z);
- gameObject.GetComponent<BoxCollider>().size = new Vector3(x, Height, z);
- LocationController.Cube(gameObject, new Vector3(x, z, Height));
- }
- }
|