Esempio n. 1
0
        protected override void DrawSettings()
        {
            VrtpStyles.BeginSectionBox(); {
                VrtpEditorUtils.ToggleProperty(_pDrawSkybox, null, VrtpStyles.sectionHeader);
                if (_tm.drawSkybox)
                {
                    ++EditorGUI.indentLevel;
                    EditorGUILayout.PropertyField(_pApplyColorToBkg, _gcApplyColor);
                    EditorGUILayout.PropertyField(_pFxSkybox);
                    --EditorGUI.indentLevel;
                }
            } VrtpStyles.EndSectionBox();

            VrtpStyles.BeginSectionBox(); {
                VrtpEditorUtils.ToggleProperty(_pDrawBeforeTransparent, null, VrtpStyles.sectionHeader);
            } VrtpStyles.EndSectionBox();

            VrtpStyles.BeginSectionBox(); {
                VrtpEditorUtils.ToggleProperty(_pUseMask, null, VrtpStyles.sectionHeader);
                if (_tm.useMask)
                {
                    ++EditorGUI.indentLevel;
                    EditorGUILayout.PropertyField(_pStencilRef);
                    EditorGUILayout.PropertyField(_pStencilMask);
                    EditorGUILayout.PropertyField(_pStencilBias);
                    EditorGUILayout.HelpBox("Mask may stress drawcalls and fillrate.", MessageType.Warning);
                    --EditorGUI.indentLevel;
                }
            } VrtpStyles.EndSectionBox();

            if (!_tm.irisZRejectionEnabled)
            {
                EditorGUILayout.HelpBox("Z-Rejection fillrate optimisation disabled", MessageType.Warning);
            }

            DrawMotionSettings();
        }
