예제 #1
0
        public override void DrawOutputSettings()
        {
            // Check if save location has changed from settings window
            if (animSaveDestination != EditorPrefs.GetString(SAVE_DESTINATION_KEY))
            {
                animSaveDestination = EditorPrefs.GetString(SAVE_DESTINATION_KEY);
                absPath             = (Application.dataPath).Replace("Assets", animSaveDestination);
            }

            TransformationType tempTransformationType = (TransformationType)EditorGUILayout.EnumPopup(new GUIContent("Transformation Type"), transformationType);

            if (tempTransformationType != transformationType)
            {
                transformationType = tempTransformationType;
                EditorPrefs.SetInt(TRANSFORMATION_TYPE_KEY, (int)transformationType);
            }

            //int tempFrameRate = EditorGUILayout.IntField(new GUIContent("Frame Rate", "The amount of frames to create per second in the output animation."), frameRate);

            //if (tempFrameRate != frameRate)
            //{
            //    frameRate = tempFrameRate;
            //    EditorPrefs.SetInt(FRAME_RATE_KEY, frameRate);
            //}



            int tempFrameRateIndex = EditorGUILayout.Popup("Frame Rate", selectedFrameRateIndex, new string[2] {
                "30 FPS", "60 FPS"
            });

            if (tempFrameRateIndex != selectedFrameRateIndex)
            {
                selectedFrameRateIndex = tempFrameRateIndex;
                EditorPrefs.SetInt(FRAME_RATE_INDEX_KEY, selectedFrameRateIndex);
            }

            string tempFileName = EditorGUILayout.TextField(new GUIContent("Animation Name", "The name of the animation when saved to .dae format."), fileName);

            if (tempFileName != fileName)
            {
                fileName = tempFileName;
                EditorPrefs.SetString(FILENAME_KEY, fileName);
            }

            // Save Path Field & Button

            EditorGUILayout.PrefixLabel("Save Location:");

            EditorGUILayout.BeginHorizontal();

            EditorGUI.indentLevel++;
            EditorGUILayout.SelectableLabel(animSaveDestination, EditorStyles.textField, GUILayout.Height(16f));
            EditorGUI.indentLevel--;

            bool saveDestChanged = false;

            if (GUILayout.Button(new GUIContent("..."), EditorStyles.miniButton, GUILayout.Width(24f)))
            {
                // Ensure the path text field does not have focus, or else we cannot change the contents.
                GUI.SetNextControlName("");
                GUI.FocusControl("");

                string temp = EditorUtility.SaveFolderPanel("Select a folder within your project", animSaveDestination, "");

                // Pressing cancel returns an empty string, don't clear the previous text on cancel.
                if (temp != string.Empty)
                {
                    absPath = temp;
                }

                saveDestChanged = true;
            }

            EditorGUILayout.EndHorizontal();

            // Display error if path not within project folder
            if (!absPath.StartsWith(Application.dataPath))
            {
                EditorGUILayout.HelpBox("Invalid selection!\nYou must select a location within your project's \"Assets\" folder.", MessageType.Warning);
                animSaveDestination = CinemaMocapHelper.GetRelativeProjectPath(Application.dataPath);
            }
            else
            {
                animSaveDestination = CinemaMocapHelper.GetRelativeProjectPath(absPath);
            }

            if (saveDestChanged)
            {
                EditorPrefs.SetString(SAVE_DESTINATION_KEY, animSaveDestination);
            }
        }
