private void OnEnable()
        {
#if URP
            PipelineUtilities.RefreshRendererList();

            renderer = (PlanarReflectionRenderer)target;

            cullingMask     = serializedObject.FindProperty("cullingMask");
            rendererIndex   = serializedObject.FindProperty("rendererIndex");
            offset          = serializedObject.FindProperty("offset");
            includeSkybox   = serializedObject.FindProperty("includeSkybox");
            renderShadows   = serializedObject.FindProperty("renderShadows");
            renderRange     = serializedObject.FindProperty("renderRange");
            renderScale     = serializedObject.FindProperty("renderScale");
            maximumLODLevel = serializedObject.FindProperty("maximumLODLevel");
            waterObjects    = serializedObject.FindProperty("waterObjects");

            if (renderer.waterObjects.Count == 0 && WaterObject.Instances.Count == 1)
            {
                renderer.waterObjects.Add(WaterObject.Instances[0]);
                renderer.RecalculateBounds();
                renderer.EnableMaterialReflectionSampling();

                EditorUtility.SetDirty(target);
                serializedObject.ApplyModifiedPropertiesWithoutUndo();
            }

            ValidateWaterObjectLayer();

            curBounds = renderer.CalculateBounds();
#endif
        }
Ejemplo n.º 2
0
        private static void CreatePlanarReflections()
        {
            GameObject obj = new GameObject("Planar Reflections Renderer", typeof(PlanarReflectionRenderer));

            Undo.RegisterCreatedObjectUndo(obj, "Created PlanarReflectionRenderer");
            PlanarReflectionRenderer r = obj.GetComponent <PlanarReflectionRenderer>();

            r.ApplyToAllWaterInstances();

            Selection.activeObject = obj;

            if (Application.isPlaying == false)
            {
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }
        }