上海苏宁宝丽嘉酒店,2020.11.17 15:30改为单机版本,以后合成单机版本可以以此版本为模板
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB

4 years ago
using UnityEngine;
public class ScaleControl : MonoBehaviour
{
bool flag;
private Ray ray;
private RaycastHit hit;
public float speed = 5f;
void Update()
{
//左击取消
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, Mathf.Infinity) && Input.GetMouseButtonDown(0))
{
if (hit.transform.name == this.name)
return;
flag = false;
}
if (flag)
{
if (Input.GetKey(KeyCode.Equals) && transform.localScale.x < 10f)
{
transform.localScale = new Vector3(transform.localScale.x + Time.deltaTime * speed, transform.localScale.y, transform.localScale.z + Time.deltaTime * speed);
}
if (Input.GetKey(KeyCode.Minus))
{
if (transform.localScale.x > 1f)
{
transform.localScale = new Vector3(transform.localScale.x - Time.deltaTime * speed, transform.localScale.y, transform.localScale.z - Time.deltaTime * speed);
}
}
}
}
void OnMouseDown()
{
flag = true;
}
}