void OnTriggerEnter(Collider other)
    {
        AutoTransparency transparency = other.GetComponent <AutoTransparency> ();

        if (transparency != null)
        {
            Debug.Log("Fading");
            transparency.FadeToMinAlpha();
        }
    }
Exemple #2
0
    private void Raycasting()
    {
        // update every two seconds
        if (Time.time > nextUpdate)
        {
            nextUpdate = Time.time + updateInterval;

            RaycastHit[] raycastHits = Physics.RaycastAll(
                transform.position,
                cam.transform.position,
                distanceToCamera
                );

            foreach (RaycastHit hit in raycastHits)
            {
                AutoTransparency transparency = hit.transform.gameObject.GetComponent <AutoTransparency> ();
                if (transparency != null)
                {
                    transparency.FadeToMinAlpha();
                }
            }
        }
    }