gutterball-3/Gutterball 3/Assets/Standard Assets/Water (Pro Only)/Water4/Sources/Scripts/WaterBase.cs
SkunkStudios 71779ef7ac New Version 1.6
New 125 balls & powerups.
Improved graphics.
2025-05-07 06:18:40 +07:00

51 lines
No EOL
1.2 KiB
C#

using UnityEngine;
public enum WaterQuality {
High = 2,
Medium = 1,
Low = 0,
}
[ExecuteInEditMode]
public class WaterBase : MonoBehaviour
{
public Material sharedMaterial;
public WaterQuality waterQuality = WaterQuality.High;
public bool edgeBlend = true;
public void UpdateShader()
{
if(waterQuality > WaterQuality.Medium)
sharedMaterial.shader.maximumLOD = 501;
else if(waterQuality> WaterQuality.Low)
sharedMaterial.shader.maximumLOD = 301;
else
sharedMaterial.shader.maximumLOD = 201;
if(edgeBlend)
{
Shader.EnableKeyword("WATER_EDGEBLEND_ON");
Shader.DisableKeyword("WATER_EDGEBLEND_OFF");
// just to make sure (some peeps might forget to add a water tile to the patches)
if (Camera.main)
Camera.main.depthTextureMode |= DepthTextureMode.Depth;
}
else
{
Shader.EnableKeyword("WATER_EDGEBLEND_OFF");
Shader.DisableKeyword("WATER_EDGEBLEND_ON");
}
}
public void WaterTileBeingRendered (Transform tr, Camera currentCam)
{
if (currentCam && edgeBlend)
currentCam.depthTextureMode |= DepthTextureMode.Depth;
}
public void Update ()
{
if(sharedMaterial)
UpdateShader();
}
}