Hi
Just trying to load a texture from resources folder when a object becomes visible to the camera but not working as expected.
No matter where i look Even if i don,t have a camera in scene! it immediately loads the textures when the code is put in OnBecameVisible and it never load the textures if i place the code in OnBecomeInvisible.
i tried a debug log OnBecameVisible and it immediately prints just once then never again.
Should this not be constantly switching from OnBecomeVisible to OnBecomeInvisible? as the object enters and exits the viewing area?
I disabled shodowws on the directional light and also put shadows off on the object and it continues to fail what am i doing wrong this is retarded.
using UnityEngine;
using System.Collections;
public class isvisible : MonoBehaviour {
void OnBecameInvisible() {
}
void OnBecameVisible() {
Renderer rend = GetComponent<Renderer>();
rend.material.mainTexture = Resources.Load("Texture") as Texture;
}
}