// Start is called before the first frame update void Start() { socket = new VirtualCVWebSocket(); socket.Initialize(); left = this.gameObject.transform.GetChild(0).gameObject; leftCamera = left.GetComponent <Camera>(); if (VirtualCVSettings.GetParam().useStereoCamera) { right = this.gameObject.transform.GetChild(1).gameObject; rightCamera = right.GetComponent <Camera>(); float ipd = VirtualCVSettings.GetParam().ipd; left.transform.localPosition.Set(0, -ipd / 2, 0); right.transform.localPosition.Set(0, ipd / 2, 0); } else { left.transform.localPosition.Set(0, 0, 0); } string pythonScript = VirtualCVSettings.GetParam().python_script; PythonExecutor.getInstance().ExecutePython(pythonScript); }
void OnGUI() { GUILayout.Label("Camera settings", EditorStyles.boldLabel); param.usePhysicalCamera = EditorGUILayout.Toggle("Use physical camera", param.usePhysicalCamera); param.useDepthCameara = EditorGUILayout.Toggle("Use depth camera", param.useDepthCameara); EditorGUILayout.Space(); param.textureWidth = EditorGUILayout.IntField("Texture width", param.textureWidth); param.textureHeight = EditorGUILayout.IntField("Texture height", param.textureHeight); EditorGUILayout.Space(); param.fov = EditorGUILayout.FloatField("Field of view", param.fov); param.fps = EditorGUILayout.IntField("FPS", param.fps); param.focal_length = EditorGUILayout.FloatField("Focal length", param.focal_length); EditorGUILayout.Space(); param.useStereoCamera = EditorGUILayout.Toggle("Use stereo camera", param.useStereoCamera); param.ipd = EditorGUILayout.FloatField("Interpupillary distance", param.ipd); EditorGUILayout.Space(); if (GUILayout.Button("Save settings")) { VirtualCVLog.Log("Settings saved"); VirtualCVSettings.SaveSettings(param); } if (GUILayout.Button("Apply to camera")) { ApplyCamera(); } EditorGUILayout.Space(); int selectedPythonScript = GetPythonScriptIndex(param.python_script); selectedPythonScript = EditorGUILayout.Popup("Python script", selectedPythonScript, pythonFiles); param.python_script = pythonFiles[selectedPythonScript]; if (GUILayout.Button("Launch the script")) { if (Application.isPlaying) { PythonExecutor.getInstance().ExecutePython(param.python_script); } else { VirtualCVLog.LogE("It's able to run only when Unity is playing."); } } }
/// <summary> /// Get python script names /// </summary> /// <returns>python scripts in StreamingAssets</returns> private static string[] GetPythonScripts() { string pythonFolderPath = PythonExecutor.getInstance().GetPythonFolderPath(); string[] pythonFiles = Directory.GetFiles(pythonFolderPath); List <string> pythonFileList = new List <string>(); foreach (string fileName in pythonFiles) { if (fileName.EndsWith(".py")) { string onlyFileName = Path.GetFileName(fileName); pythonFileList.Add(onlyFileName); } } return(pythonFileList.ToArray()); }