public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.HelpBox(
                "Before using this DataHandler to store data in an online DynamoDB database, you need to set up an Amazon AWS account, DynamoDB, and a Cognito Identity Pool with write access to your database. The article on the Wiki can help:",
                UnityEditor.MessageType.Info);

            if (EditorExtensions.MiddleButton("Go to Wiki page"))
            {
                Application.OpenURL("https://github.com/immersivecognition/unity-experiment-framework/wiki/AWS-DynamoDB-setup");
            }

            EditorGUILayout.Space();
            EditorGUILayout.HelpBox("Enter the region of your AWS DynamoDB & Cognito Identity pool. It should look like 'eu-west-2'.", UnityEditor.MessageType.Info);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("region"));

            EditorGUILayout.Space();
            EditorGUILayout.HelpBox("Enter ID of the Cognito Identity Pool you setup to have read/write access to your DynamoDB. It should look like 'eu-west-2:00000000-0000-0000-0000-000000000000'.", UnityEditor.MessageType.Info);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("cognitoIdentityPool"));

            // Write back changed values and evtl mark as dirty and handle undo/redo
            serializedObject.ApplyModifiedProperties();
        }
示例#2
0
        protected override void DrawInspector()
        {
            serializedObject.Update();

            EditorGUI.BeginDisabledGroup(true);
            {
                EditorGUILayout.ObjectField(
                    "Script",
                    MonoScript.FromMonoBehaviour(uiController),
                    typeof(MonoScript),
                    false
                    );
            }
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.Separator();

            tabSelection = GUILayout.Toolbar(tabSelection, tabTexts);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(":: ", EditorStyles.boldLabel);
            GUILayout.Label(tabTexts[tabSelection], EditorStyles.boldLabel);
            GUILayout.Label(" ::", EditorStyles.boldLabel);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            if (tabSelection != 0 && uiController.startupMode != StartupMode.BuiltInUI)
            {
                DrawUIDisabledMessage();
            }

            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.Separator();
            float lw = EditorGUIUtility.labelWidth;

            switch (tabSelection)
            {
            case 0:


                string ppidReasonText;
                if (!uiController.PPIDModeIsValid(out ppidReasonText))
                {
                    string errorText = "Incompatibility Error: " + ppidReasonText;
                    EditorGUILayout.HelpBox(errorText, UnityEditor.MessageType.Error);
                    EditorGUILayout.Separator();
                }

                string settingsReasonText;
                if (!uiController.SettingsModeIsValid(out settingsReasonText))
                {
                    string errorText = "Incompatibility Error: " + settingsReasonText;
                    EditorGUILayout.HelpBox(errorText, UnityEditor.MessageType.Error);
                    EditorGUILayout.Separator();
                }

                string localPathStateReasonText;
                if (!uiController.LocalPathStateIsValid(out localPathStateReasonText))
                {
                    string errorText = "Incompatibility Error: " + localPathStateReasonText;
                    EditorGUILayout.HelpBox(errorText, UnityEditor.MessageType.Error);
                    EditorGUILayout.Separator();
                }

                EditorGUILayout.HelpBox("Startup Mode " + uiController.startupMode.ToString() + ": " + startupModeDescriptionMapping[uiController.startupMode], UnityEditor.MessageType.Info);
                this.DrawProperty("startupMode");
                if (uiController.startupMode == StartupMode.Automatic || uiController.settingsMode != SettingsMode.AcquireFromUI)
                {
                    this.DrawProperty("experimentName");
                }
                EditorGUILayout.Separator();

                EditorGUI.BeginDisabledGroup(uiController.startupMode == StartupMode.Manual);
                if (uiController.startupMode == StartupMode.Manual)
                {
                    EditorGUILayout.HelpBox("Manual is selected as the Startup Setting - the options below have no effect.", UnityEditor.MessageType.Info);
                    EditorGUILayout.Separator();
                }

                EditorGUILayout.HelpBox("PPID Mode " + uiController.ppidMode.ToString() + ": " + ppidModeDescriptionMapping[uiController.ppidMode], UnityEditor.MessageType.Info);
                this.DrawProperty("ppidMode");
                if (uiController.ppidMode == PPIDMode.GenerateUnique)
                {
                    this.DrawProperty("uuidWordList");
                }
                else if (uiController.ppidMode == PPIDMode.AcquireFromUI)
                {
                    EditorGUILayout.Separator();
                    EditorGUILayout.HelpBox("Session Num Mode " + uiController.sessionNumMode.ToString() + ": " + sessionNumModeDescriptionMapping[uiController.sessionNumMode], UnityEditor.MessageType.Info);
                    this.DrawProperty("sessionNumMode");
                    EditorGUILayout.Separator();
                }
                EditorGUILayout.Separator();


                EditorGUILayout.HelpBox("Settings Mode " + uiController.settingsMode.ToString() + ": " + settingsModeDescriptionMapping[uiController.settingsMode], UnityEditor.MessageType.Info);
                this.DrawProperty("settingsMode");
                switch (uiController.settingsMode)
                {
                case SettingsMode.AcquireFromUI:
                    this.DrawProperty("settingsSearchPattern");
                    break;

                case SettingsMode.DownloadFromURL:
                    this.DrawProperty("jsonURL");
                    break;

                case SettingsMode.Empty:
                    break;
                }

                EditorGUI.EndDisabledGroup();

                EditorGUILayout.Separator();

                if (EditorExtensions.MiddleButton("Force UI Refresh"))
                {
                    uiController.LateValidate();
                }
                break;

            case 1:
                string datapointsReasonText;
                EditorGUILayout.HelpBox(
                    "Below you can enter a series of datapoints to be collected about a participant" +
                    "- such as their age, gender, or even things that could affect the task such as " +
                    "the preferred hand of the participant. Press the Generate button to update the UI " +
                    "to reflect your items.", UnityEditor.MessageType.Info);
                bool valid = uiController.DatapointsAreValid(out datapointsReasonText);
                if (!valid)
                {
                    string errorText = "Participant Datapoints Error: " + datapointsReasonText;
                    EditorGUILayout.HelpBox(errorText, UnityEditor.MessageType.Error);
                    EditorGUILayout.Separator();
                }
                if (EditorExtensions.MiddleButton("Generate", enabled: valid))
                {
                    uiController.GenerateSidebar();
                }
                EditorGUILayout.Separator();
                EditorGUI.indentLevel++;
                DrawPropertiesFromUpTo("participantDataPoints", "termsAndConditions");
                EditorGUI.indentLevel--;
                break;

            case 2:
                EditorGUILayout.HelpBox(
                    "You can edit the content that displays in the right side of the UI. This can " +
                    "be used for instructions to the participant or researcher on how the study should " +
                    "be performed, and what types of data will be collected. " +
                    "You can add any UI elements such as text, images, or even buttons to  " +
                    "the Instructions Panel Content GameObject. You can select it with the button below.", UnityEditor.MessageType.Info);
                if (EditorExtensions.MiddleButton("Select Content GameObject"))
                {
                    if (uiController.instructionsContentTransform.childCount > 0)
                    {
                        Selection.activeObject = uiController.instructionsContentTransform.GetChild(0);
                    }
                    else
                    {
                        Selection.activeObject = uiController.instructionsContentTransform;
                    }
                }
                EditorGUILayout.HelpBox(
                    "You can also change the 'terms & conditions' style message that must be ticked " +
                    "for the session to begin.", UnityEditor.MessageType.Info);
                this.DrawProperty("termsAndConditions");
                this.DrawProperty("tsAndCsInitialState");

                break;
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Separator();

            serializedObject.ApplyModifiedProperties();
        }