Example #1
0
    // Currently does not support editing of multiple objects at once.
    // I do not anticipate any problems with this since you should only
    // ever really have one per scene anyway.
    public sealed override void OnInspectorGUI()
    {
        // A decent style.  Light grey text inside a border.
        helpStyle           = new GUIStyle(GUI.skin.box);
        helpStyle.wordWrap  = true;
        helpStyle.alignment = TextAnchor.UpperLeft;

        helpStyle.normal.textColor = Color.red;

        // Update the serializedobject
        serializedObject.Update();

        EditorGUILayout.PropertyField(_worldScale);

        // Cache the editor's playing state so we can prevent editing fields that shouldn't update during
        // a live play session.
        bool isPlaying = EditorApplication.isPlaying;

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Client uses...", EditorStyles.boldLabel);
        EditorGUI.BeginChangeCheck();
        {
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(_gaze);
            EditorGUILayout.PropertyField(_orientation);
            EditorGUILayout.PropertyField(_position);
            EditorGUI.indentLevel--;
        }
        if (EditorGUI.EndChangeCheck())
        {
            FoveInterfaceBase xface = target as FoveInterfaceBase;
            if (xface != null)
            {
                xface.ReloadFoveClient();
            }
        }

        EditorGUILayout.Space();
        EditorGUILayout.PropertyField(_skipAutoCalibrationCheck);

        EditorGUILayout.PropertyField(_oversamplingRatio);

        GUI.enabled    = true;
        _showOverrides = EditorGUILayout.Foldout(_showOverrides, "Headset Overrides");
        if (_showOverrides)
        {
            EditorGUI.indentLevel++;

            EditorGUILayout.PropertyField(_useCustomPositionScaling);
            GUI.enabled = _useCustomPositionScaling.boolValue;
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(_posScales);
                EditorGUI.indentLevel--;
            }

            GUI.enabled = true;
            EditorGUILayout.PropertyField(_usesCustomPlacement);
            GUI.enabled = _usesCustomPlacement.boolValue;            // & !isPlaying;  // not modifiable in play mode
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(_IOD);
                EditorGUILayout.PropertyField(_eyeHeight);
                EditorGUILayout.PropertyField(_eyeForward);
                EditorGUI.indentLevel--;
            }

            GUI.enabled = true;
            EditorGUILayout.PropertyField(_suppressProjectionUpdates);

            EditorGUI.indentLevel--;
        }

        GUI.enabled            = true;
        _showCompositorAttribs = EditorGUILayout.Foldout(_showCompositorAttribs, "Compositor options");
        if (_showCompositorAttribs)
        {
            GUI.enabled = !isPlaying;
            EditorGUI.indentLevel++;

            EditorGUILayout.PropertyField(_compositorLayerType);
            EditorGUILayout.PropertyField(_compositorDisableTimewarp);
            EditorGUILayout.PropertyField(_compositorDisableDistortion);

            EditorGUI.indentLevel--;
        }

        GUI.enabled = true;
        if (isPlaying && GUILayout.Button("Ensure calibration"))
        {
            Debug.Log("Manually triggering eye tracking calibration check from inspector...");
            FoveInterface.EnsureEyeTrackingCalibration();
        }

        if (Application.targetFrameRate != -1)
        {
            GUILayout.Label(
                "WARNING: Your target framerate is set to " + Application.targetFrameRate + ". Having a target framerate can artificially slow down FOVE frame submission. We recommend disabling this."
                , helpStyle
                , GUILayout.ExpandWidth(true));
        }

        DrawLocalGUIEditor();

        serializedObject.ApplyModifiedProperties();

        // Tell a live FoveInterfaceBase object to try to update itself
        if (isPlaying && GUI.changed)
        {
            FoveInterfaceBase xface = target as FoveInterfaceBase;
            if (xface != null)
            {
                xface.RefreshSetup();
            }
        }
    }