- 最后登录
- 2019-12-2
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 34660
- 纳金币
- 38268
- 精华
- 111
|
代码如下:- Public GameObject go;//要变换的对象
- Float D2; //系数
-
- Void Start()
- {
- D2=Vector3.Distance(go.transform.render.bounds.center,go.transform.renderer.bounds.max);
- }
-
- Void Update()
- {
- If (Input.GetMouseButtonDown(0))
- {
- Ray ray=Camera.main.ScreenPointToRay(Input.mousePosition);
- RaycastHit hit;
- If(Physics.Raycast(ray,out hit))
- {
- Float D1=Vector3.Distance(hit.transform.render.bounds.center,hit.transform.renderer.bounds.max);
- Float f=D1/D2;
- Go.transform.localScale=new Vector3(f+0.2f,f+0.2f,f+0.2f);
- Go.transform.position=hit.transform.position;
- }
- }
- }
复制代码 |
|