57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
using UnityEngine;
|
|
|
|
namespace AQUAS
|
|
{
|
|
[AddComponentMenu("AQUAS/Essentials/Ripple Effect")]
|
|
public class AQUAS_RippleManager : MonoBehaviour
|
|
{
|
|
[Range(0f, 4f)]
|
|
public int numberOfObjects;
|
|
|
|
[Space(10f)]
|
|
[TextArea(1, 3)]
|
|
public string objectsInfo = "Array of objects to produce ripples (max. 4). Changing the number of objects will clear the array!";
|
|
|
|
[Space(10f)]
|
|
public GameObject[] objects;
|
|
|
|
[Space(10f)]
|
|
[Header("Waterplane to apply ripples to.")]
|
|
[Space(10f)]
|
|
public GameObject waterplane;
|
|
|
|
private void OnValidate()
|
|
{
|
|
objectsInfo = "Array of objects to produce ripples (max. 4). Changing the number of objects will clear the array!";
|
|
if (objects.Length != numberOfObjects)
|
|
{
|
|
objects = new GameObject[numberOfObjects];
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
for (int i = 0; i < objects.Length; i++)
|
|
{
|
|
if (objects[i] == null)
|
|
{
|
|
Debug.LogWarning("Gameobject in array is null. Skipping...");
|
|
continue;
|
|
}
|
|
if (objects[i].GetComponent<MeshFilter>() == null)
|
|
{
|
|
Debug.LogWarning("Object " + objects[i].name + " does not have a Mesh Filter component. Skipping...");
|
|
continue;
|
|
}
|
|
GameObject obj = Object.Instantiate(Resources.Load("RippleRecorder", typeof(GameObject))) as GameObject;
|
|
obj.name = "RippleRecorder" + i;
|
|
AQUAS_RippleController component = obj.GetComponent<AQUAS_RippleController>();
|
|
component.body = objects[i];
|
|
component.waterPlane = waterplane;
|
|
component.index = i;
|
|
obj.GetComponent<Camera>().depth = -1000 - i;
|
|
}
|
|
}
|
|
}
|
|
}
|