public void Init() { SetWaves(); GenerateColorRamp(); if (bakedDepthTex) { Shader.SetGlobalTexture(WaterDepthMap, bakedDepthTex); } if (!gameObject.TryGetComponent(out _planarReflections)) { _planarReflections = gameObject.AddComponent <PlanarReflections>(); } _planarReflections.hideFlags = HideFlags.HideAndDontSave | HideFlags.HideInInspector; _planarReflections.m_settings = settingsData.planarSettings; _planarReflections.enabled = settingsData.refType == ReflectionType.PlanarReflection; if (resources == null) { resources = Resources.Load("WaterResources") as WaterResources; } if (Application.platform != RuntimePlatform.WebGLPlayer) // TODO - bug with Opengl depth { CaptureDepthMap(); } }
// 初始化 public void Init() { // 根据配置设置波相关参数,并传递给Shader。根据渲染类型,开启或关闭相关参数 SetWaves(); // 生成Water的颜色贴图 GenerateColorRamp(); if (bakedDepthTex) { Shader.SetGlobalTexture(WaterDepthMap, bakedDepthTex); } if (!gameObject.TryGetComponent(out _planarReflections)) { _planarReflections = gameObject.AddComponent <PlanarReflections>(); } _planarReflections.hideFlags = HideFlags.HideAndDontSave | HideFlags.HideInInspector; _planarReflections.m_settings = settingsData.planarSettings; _planarReflections.enabled = settingsData.refType == ReflectionType.PlanarReflection; if (resources == null) { resources = Resources.Load("WaterResources") as WaterResources; } Invoke(nameof(CaptureDepthMap), 1.0f); }
private void Awake() { _material = GetComponent <Renderer>().material; _reflection = GetComponent <PlanarReflections>(); }