Ejemplo n.º 1
0
 private void CreateInteractionRayObject()
 {
     if (GameObject.Find(UseThisAs.ToString()) != null)
     {
         Debug.LogError(UseThisAs.ToString() + " is set by multiple gaze sources in the scene");
     }
     else
     {
         GameObject newObj = new GameObject(UseThisAs.ToString());
         //Add Components
         newObj.AddComponent <InteractionRay> ();
     }
     original_UseAs = UseThisAs;
 }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        GameObject rayObj = GameObject.Find(RelativeTo.ToString());

        if (rayObj != null)
        {
            CurrentDistIs = Vector3.Angle(rayObj.GetComponent <InteractionRay>()._ray.direction, this.transform.position - rayObj.GetComponent <InteractionRay>()._ray.origin);

            Color color        = GetComponent <Renderer> ().material.color;
            float dist_clamped = Mathf.Clamp(CurrentDistIs, DistCutoffClose, DistCutoffFar);

            color.a = ((AlphaAtFar - AlphaAtClose) / (DistCutoffFar - DistCutoffClose)) * (dist_clamped - DistCutoffFar) + AlphaAtFar;


            this.GetComponentInParent <MeshRenderer> ().material.SetColor("_Color", color);
        }
    }