-
-
Notifications
You must be signed in to change notification settings - Fork 470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OceanPlanarReflection does not initialize properly, when oceanrenderer is not present #576
Comments
Could you please elaborate on this - did you move all the code out of OceanPlanarReflection.Start and into OceanPlanarReflection.OnEnable? I cant get my head around why that would help, but i'm sure theres a good reason! Would a solution be to remove this code:
So that the OceanPlanarReflections does not shut itself down when theres no ocean? |
I cannot say if you solution would work. The problem is, that Start() is only called once. OnEnable() is called whenever it is enabled. So it´s the safe way. I've put all code in OnEnable() and deleted Start(). private void OnEnable() { RenderPipelineManager.beginCameraRendering += BeginCameraRendering; if (OceanRenderer.Instance == null) { enabled = false; return; } _camViewpoint = GetComponent(); if (!_camViewpoint) { Debug.LogWarning("Disabling planar reflections as no camera found on gameobject to generate reflection from.", this); enabled = false; return; } _camViewpointSkybox = _camViewpoint?.GetComponent(); // This is anyway called in OnPreRender, but was required here as there was a black reflection // for a frame without this earlier setup call. CreateWaterObjects(_camViewpoint); #if UNITY_EDITOR if (!OceanRenderer.Instance.OceanMaterial.IsKeywordEnabled("_PLANARREFLECTIONS_ON")) { Debug.LogWarning("Planar reflections are not enabled on the current ocean material and will not be visible.", this); } #endif } |
Ok. I'm guessing this still wouldn't work if it's enabled before the ocean, which seems like something we should support, I think |
Describe the bug
Problem is, when crest gets instanciated later, not during startup.
To Reproduce
disable oceanrenderer - start - enable oceanrenderer
** Solution **
move some code from Start to OnEnable
Additional context
I am using different ocean systems to be compatible on opengl <3.1 and low end devices.
The text was updated successfully, but these errors were encountered: