// Use this for initialization void Start() { smiInstance = SMIEyeTrackingUnity.Instance; output_ray = this.GetComponentInParent <OutputRay> (); }
// prepare everything: paths, names, ... void Start() { // write log to console Debug.Log("Create log file"); //get video_id from video player var videoPlayer = GameObject.Find("360sphere").GetComponent <UnityEngine.Video.VideoPlayer>(); video_id = videoPlayer.clip.name; video_frame_max = unchecked ((int)videoPlayer.clip.frameCount); Debug.Log("video_id is: " + video_id + "\nmax_frame_video is: " + video_frame_max); smiInstance = SMIEyeTrackingUnity.Instance; gazeVis = (GameObject)Resources.Load("SMI_GazePoint"); if (gazeVis != null) { gazeVis = Instantiate(gazeVis, Vector3.zero, Quaternion.identity) as GameObject; gazeVis.name = "SMI_GazePoint"; initialeScale = gazeVis.transform.localScale; } else { Debug.LogError("Unity Prefab missing: SMI_GazePoint"); UnityEditor.EditorApplication.isPlaying = false; } // prepare log string log_file = ""; // path saving log files string log_path = Directory.GetCurrentDirectory() + "/log_vr_eyetracking" + "/subject_" + subject_id.ToString("D2"); // path saving screenshots string screenshot_path = log_path + "/frames/" + video_id; // check path exists if (!Directory.Exists(log_path)) // create folder if it does not exist { Directory.CreateDirectory(log_path); } if (!Directory.Exists(screenshot_path)) // create folder if it does not exist { Directory.CreateDirectory(screenshot_path); } else { Debug.LogError("Directory for frames already exists! Please check subject_id or scene."); UnityEditor.EditorApplication.isPlaying = false; } log_file = log_path + "/log_vr_" + date + '_' + subject_id.ToString("D2") + "_" + video_id + ".txt"; // Debug.Log(log_file); // Debug.Log("Opening log_file..."); sw = new StreamWriter(log_file);//, true); // append = true, don't overwrtie log file log_header = "subject_id" + "\t" + "date" + "\t" + "video_id" + "\t" + "frame_video" + "\t" + "screenPos.x" + "\t" + "screenPos.y" + "\t" + "camAngle.x" + "\t" + "camAngle.y" + "\t" + "camAngle.z"; // Debug.Log("Writing header..."); sw.WriteLine(log_header); }