public static void DestroyInstance() { if (_this != null) { _this.Release(); DestroyImmediate(_this.gameObject); _this = null; } }
public override void ApplyAtSceneLoad() { //Global Character light UnityEngine.RenderSettings.ambientLight = GlobalLightAmbient; SetWaterRenderTranscy(WaterTranscy); //Global Character light Shader.SetGlobalColor("_EBGCharLightDiffuseColor0", GlobalLightDiffuse); Shader.SetGlobalColor("_EBGCharLightDiffuseColor1", GlobalLightDiffuse1 * 2.0f); Shader.SetGlobalColor("_EBGCharLightSpecularColor0", GlobalLightSpecular); Shader.SetGlobalColor("_EBGCharLightScale", GlobalCharColorScale); Vector3 charLightDirection = Quaternion.Euler(GlobalLightRotation) * Vector3.forward; Vector3 charLightDirection1 = Quaternion.Euler(GlobalLightRotation1) * Vector3.forward; Shader.SetGlobalVector("_EBGCharLightDirection0", charLightDirection.normalized); Shader.SetGlobalVector("_EBGCharDirectionToLight0", Vector3.zero - charLightDirection.normalized); Shader.SetGlobalVector("_EBGCharLightDirection1", charLightDirection1.normalized); Shader.SetGlobalVector("_EBGCharDirectionToLight1", Vector3.zero - charLightDirection1.normalized); Shader.SetGlobalFloat("_EBGCharLightProbeScale", LightProbeScale); Shader.SetGlobalFloat("_EBGCharOutlineScale", CharactorOutlineScale * GlobalCharacterOutlineScale); //Global Environment light Shader.SetGlobalColor("_EBGEnvLightDiffuseColor0", EnvGlobalLightDiffuse); Shader.SetGlobalColor("_EBGEnvLightSpecularColor0", EnvGlobalLightSpecular); Shader.SetGlobalColor("_EBGEnvLightColorScale", EnvGlobalLightScale); Vector3 envLightDirection = Quaternion.Euler(EnvGlobalLightRotation) * Vector3.forward; Shader.SetGlobalVector("_EBGEnvLightDirection0", envLightDirection.normalized); Shader.SetGlobalVector("_EBGEnvDirectionToLight0", Vector3.zero - envLightDirection.normalized); Shader.SetGlobalFloat("_EBGEnvScale", EnvGlobalScale); Shader.SetGlobalColor("_EBGTint", EnvGlobalSkyBoxColor); Shader.SetGlobalColor("_EBGGlassColor", EnvGlobalGlassColor); Shader.SetGlobalColor("_EBGTColor", EnvGlobalTColor); //Reflections if (EnvironmentCubemap != null) { Shader.SetGlobalTexture("_EBGCubemap", EnvironmentCubemap); } if (EnvironmentBlurryCubemap != null) { Shader.SetGlobalTexture("_EBGCubemapBlurry", EnvironmentBlurryCubemap); } //Fog Shader.SetGlobalColor("_EBGFogColor", FogColor); Vector4 FogParams; FogParams.x = FogDistStart; FogParams.y = 1.0f / (FogDistEnd - FogDistStart); FogParams.z = FogHeightEnd; FogParams.w = 1.0f / (FogHeightEnd - FogHeightStart); Shader.SetGlobalVector("_EBGFogParams", FogParams); //Planar if (PlanarReflectionManager.Initilized()) { PlanarReflectionManager.Instance.SetPlanarReflectionRamp(PlanarReflectionRamp); PlanarReflectionManager.Instance.SetBackgroundColor(PlanarReflectionCameraClearColor); PlanarReflectionManager.Instance.SetClearMode(PlanarReflectionClearMode); } //DynamicPointLight if (!Application.isPlaying && !forceUpdate) { Shader.SetGlobalMatrix("_EBGPointLightColor", Matrix4x4.zero); Shader.SetGlobalMatrix("_EBGPointLightPosition", Matrix4x4.zero); Shader.SetGlobalVector("_EBGPointLightMultiplier", Vector4.zero); Shader.SetGlobalVector("EBGPointLightIntensity", Vector4.one); } if ((Application.isPlaying || forceUpdate) && PostFXManager.Instance != null) { var postfx = PostFXManager.Instance; #if EBG_POSTFX_VIGNETTE2 postfx.SetVignette2(PostFXVignette2Mask, PostFXVignette2MaskColor, PostFXVignette2Color, PostFXVignette2Intensity, PostFXVignette2DarkIntensity); #endif #if EBG_POSTFX_COLOR_GRADE postfx.SetColorGradeTexture(PostFXColourGradeTexture); #endif } }