Esempio n. 2
0
        protected override void DrawSettings()
        {
            VrtpStyles.BeginSectionBox(); {
                ++EditorGUI.indentLevel;
                _showBkgSettings = EditorGUILayout.Foldout(_showBkgSettings, "Background Settings", VrtpStyles.sectionFoldout);
                --EditorGUI.indentLevel;

                if (_showBkgSettings)
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(_pBkgMode);
                    if (_tib.backgroundMode != TunnellingBase.BackgroundMode.COLOR)
                    {
                        switch (_tib.backgroundMode)
                        {
                        case TunnellingBase.BackgroundMode.SKYBOX:
                            EditorGUILayout.LabelField("Skybox Settings");
                            ++EditorGUI.indentLevel;
                            EditorGUILayout.PropertyField(_pApplyColorToBkg, _gcApplyColorSkybox);
                            EditorGUILayout.PropertyField(_pFxSkybox);
                            EditorGUILayout.PropertyField(_pOverlay);
                            --EditorGUI.indentLevel;
                            break;

                        case TunnellingBase.BackgroundMode.BLUR:
                            EditorGUILayout.HelpBox("BLUR mode is performance-intensive", MessageType.Warning);
                            EditorGUILayout.LabelField("Blur Settings");
                            ++EditorGUI.indentLevel;
                            EditorGUILayout.PropertyField(_pApplyColorToBkg, _gcApplyColorBlur);
                            EditorGUILayout.PropertyField(_pBlurDownsample, _gcBlurDownsample);
                            EditorGUILayout.PropertyField(_pBlurDistance, _gcBlurDistance);
                            EditorGUILayout.PropertyField(_pBlurPasses, _gcBlurPasses);
                            EditorGUILayout.PropertyField(_pBlurKernel, _gcBlurKernel);
                            --EditorGUI.indentLevel;
                            break;

                        case TunnellingBase.BackgroundMode.CAGE_COLOR:
                        case TunnellingBase.BackgroundMode.CAGE_SKYBOX:
                        case TunnellingBase.BackgroundMode.CAGE_ONLY:
                            EditorGUILayout.PropertyField(_pCageParent);
                            ++EditorGUI.indentLevel;
                            _showCageSettings = EditorGUILayout.Foldout(_showCageSettings, _gcCageSettings, VrtpStyles.childFoldout);
                            if (_showCageSettings)
                            {
                                EditorGUILayout.PropertyField(_pApplyColorToBkg, _gcApplyColorCage);
                                EditorGUILayout.PropertyField(_pOverlay);
                                if (_tib.backgroundMode == TunnellingBase.BackgroundMode.CAGE_SKYBOX)
                                {
                                    EditorGUILayout.PropertyField(_pFxSkybox);
                                }
                                EditorGUILayout.PropertyField(_pCageDownsample, _gcCageDownsample);
                                EditorGUILayout.PropertyField(_pCageAa, _gcCageAa);
                                EditorGUILayout.PropertyField(_pCageUpdate, _gcCageUpdate);
                            }
                            _showFogSettings = EditorGUILayout.Foldout(_showFogSettings, _gcFogSettings, VrtpStyles.childFoldout);
                            if (_showFogSettings)
                            {
                                EditorGUILayout.PropertyField(_pCageFogDensity, _gcCageFogDensity);
                                EditorGUILayout.PropertyField(_pCageFogPower, _gcCageFogPower);
                                EditorGUILayout.PropertyField(_pCageFogBlend, _gcCageFogBlend);
                            }
                            --EditorGUI.indentLevel;
                            break;
                        }
                    }
                    if (_tib.backgroundMode != TunnellingBase.BackgroundMode.BLUR)
                    {
                        bool canDrawIris = (bool)_piCanDrawIris.GetValue(_tib, null);
                        if (!canDrawIris)
                        {
                            EditorGUILayout.BeginHorizontal();
                        }
                        EditorGUILayout.PropertyField(_pZRejectIris);
                        if (!canDrawIris)
                        {
                            string whyDisabled = "Disabled: ";
                            if (_tib.usingMask)
                            {
                                whyDisabled += "Masking enabled";
                            }
                            else if (_tib.backgroundMode == TunnellingBase.BackgroundMode.BLUR)
                            {
                                whyDisabled += "Blur enabled";
                            }
                            else if (_tib.backgroundMode == TunnellingBase.BackgroundMode.CAGE_ONLY)
                            {
                                whyDisabled += "CAGE_ONLY mode";
                            }
                            else
                            {
                                whyDisabled += "Effect Color alpha < 1";
                            }
                            GUI.enabled = false;
                            EditorGUILayout.LabelField(whyDisabled);
                            GUI.enabled = true;
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                }
            } VrtpStyles.EndSectionBox();

            VrtpStyles.BeginSectionBox();
            EditorGUILayout.PropertyField(_pMaskMode);
            VrtpStyles.EndSectionBox();

            DrawMotionSettings();

            if (!Application.isPlaying)
            {
                SetFogParams(_tib.cageFogDensity, _tib.cageFogPower, _tib.cageFogBlend, _tib.effectColor);
            }
        }
        protected void DrawMotionSettings()
        {
            #region Detection
            VrtpStyles.BeginSectionBox(); {
                ++EditorGUI.indentLevel;
                _showMotionDetection.active = EditorGUILayout.Foldout(_showMotionDetection, "Motion Detection", VrtpStyles.sectionFoldout);
                --EditorGUI.indentLevel;
                if (_showMotionDetection)
                {
                    EditorGUILayout.Space();

                    #region Angular Velocity
                    VrtpStyles.BeginChildBox(); {
                        VrtpEditorUtils.ToggleProperty(_pAvUse, _pAvUse.content, VrtpStyles.sectionHeader);
                        if (_tb.useAngularVelocity)
                        {
                            ++EditorGUI.indentLevel;
                            EditorGUILayout.PropertyField(_pAvStr, _gcAvStr);
                            EditorGUILayout.PropertyField(_pAvMin, _gcAvMin);
                            EditorGUILayout.PropertyField(_pAvMax, _gcAvMax);
                            EditorGUILayout.PropertyField(_pAvSmooth, _gcAvSmooth);
                            --EditorGUI.indentLevel;
                        }
                    } VrtpStyles.EndChildBox();
                    #endregion

                    #region Linear Acceleration
                    VrtpStyles.BeginChildBox(); {
                        VrtpEditorUtils.ToggleProperty(_pLaUse, _pLaUse.content, VrtpStyles.sectionHeader);
                        if (_tb.useAcceleration)
                        {
                            ++EditorGUI.indentLevel;
                            EditorGUILayout.PropertyField(_pLaStr, _gcLaStr);
                            EditorGUILayout.PropertyField(_pLaMin, _gcLaMin);
                            EditorGUILayout.PropertyField(_pLaMax, _gcLaMax);
                            EditorGUILayout.PropertyField(_pLaSmooth, _gcLaSmooth);
                            --EditorGUI.indentLevel;
                        }
                    } VrtpStyles.EndChildBox();
                    #endregion

                    #region Linear Velocity
                    VrtpStyles.BeginChildBox(); {
                        VrtpEditorUtils.ToggleProperty(_pLvUse, _pLvUse.content, VrtpStyles.sectionHeader);
                        if (_tb.useVelocity)
                        {
                            ++EditorGUI.indentLevel;
                            EditorGUILayout.PropertyField(_pLvStr, _gcLvStr);
                            EditorGUILayout.PropertyField(_pLvMin, _gcLvMin);
                            EditorGUILayout.PropertyField(_pLvMax, _gcLvMax);
                            EditorGUILayout.PropertyField(_pLvSmooth, _gcLvSmooth);
                            --EditorGUI.indentLevel;
                        }
                    } VrtpStyles.EndChildBox();
                    #endregion

                    #region Force Vignette
                    EditorGUILayout.Space();
                    VrtpEditorUtils.PropertyField(_pForceVigMode);
                    if (_pForceVigMode.p.intValue != (int)TunnellingBase.ForceVignetteMode.NONE)
                    {
                        VrtpEditorUtils.PropertyField(_pForceVigVal);
                    }
                    #endregion
                }
            } VrtpStyles.EndSectionBox();
            #endregion

            #region Effects
            VrtpStyles.BeginSectionBox(); {
                ++EditorGUI.indentLevel;
                _showMotionEffects.active = EditorGUILayout.Foldout(_showMotionEffects, "Motion Effects", VrtpStyles.sectionFoldout);
                --EditorGUI.indentLevel;
                if (_showMotionEffects)
                {
                    EditorGUILayout.Space();

                    #region Counter-motion
                    VrtpStyles.BeginChildBox(); {
                        VrtpEditorUtils.ToggleProperty(_pCounterMotion, null, VrtpStyles.sectionHeader);
                        if (_pCounterMotion.p.boolValue)
                        {
                            ++EditorGUI.indentLevel;
                            DrawCounterMotionSettings();
                            --EditorGUI.indentLevel;
                        }
                    } VrtpStyles.EndChildBox();
                    #endregion

                    EditorGUILayout.Separator();
                    EditorGUILayout.PropertyField(_pMotionEffectTarget);
                    if (_tb.motionEffectTarget == null && _tb.usingMotionEffectTarget)
                    {
                        EditorGUILayout.HelpBox("No motion effect target specified!", MessageType.Error);
                    }

                    #region Auto-tilt
                    VrtpStyles.BeginChildBox(); {
                        VrtpEditorUtils.ToggleProperty(_pArtTilt, null, VrtpStyles.sectionHeader);
                        if (_pArtTilt.p.boolValue)
                        {
                            ++EditorGUI.indentLevel;
                            EditorGUILayout.PropertyField(_pArtTiltStr);
                            EditorGUILayout.PropertyField(_pArtTiltMax);
                            EditorGUILayout.PropertyField(_pArtTiltSmooth);
                            --EditorGUI.indentLevel;
                        }
                    } VrtpStyles.EndChildBox();
                    #endregion

                    VrtpStyles.BeginChildBox(); {
                        EditorGUILayout.PropertyField(_pDivFps);
                        if (_pDivFps.p.intValue > 1)
                        {
                            EditorGUILayout.PropertyField(_pDivTrans);
                            EditorGUILayout.PropertyField(_pDivRot);
                        }
                    } VrtpStyles.EndChildBox();
                }
            } VrtpStyles.EndSectionBox();
            #endregion
        }
        public override void OnInspectorGUI()
        {
            // Draw header
            EditorGUI.BeginChangeCheck();

            VrtpEditorUtils.DrawImage(_headerLogo, 77, new Vector2(0, 4));

            EditorGUILayout.Space();
            VrtpStyles.BeginSectionBox(); {
                EditorGUILayout.PropertyField(_pTarget);
                if (_tb.motionTarget == null)
                {
                    EditorGUILayout.HelpBox("No motion target specified!", MessageType.Error);
                }
                else if (_tb.motionTarget == _tb.transform)
                {
                    EditorGUILayout.HelpBox("Motion Target generally shouldn't be the HMD", MessageType.Warning);
                }
            } VrtpStyles.EndSectionBox();

            VrtpStyles.BeginSectionBox(); {
                ++EditorGUI.indentLevel;
                _showEffectSettings = EditorGUILayout.Foldout(_showEffectSettings, "Effect Settings", VrtpStyles.sectionFoldout);
                --EditorGUI.indentLevel;

                if (_showEffectSettings)
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(_pFxColor);
                    EditorGUILayout.PropertyField(_pFxCover);
                    EditorGUILayout.PropertyField(_pFxFeather);
                }
            } VrtpStyles.EndSectionBox();

            // Draw content
            DrawSettings();

            // Finalise
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }

            #region Debug
            VrtpStyles.BeginSectionBox(); {
                ++EditorGUI.indentLevel;
                EditorGUILayout.BeginHorizontal(); {
                    _showDebug = EditorGUILayout.Foldout(_showDebug, _gcDebugLabel, VrtpStyles.sectionFoldout);
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("About VRTP", EditorStyles.miniButton))
                    {
                        VrtpAboutWindow.Open();
                    }
                    if (GUILayout.Button("Open Manual", EditorStyles.miniButton))
                    {
                        Application.OpenURL(URL_DOCS);
                    }
                } EditorGUILayout.EndHorizontal();
                --EditorGUI.indentLevel;

                if (_showDebug)
                {
                    bool showMotionDebug = (bool)_fiDebugMotion.GetValue(_tb);
                    EditorGUI.BeginChangeCheck();
                    showMotionDebug = EditorGUILayout.ToggleLeft(_gcDebugMotion, showMotionDebug, VrtpStyles.sectionHeader);
                    if (EditorGUI.EndChangeCheck())
                    {
                        _fiDebugMotion.SetValue(_tb, showMotionDebug);
                        // Reset peak motion data each time toggled
                        _debugAvMax = _debugLaMax = _debugLvMax = 0;
                    }
                    if (showMotionDebug)
                    {
                        ++EditorGUI.indentLevel;
                        float currentAv, currentLa, currentLv;
                        currentAv = currentLa = currentLv = 0;
                        if (Application.isPlaying)
                        {
                            #region Get motion data
                            currentAv   = (float)_fiDebugAv.GetValue(_tb);
                            currentLa   = (float)_fiDebugLa.GetValue(_tb);
                            currentLv   = (float)_fiDebugLv.GetValue(_tb);
                            _debugAvMax = Mathf.Max(currentAv, _debugAvMax);
                            _debugLaMax = Mathf.Max(currentLa, _debugLaMax);
                            _debugLvMax = Mathf.Max(currentLv, _debugLvMax);
                            #endregion
                        }
                        else
                        {
                            GUI.enabled = false;
                            _debugAvMax = _debugLaMax = _debugLvMax = 0;
                        }

                        #region Draw
                        GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(72) };

                        EditorGUILayout.BeginHorizontal(); {
                            EditorGUILayout.LabelField("Motion", EditorStyles.boldLabel, options);
                            EditorGUILayout.LabelField("Current", EditorStyles.boldLabel, options);
                            EditorGUILayout.LabelField("Max", EditorStyles.boldLabel, options);
                            if (GUILayout.Button(_gcDebugMotionResetAll, options))
                            {
                                _debugAvMax = _debugLaMax = _debugLvMax = 0;
                            }
                        } EditorGUILayout.EndHorizontal();

                        EditorGUILayout.BeginHorizontal(); {
                            EditorGUILayout.LabelField(_gcDebugAvLabel, options);
                            EditorGUILayout.LabelField(string.Format(DEBUG_MOTION_FORMAT, currentAv), options);
                            EditorGUILayout.LabelField(string.Format(DEBUG_MOTION_FORMAT, _debugAvMax), options);
                            if (GUILayout.Button(_gcDebugMotionResetBtn, options))
                            {
                                _debugAvMax = 0;
                            }
                        } EditorGUILayout.EndHorizontal();

                        EditorGUILayout.BeginHorizontal(); {
                            EditorGUILayout.LabelField(_gcDebugLaLabel, options);
                            EditorGUILayout.LabelField(string.Format(DEBUG_MOTION_FORMAT, currentLa), options);
                            EditorGUILayout.LabelField(string.Format(DEBUG_MOTION_FORMAT, _debugLaMax), options);
                            if (GUILayout.Button(_gcDebugMotionResetBtn, options))
                            {
                                _debugLaMax = 0;
                            }
                        } EditorGUILayout.EndHorizontal();

                        EditorGUILayout.BeginHorizontal(); {
                            EditorGUILayout.LabelField(_gcDebugLvLabel, options);
                            EditorGUILayout.LabelField(string.Format(DEBUG_MOTION_FORMAT, currentLv), options);
                            EditorGUILayout.LabelField(string.Format(DEBUG_MOTION_FORMAT, _debugLvMax), options);
                            if (GUILayout.Button(_gcDebugMotionResetBtn, options))
                            {
                                _debugLvMax = 0;
                            }
                        } EditorGUILayout.EndHorizontal();
                        #endregion
                        GUI.enabled = true;
                        --EditorGUI.indentLevel;
                    }
                    DrawDebugOptions();
                }
            } VrtpStyles.EndSectionBox();

            #endregion
        }