예제 #2
0
        /// <summary>
        /// Draw the Window's contents
        /// </summary>
        protected void OnGUI()
        {
            // Show Defaults options
            EditorGUILayout.Foldout(true, "Defaults");
            EditorGUI.indentLevel++;

            GUIContent[] mocapProfileContent = new GUIContent[inputProfiles.Count];
            for (int i = 0; i < inputProfiles.Count; i++)
            {
                mocapProfileContent[i] = new GUIContent(inputProfiles[i].Label);
            }
            int tempProfileSelection = EditorGUILayout.Popup(new GUIContent("Device", "Profile"), mocapProfileSelection, mocapProfileContent);

            if (mocapProfileSelection != tempProfileSelection)
            {
                mocapProfileSelection = tempProfileSelection;
                EditorPrefs.SetString(InputProfileKey, inputProfiles[mocapProfileSelection].Label);
            }

            GUIContent[] layoutContent = new GUIContent[layoutProfiles.Count];
            for (int i = 0; i < layoutProfiles.Count; i++)
            {
                layoutContent[i] = new GUIContent(layoutProfiles[i].Label);
            }
            int tempSelection = EditorGUILayout.Popup(new GUIContent("Layout", "Layout"), layoutProfileSelection, layoutContent);

            if (tempSelection != layoutProfileSelection)
            {
                layoutProfileSelection = tempSelection;
                EditorPrefs.SetString(LayoutKey, layoutProfiles[layoutProfileSelection].Label);
            }

            // Check if save locations have changed from mocap window
            if (anim20JointSaveDestination != EditorPrefs.GetString(Anim20JointSaveDestKey))
            {
                anim20JointSaveDestination = EditorPrefs.GetString(Anim20JointSaveDestKey);
                anim20AbsPath = (Application.dataPath).Replace("Assets", anim20JointSaveDestination);
            }
            if (anim25JointSaveDestination != EditorPrefs.GetString(Anim25JointSaveDestKey))
            {
                anim25JointSaveDestination = EditorPrefs.GetString(Anim25JointSaveDestKey);
                anim25AbsPath = (Application.dataPath).Replace("Assets", anim25JointSaveDestination);
            }
            if (sessionSaveDestination != EditorPrefs.GetString(Anim20JointSaveDestKey))
            {
                sessionSaveDestination = EditorPrefs.GetString(SessionSaveDestKey);
                sessionAbsPath         = (Application.dataPath).Replace("Assets", sessionSaveDestination);
            }

            // 20 Joint Save Path Field & Button

            EditorGUILayout.PrefixLabel("Kinect 1 Anim Save:");

            EditorGUILayout.BeginHorizontal();

            EditorGUI.indentLevel++;
            EditorGUILayout.SelectableLabel(anim20JointSaveDestination, EditorStyles.textField, GUILayout.Height(16f));
            EditorGUI.indentLevel--;


            if (GUILayout.Button(new GUIContent("..."), EditorStyles.miniButton, GUILayout.Width(24f)))
            {
                // Ensure the path text field does not have focus, or else we cannot change the contents.
                GUI.SetNextControlName("");
                GUI.FocusControl("");

                string temp = EditorUtility.SaveFolderPanel("Select a folder within your project", anim20JointSaveDestination, "");

                // Pressing cancel returns an empty string, don't clear the previous text on cancel.
                if (temp != string.Empty)
                {
                    anim20AbsPath = temp;
                }
            }

            EditorGUILayout.EndHorizontal();

            // Display error if path not within project folder
            if (!anim20AbsPath.StartsWith(Application.dataPath))
            {
                EditorGUILayout.HelpBox("Invalid selection!\nYou must select a location within your project's \"Assets\" folder.", MessageType.Warning);
                anim20JointSaveDestination = CinemaMocapHelper.GetRelativeProjectPath(Application.dataPath);
                EditorPrefs.SetString(Anim20JointSaveDestKey, anim20JointSaveDestination);
            }
            else
            {
                anim20JointSaveDestination = CinemaMocapHelper.GetRelativeProjectPath(anim20AbsPath);
                EditorPrefs.SetString(Anim20JointSaveDestKey, anim20JointSaveDestination);
            }

            // 25 Joint Save Path Field & Button

            EditorGUILayout.PrefixLabel("Kinect 2 Anim Save:");

            EditorGUILayout.BeginHorizontal();

            EditorGUI.indentLevel++;
            EditorGUILayout.SelectableLabel(anim25JointSaveDestination, EditorStyles.textField, GUILayout.Height(16f));
            EditorGUI.indentLevel--;


            if (GUILayout.Button(new GUIContent("..."), EditorStyles.miniButton, GUILayout.Width(24f)))
            {
                // Ensure the path text field does not have focus, or else we cannot change the contents.
                GUI.SetNextControlName("");
                GUI.FocusControl("");

                string temp = EditorUtility.SaveFolderPanel("Select a folder within your project", anim25JointSaveDestination, "");

                // Pressing cancel returns an empty string, don't clear the previous text on cancel.
                if (temp != string.Empty)
                {
                    anim25AbsPath = temp;
                }
            }

            EditorGUILayout.EndHorizontal();

            // Display error if path not within project folder
            if (!anim25AbsPath.StartsWith(Application.dataPath))
            {
                EditorGUILayout.HelpBox("Invalid selection!\nYou must select a location within your project's \"Assets\" folder.", MessageType.Warning);
                anim25JointSaveDestination = CinemaMocapHelper.GetRelativeProjectPath(Application.dataPath);
                EditorPrefs.SetString(Anim25JointSaveDestKey, anim25JointSaveDestination);
            }
            else
            {
                anim25JointSaveDestination = CinemaMocapHelper.GetRelativeProjectPath(anim25AbsPath);
                EditorPrefs.SetString(Anim25JointSaveDestKey, anim25JointSaveDestination);
            }

            // Session Save Path Field & Button

            EditorGUILayout.PrefixLabel("Session Save:");

            EditorGUILayout.BeginHorizontal();

            EditorGUI.indentLevel++;
            EditorGUILayout.SelectableLabel(sessionSaveDestination, EditorStyles.textField, GUILayout.Height(16f));
            EditorGUI.indentLevel--;


            if (GUILayout.Button(new GUIContent("..."), EditorStyles.miniButton, GUILayout.Width(24f)))
            {
                // Ensure the path text field does not have focus, or else we cannot change the contents.
                GUI.SetNextControlName("");
                GUI.FocusControl("");

                string temp = EditorUtility.SaveFolderPanel("Select a folder within your project", sessionSaveDestination, "");

                // Pressing cancel returns an empty string, don't clear the previous text on cancel.
                if (temp != string.Empty)
                {
                    sessionAbsPath = temp;
                }
            }

            EditorGUILayout.EndHorizontal();

            // Display error if path not within project folder
            if (!sessionAbsPath.StartsWith(Application.dataPath))
            {
                EditorGUILayout.HelpBox("Invalid selection!\nYou must select a location within your project's \"Assets\" folder.", MessageType.Warning);
                sessionSaveDestination = CinemaMocapHelper.GetRelativeProjectPath(Application.dataPath);
                EditorPrefs.SetString(SessionSaveDestKey, sessionSaveDestination);
            }
            else
            {
                sessionSaveDestination = CinemaMocapHelper.GetRelativeProjectPath(sessionAbsPath);
                EditorPrefs.SetString(SessionSaveDestKey, sessionSaveDestination);
            }

            EditorGUI.indentLevel--;

            //EditorGUILayout.Foldout(true, "Developers");

            //EditorGUI.indentLevel++;
            //bool tempDevMode = EditorGUILayout.Toggle(new GUIContent("Developer Mode"), developerMode);
            //if (tempDevMode != developerMode)
            //{
            //    developerMode = tempDevMode;
            //    EditorPrefs.SetBool(DeveloperModeKey, tempDevMode);
            //}
            //EditorGUI.indentLevel--;
        }
