43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
using UnityEngine;
|
|
|
|
namespace AQUAS
|
|
{
|
|
[AddComponentMenu("AQUAS/Essentials/Depth Support")]
|
|
public class AQUAS_DepthSupport : MonoBehaviour
|
|
{
|
|
public GameObject waterPlane;
|
|
|
|
public LayerMask cullingMask = -1;
|
|
|
|
private void Start()
|
|
{
|
|
GameObject gameObject = new GameObject("Depth Cam");
|
|
gameObject.transform.SetParent(base.transform, worldPositionStays: false);
|
|
GameObject gameObject2 = new GameObject("Color Cam");
|
|
gameObject2.transform.SetParent(base.transform, worldPositionStays: false);
|
|
gameObject.hideFlags = HideFlags.HideAndDontSave;
|
|
gameObject2.hideFlags = HideFlags.HideAndDontSave;
|
|
Camera camera = gameObject.AddComponent<Camera>();
|
|
Camera camera2 = gameObject2.AddComponent<Camera>();
|
|
camera.CopyFrom(GetComponent<Camera>());
|
|
camera2.CopyFrom(GetComponent<Camera>());
|
|
camera.cullingMask = cullingMask;
|
|
camera2.cullingMask = cullingMask;
|
|
camera.cullingMask &= ~(1 << LayerMask.NameToLayer("Water"));
|
|
camera2.cullingMask &= ~(1 << LayerMask.NameToLayer("Water"));
|
|
camera.gameObject.AddComponent<AQUAS_ReflectNot>();
|
|
camera2.gameObject.AddComponent<AQUAS_ReflectNot>();
|
|
if (waterPlane == null)
|
|
{
|
|
waterPlane = GameObject.Find("Water Plane");
|
|
if (waterPlane == null)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
gameObject.AddComponent<AQUAS_RenderDepth>().plane = waterPlane;
|
|
gameObject2.AddComponent<AQUAS_RenderColor>().plane = waterPlane;
|
|
}
|
|
}
|
|
}
|