鼠标拖动的同时绘制一块同等大小的区域:如下
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 通过鼠标框选绘制矩形区域
/// </summary>
///
public enum MouseType
{
left = 0,
right = 1,
middle = 2
}
public class DrawRectangleArea : MonoBehaviour
{
bool _canAddArea = true;
/// <summary>
/// 是否可以绘制
/// </summary>
public bool canAddArea
{
set { _canAddArea = value; }
get { return _canAddArea; }
}
bool _isDraw = false;
[SerializeField]
Transform areaCube;
Vector3 leftTopPos = Vector3.zero;
Vector3 rightBottomPos = Vector3.zero;
/// <summary>
/// 绘制区域所在的层级
/// </summary>
[SerializeField]
LayerMask maskLayer = 0;
//