I put two Pro water objects (with refraction) into my scene. Because I noted that the Water script is running constantly, sucking CPU even when you’re far away from it, I use a collider to enable both the water script and the water renderer only when the player is within sight of the water object.
Here’s my collider script:
private var theRenderer : Renderer;
private var water : Water;
// most important to turn off the water script when not in the area since it chews up CPU when active
function Start ()
{
theRenderer = gameObject.GetComponent(Renderer);
water = gameObject.GetComponent(Water);
theRenderer.enabled = false;
water.enabled = false;
}
function OnTriggerEnter( coll : Collider )
{
theRenderer.enabled = true;
water.enabled = true;
}
function OnTriggerExit( coll : Collider )
{
theRenderer.enabled = false;
water.enabled = false;
}
But now it appears that enabling and disabling the Water script and renderer eats RAM – it seems to add about 15-20MB of memory each time I enter and leave the water collider. Unlike when other objects are instantiated and destroyed, this added memory is never recovered, so the RAM of the player just climbs and climbs.
I observe this with an OSX standalone via Activity Monitor.
Obviously this is bad news. Any ideas?