UnityMol  0.9.6-875
UnityMol viewer / In developement
SelectAtomFocus.cs
Go to the documentation of this file.
1 
66 using UnityEngine;
67 using System.Collections;
68 using UI;
69 using Molecule.Model;
71 
72 
73 public class SelectAtomFocus : MonoBehaviour {
74  private GameObject myObj;
75  public static Transform selected = null;
76  private float distance;
77  private Camera mainCamera = null;
78 
79 
80  void Update ()
81  {
82  if(mainCamera == null)
83  mainCamera = Camera.main;
84  if (enabled && Input.GetButtonDown ("Fire1"))
85  {
86  Ray sRay= mainCamera.ScreenPointToRay (Input.mousePosition);
87  RaycastHit sHit;
88  if (Physics.Raycast(sRay, out sHit))
89  {
90  distance = sHit.distance;
91  myObj = sHit.collider.gameObject;
92  // if(myObj.GetComponent<BallUpdate>() == null)
93  // return;
94  // else
95  // {
96  Debug.Log(myObj.ToString());
97  //mainCamera.GetComponent<DepthOfField>().
98  //mainCamera.GetComponent<DepthOfField>().objectFocus = myObj.transform;
99  //mainCamera.GetComponent<DepthOfField>().focalLength = distance;
100 // mainCamera.GetComponent<DepthOfField>().FocalDistance01 = distance;
101  Debug.Log(myObj.transform.position.ToString());
102  mainCamera.GetComponent<DepthOfField>().focalTransform = myObj.transform;
103  Debug.Log(mainCamera.GetComponent<DepthOfField>().focalTransform.position.ToString());
104  mainCamera.GetComponent<DepthOfField>().focalLength = distance;
105  Debug.Log("Refocusing DOF effect with distance :");
106  Debug.Log(distance.ToString());
107  // }
108  }
109  }
110  }
111 }
static Transform selected
GameObject myObj
Definition: GUIDisplay.cs:66