How do I enable an effect on a object?

I have a game object with a halo effect, and I basically want to enable it when the camera is looking at it.

I tried this and numerous variations:

public void Update () {
    RaycastHit hit;
    if (Physics.Raycast(transform.position, transform.forward, out hit, 10)) {
		hit.collider.gameObject.GetComponent<Halo>().enabled = true;
	}
}

But it was to no avail. Any ideas on how to do it?

Not sure if it was fixed recently but I’m pretty sure that you cannot manipulate halo’s in code… try using a particle effect instead.