mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
Fix PreRender
This commit is contained in:
parent
f789182d4f
commit
2b4f306040
4 changed files with 13 additions and 13 deletions
|
@ -59,7 +59,7 @@ public class BlackoutController : MonoBehaviour
|
|||
Sleeping,
|
||||
}
|
||||
|
||||
private GameObject activeModeCam;
|
||||
private Camera activeModeCam;
|
||||
private Quaternion oldHeadRotation = Quaternion.identity;
|
||||
private float angularMovement = 0f;
|
||||
private float curTime = 0f;
|
||||
|
@ -114,6 +114,10 @@ public class BlackoutController : MonoBehaviour
|
|||
blackoutGO.name = "BlackoutInstance";
|
||||
blackoutAnimator = blackoutGO.GetComponent<Animator>();
|
||||
SetupBlackoutInstance();
|
||||
|
||||
//we dont want this to ever disable (unless in awake state maybe?
|
||||
Camera.onPreRender += OnPreRender;
|
||||
Camera.onPostRender += OnPostRender;
|
||||
}
|
||||
|
||||
//Automatic State Change
|
||||
|
@ -151,20 +155,16 @@ public class BlackoutController : MonoBehaviour
|
|||
{
|
||||
curTime = Time.time;
|
||||
lastAwakeTime = curTime;
|
||||
Camera.onPreRender += OnPreRender;
|
||||
Camera.onPostRender += OnPostRender;
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
ChangeBlackoutState(BlackoutState.Awake);
|
||||
Camera.onPreRender -= OnPreRender;
|
||||
Camera.onPostRender -= OnPostRender;
|
||||
}
|
||||
|
||||
void OnPreRender(Camera cam)
|
||||
{
|
||||
if (cam != activeModeCam.GetComponent<Camera>()) return;
|
||||
if (cam == activeModeCam) return;
|
||||
blackoutAnimator.transform.localScale = Vector3.zero;
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ public class BlackoutController : MonoBehaviour
|
|||
|
||||
public void SetupBlackoutInstance()
|
||||
{
|
||||
activeModeCam = PlayerSetup.Instance.GetActiveCamera();
|
||||
activeModeCam = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>();
|
||||
blackoutAnimator.transform.parent = activeModeCam.transform;
|
||||
blackoutAnimator.transform.localPosition = Vector3.zero;
|
||||
blackoutAnimator.transform.localRotation = Quaternion.identity;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue