Code Review

1 using System;
2 using
UnityEngine;
3
4 namespace
UnityStandardAssets.Utility
5 {
6     
public class CameraRefocus
7     {
8         
public Camera Camera;
9         
public Vector3 Lookatpoint;
10         
public Transform Parent;
11
12         
private Vector3 m_OrigCameraPos;
13         
private bool m_Refocus;
14
15
16         
public CameraRefocus(Camera camera, Transform parent, Vector3 origCameraPos)
17         {
18             m_OrigCameraPos = origCameraPos;
19             Camera = camera;
20             Parent = parent;
21         }
22
23
24         
public void ChangeCamera(Camera camera)
25         {
26             Camera = camera;
27         }
28
29
30         
public void ChangeParent(Transform parent)
31         {
32             Parent = parent;
33         }
34
35
36         
public void GetFocusPoint()
37         {
38             RaycastHit hitInfo;
39             
if (Physics.Raycast(Parent.transform.position + m_OrigCameraPos, Parent.transform.forward, out hitInfo,
40                                 
100f))
41             {
42                 Lookatpoint = hitInfo.point;
43                 m_Refocus =
true;
44                 
return;
45             }
46             m_Refocus =
false;
47         }
48
49
50         
public void SetFocusPoint()
51         {
52             
if (m_Refocus)
53             {
54                 Camera.transform.LookAt(Lookatpoint);
55             }
56         }
57     }
58 }


Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *