summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Unit/Effect/UnitCamera.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2022-03-10 14:07:40 +0800
committerchai <chaifix@163.com>2022-03-10 14:07:40 +0800
commit22891bf59032ba88262824255a706d652031384b (patch)
tree7595439ba9966c9402d37e37cee5e8cf098757d5 /Assets/Scripts/Unit/Effect/UnitCamera.cs
parent8b04ea73e540067f83870b61d89db4868fea5e8a (diff)
* move folder
Diffstat (limited to 'Assets/Scripts/Unit/Effect/UnitCamera.cs')
-rw-r--r--Assets/Scripts/Unit/Effect/UnitCamera.cs55
1 files changed, 0 insertions, 55 deletions
diff --git a/Assets/Scripts/Unit/Effect/UnitCamera.cs b/Assets/Scripts/Unit/Effect/UnitCamera.cs
deleted file mode 100644
index abb13a00..00000000
--- a/Assets/Scripts/Unit/Effect/UnitCamera.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-// 专门用来渲染character的相机,用来做特效
-[RequireComponent(typeof(Camera))]
-public class UnitCamera : SingletonMB<UnitCamera>
-{
- PCController pc { get { return UnitManager.Instance.pc; } }
-
- Camera m_Camera;
-
- private void OnEnable()
- {
- m_Camera = GetComponent<Camera>();
- m_Camera.enabled = false;
- }
-
- // 手动渲染
- public void Render()
- {
- m_Camera.Render();
- }
-
- // 这里要用OnPreCull,不能是OnPreRender,因为设置了可见性,OnPreRender是在可见性剔除之后
- void OnPreCull()
- {
- if (pc == null)
- return;
- if (pc.unitImageEffect == null || pc.unitImageEffect.effects.Count == 0)
- return;
- if (m_Camera == null)
- return;
-
- Vector3 pos = transform.position;
- transform.position = new Vector3(pc.center.x, pc.center.y, pos.z);
-
- float dz = Mathf.Abs(pos.z - pc.center.z);
- float fov = 2 * Mathf.Atan2(pc.unitDetail.snapshotBound / 2, dz) * Mathf.Rad2Deg;
-
- m_Camera.fieldOfView = fov;
-
- // 开启unit的渲染
- pc.unitRender.SetVisibilityInAllCameras(true);
- }
-
- void OnPostRender()
- {
- if (pc.unitImageEffect == null || pc.unitImageEffect.effects.Count == 0)
- return;
-
- pc.unitRender.SetVisibilityInAllCameras(false);
- }
-
-} \ No newline at end of file