예제 #3
0
        public override void DrawPipelineSettings()
        {
            int tempDelaySelection = EditorGUILayout.Popup(new GUIContent("Start Delay", "The delay in seconds before recording begins after pressing the record button."), delaySelection, delays);

            if (tempDelaySelection != delaySelection)
            {
                delaySelection = tempDelaySelection;
                EditorPrefs.SetInt(RECORD_START_DELAY_KEY, delaySelection);
            }

            bool isDeveloperModeEnabled = true;

            if (isDeveloperModeEnabled)
            {
                bool tempSaveSession = EditorGUILayout.Toggle(new GUIContent("Save Session", "Saves the raw data of the session in the project folder for later use."), saveSession);

                if (tempSaveSession != saveSession)
                {
                    saveSession = tempSaveSession;
                    EditorPrefs.SetBool(PIPELINE_SAVE_SESSION_KEY, saveSession);
                }

                if (saveSession)
                {
                    // Check if save location has changed from settings window
                    if (sessionSaveDestination != EditorPrefs.GetString(PIPELINE_SAVE_DESTINATION_KEY))
                    {
                        sessionSaveDestination = EditorPrefs.GetString(PIPELINE_SAVE_DESTINATION_KEY);
                        absPath = (Application.dataPath).Replace("Assets", sessionSaveDestination);
                    }

                    string tempFileName = EditorGUILayout.TextField(new GUIContent("Session Filename"), fileName);

                    if (tempFileName != fileName)
                    {
                        fileName = tempFileName;
                        EditorPrefs.SetString(PIPELINE_SAVE_FILENAME_KEY, fileName);
                    }

                    EditorGUILayout.PrefixLabel("Save Location:");

                    EditorGUILayout.BeginHorizontal();

                    EditorGUI.indentLevel++;
                    EditorGUILayout.SelectableLabel(sessionSaveDestination, EditorStyles.textField, GUILayout.Height(16f));
                    EditorGUI.indentLevel--;


                    bool saveDestChanged = false;
                    if (GUILayout.Button(new GUIContent("..."), EditorStyles.miniButton, GUILayout.Width(24f)))
                    {
                        // Ensure the path text field does not have focus, or else we cannot change the contents.
                        GUI.SetNextControlName("");
                        GUI.FocusControl("");

                        string temp = EditorUtility.SaveFolderPanel("Select a folder within your project", sessionSaveDestination, "");

                        // Pressing cancel returns an empty string, don't clear the previous text on cancel.
                        if (temp != string.Empty)
                        {
                            absPath = temp;
                        }

                        saveDestChanged = true;
                    }

                    EditorGUILayout.EndHorizontal();

                    // Display error if path not within project folder
                    if (!absPath.StartsWith(Application.dataPath))
                    {
                        EditorGUILayout.HelpBox("Invalid selection!\nYou must select a location within your project's \"Assets\" folder.", MessageType.Warning);
                        sessionSaveDestination = CinemaMocapHelper.GetRelativeProjectPath(Application.dataPath);
                    }
                    else
                    {
                        sessionSaveDestination = CinemaMocapHelper.GetRelativeProjectPath(absPath);
                    }

                    if (saveDestChanged)
                    {
                        EditorPrefs.SetString(PIPELINE_SAVE_DESTINATION_KEY, sessionSaveDestination);
                    }
                }
            }

            EditorGUI.BeginDisabledGroup(!InputProfile.IsDeviceOn);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(" ");
            if (GUILayout.Button(captureState == RecordingState.NotRecording ? new GUIContent("Record") : new GUIContent("Stop"), EditorStyles.miniButton))
            {
                if (captureState == RecordingState.NotRecording)
                {
                    int delaySeconds = int.Parse(delays[delaySelection].text.Split(' ')[0]);
                    StartRecording(delaySeconds);
                }
                else
                {
                    MocapSession session = StopRecording();
                    saveAnimation(session);
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();
        }