Having a bunch of gameobjects with animatios and scripts, which is better way to stop it when object are out of frustum?
One way i think is disabling gameobject when is out of frustum, but self script that check if it is out of frustum will not run more to activate when it enter on the frustum (if script are attached to the gameobject).
I’m not expert in Unity. Thanks for your help
You can use OnBecameInvisible/OnBecameVisible.
–Eric
Thanks Eric.
Yes . You named it in another post, but I’m not sure how I can use it. I mean, if I create a script called culling.cs and add it to a gameobject that has a script that moves a rope, culling.OnBecameInvisible method should stop the movement of the rope. The way I know is disabling the gameobject ; but if i disable the gameobject ( with culling.OnBecameInvisible) how can i return to enable (through culling.OnBecameVisible ) if the same gameobject that hold the script is disabled .
Idea is not process all out of frustum camera (scripts, animations…)
(Translated by google)
I do this, work for now…but for(int i=0;i<scripts.Length;i++) Debug.Log(scripts*.name); return the name of the gameobject, not the name of the script. ??*
```
*using UnityEngine;
using System.Collections;
public class Culling : MonoBehaviour {
// Use this for initialization
MonoBehaviour[] scripts;
void Start () {
scripts = this.GetComponents<MonoBehaviour>();
for(int i=0;i<scripts.Length;i++) Debug.Log(scripts[i].name);
}
void OnBecameInvisible() {
for(int i=0;i<scripts.Length;i++)
if(scripts != this)
scripts.enabled = false;
}
void OnBecameVisible() {
for(int i=0;i<scripts.Length;i++)
scripts.enabled = true;
}
}*
```