diff options
author | chai <chaifix@163.com> | 2021-09-17 20:09:19 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-09-17 20:09:19 +0800 |
commit | 234c25bc8761a4d41bc5b4aa362449cf3e806e13 (patch) | |
tree | 69cc0b7002ac8018af1806de366526dfc089d49e /Assets/Scripts/Unit/Effect/UnitCamera.cs | |
parent | ea4624fbef6e9d8f58da12be363807eb19a37b53 (diff) |
*unit image effect
Diffstat (limited to 'Assets/Scripts/Unit/Effect/UnitCamera.cs')
-rw-r--r-- | Assets/Scripts/Unit/Effect/UnitCamera.cs | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/Assets/Scripts/Unit/Effect/UnitCamera.cs b/Assets/Scripts/Unit/Effect/UnitCamera.cs index 90d78730..abb13a00 100644 --- a/Assets/Scripts/Unit/Effect/UnitCamera.cs +++ b/Assets/Scripts/Unit/Effect/UnitCamera.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using UnityEngine; -// 专门用来渲染player character的相机,用来做特效 +// 专门用来渲染character的相机,用来做特效 [RequireComponent(typeof(Camera))] public class UnitCamera : SingletonMB<UnitCamera> { @@ -13,12 +13,22 @@ public class UnitCamera : SingletonMB<UnitCamera> private void OnEnable() { m_Camera = GetComponent<Camera>(); - } - - private void OnPreRender() + 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; @@ -29,6 +39,17 @@ public class UnitCamera : SingletonMB<UnitCamera> 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 |