/// <summary> /// Helper to get the name of a drag and dropped file /// </summary> public void DropAreaGUI() { Event evt = Event.current; ZEDSVOManager obj = (ZEDSVOManager)target; switch (evt.type) { case EventType.DragUpdated: case EventType.DragPerform: if (!drop_area.Contains(evt.mousePosition)) { return; } DragAndDrop.visualMode = DragAndDropVisualMode.Copy; if (evt.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); foreach (string dragged_object in DragAndDrop.paths) { videoFile.stringValue = dragged_object; } } break; } }
public override void OnInspectorGUI() { serializedObject.Update(); obj = (ZEDSVOManager)target; EditorGUI.BeginChangeCheck(); DrawDefaultInspector(); using (new EditorGUI.DisabledScope(Application.isPlaying)) { string tooltip = "Uses timecodes of each frame for playback. Causes a pause for dropped frames or when pause was used during recording."; obj.realtimePlayback = EditorGUILayout.Toggle(new GUIContent("Realtime Playback", tooltip), obj.realtimePlayback); } EditorGUILayout.BeginHorizontal(); videoFile.stringValue = EditorGUILayout.TextField("SVO Path", videoFile.stringValue); if (GUILayout.Button("...", optionsButtonBrowse)) { obj.videoFile = EditorUtility.OpenFilePanelWithFilters("Load SVO", "", filters); serializedObject.ApplyModifiedProperties(); } EditorGUILayout.EndHorizontal(); if (drop_area.width != EditorGUIUtility.currentViewWidth || drop_area.height != Screen.height) { drop_area = new Rect(0, 0, EditorGUIUtility.currentViewWidth, Screen.height); } if (EditorGUI.EndChangeCheck()) { CheckChange(); } EditorGUI.BeginChangeCheck(); GUI.enabled = (obj.NumberFrameMax > 0); currentFrame.intValue = EditorGUILayout.IntSlider("Frame ", currentFrame.intValue, 0, numberFrameMax.intValue); if (EditorGUI.EndChangeCheck()) { if (sl.ZEDCamera.GetInstance() != null) { //If the slider of frame from the SVO has moved, grab mannually the frame and update the textures sl.ZEDCamera.GetInstance().SetSVOPosition(currentFrame.intValue); if (pause.boolValue) { sl.ZEDCamera.GetInstance().UpdateTextures(); } } } GUI.enabled = true; GUI.enabled = sl.ZEDCamera.GetInstance() != null && sl.ZEDCamera.GetInstance().IsCameraReady; pauseText = pause.boolValue ? "Resume" : "Pause"; if (GUILayout.Button(pauseText)) { pause.boolValue = !pause.boolValue; } GUI.enabled = true; DropAreaGUI(); serializedObject.ApplyModifiedProperties(); }
void Awake() { instance = this; zedReady = false; //If you want the ZEDRig not to be destroyed DontDestroyOnLoad(transform.root); //Init the first parameters initParameters = new sl.InitParameters(); initParameters.resolution = resolution; initParameters.depthMode = depthMode; initParameters.depthStabilization = depthStabilizer; //Check if the AR is needed and if possible to add CheckStereoMode(); //Init the other options isZEDTracked = enableTracking; initialPosition = zedRigRoot.transform.localPosition; zedPosition = initialPosition; zedOrientation = initialRotation; //Create a camera and return an error message if the dependencies are not detected zedCamera = sl.ZEDCamera.GetInstance(); LastInitStatus = sl.ERROR_CODE.ERROR_CODE_LAST; zedSVOManager = GetComponent <ZEDSVOManager>(); zedCamera.CreateCamera(wrapperVerbose); if (zedSVOManager != null) { //Create a camera if ((zedSVOManager.read || zedSVOManager.record) && zedSVOManager.videoFile.Length == 0) { zedSVOManager.record = false; zedSVOManager.read = false; } if (zedSVOManager.read) { zedSVOManager.record = false; initParameters.pathSVO = zedSVOManager.videoFile; initParameters.svoRealTimeMode = zedSVOManager.realtimePlayback; initParameters.depthStabilization = depthStabilizer; } } versionZED = "[SDK]: " + sl.ZEDCamera.GetSDKVersion().ToString() + " [Plugin]: " + sl.ZEDCamera.PluginVersion.ToString(); //Set the ZED Tracking frame as Left eye if (isStereoRig) { //Creates a CameraRig (the 2 last cameras) GameObject o = CreateZEDRigDisplayer(); o.hideFlags = HideFlags.HideAndDontSave; o.transform.parent = transform; //Force some initParameters that are required for MR experience initParameters.enableRightSideMeasure = isStereoRig; initParameters.depthMinimumDistance = 0.1f; initParameters.depthMode = sl.DEPTH_MODE.PERFORMANCE; initParameters.depthStabilization = depthStabilizer; //Create the mirror, the texture from the firsts cameras is rendered to avoid a black border CreateMirror(); } //Start the co routine to initialize the ZED and avoid to block the user LastInitStatus = sl.ERROR_CODE.ERROR_CODE_LAST; openingLaunched = false; StartCoroutine("InitZED"); OnCamBrightnessChange += CameraBrightnessChangeHandler; }
/// <summary> /// Called by Unity each time the editor is viewed. /// </summary> public override void OnInspectorGUI() { serializedObject.Update(); obj = (ZEDSVOManager)target; EditorGUI.BeginChangeCheck(); DrawDefaultInspector(); using (new EditorGUI.DisabledScope(Application.isPlaying)) { string tooltip = "If reading an SVO, set true to use frame timestamps to set playback speed." + "Dropped frames will cause a 'pause' in playback instead of a 'skip.'"; obj.realtimePlayback = EditorGUILayout.Toggle(new GUIContent("Realtime Playback", tooltip), obj.realtimePlayback); } EditorGUILayout.BeginHorizontal(); GUIContent pathlabel = new GUIContent("SVO Path", "Path to the SVO to be read, or where a new SVO will be recorded. " + "Note: If building the application, put the file in the root directory or specify a non-relative path " + "to preserve this reference."); videoFile.stringValue = EditorGUILayout.TextField(pathlabel, videoFile.stringValue); GUIContent loadlabel = new GUIContent("...", "Browse for existing SVO file."); if (GUILayout.Button(loadlabel, optionsButtonBrowse)) { obj.videoFile = EditorUtility.OpenFilePanelWithFilters("Load SVO", "", filters); serializedObject.ApplyModifiedProperties(); } EditorGUILayout.EndHorizontal(); if (drop_area.width != EditorGUIUtility.currentViewWidth || drop_area.height != Screen.height) { drop_area = new Rect(0, 0, EditorGUIUtility.currentViewWidth, Screen.height); } if (EditorGUI.EndChangeCheck()) { CheckChange(); } EditorGUI.BeginChangeCheck(); GUI.enabled = (obj.NumberFrameMax > 0); GUIContent sliderlabel = new GUIContent("Frame ", "SVO playback position"); currentFrame.intValue = EditorGUILayout.IntSlider(sliderlabel, currentFrame.intValue, 0, numberFrameMax.intValue); if (EditorGUI.EndChangeCheck()) { if (obj.zedCam != null) { //If the slider of frame from the SVO has moved, manually grab the frame and update the textures. obj.zedCam.SetSVOPosition(currentFrame.intValue); if (pause.boolValue) { obj.NeedNewFrameGrab = true; } } } GUI.enabled = false; if (obj.zedCam != null) { GUI.enabled = obj.zedCam.IsCameraReady; } pauseText = pause.boolValue ? "Resume" : "Pause"; GUIContent pauselabel = new GUIContent(pauseText, pauseText + pauseTooltip); if (GUILayout.Button(pauselabel)) { pause.boolValue = !pause.boolValue; } GUI.enabled = true; DropAreaGUI(); serializedObject.ApplyModifiedProperties(); //Applies changes to serialized properties to the values they represent. }