Ejemplo n.º 1
0
        /// <summary>
        /// Enable a specific debug view.
        /// Pass null to disable debug views.
        /// You can browse available debug views with AllAvailableDebugViews property.
        /// </summary>
        /// <param name="data"></param>
        public void EnableView(DebugViewData data)
        {
            if (!CheckForCorrectlyLoaded())
            {
                return;
            }

            SaveURPAssetIfPossible();

            bool success;

            if (!data || data.RenderObjectsNormallyBefore)
            {
                success = PopURPAssetIfPossible();
            }
            else
            {
                success = true;
                SetNewRenderPipelineAsset(_debugViewRenderPipelineAsset);
            }

            if (success)
            {
                _currentViewData = data;

#if UNITY_EDITOR
                EditorPrefs.SetInt(DebugViewIndexEditorPref, _debugViewDatas.IndexOf(_currentViewData));
#endif
            }
        }
Ejemplo n.º 2
0
        private void ValidateRenderPipeline()
        {
            if (!CheckForCorrectlyLoaded(false))
            {
                return;
            }

            if (GetCurrentRenderPipelineAsset() == _debugViewRenderPipelineAsset)
            {
                const int notSetValue         = -1;
                int       savedDebugViewIndex = notSetValue;

#if UNITY_EDITOR
                savedDebugViewIndex = EditorPrefs.GetInt(DebugViewIndexEditorPref, notSetValue);
#endif

                if (savedDebugViewIndex == notSetValue || savedDebugViewIndex >= _debugViewDatas.Count)
                {
                    // load a default view that can use the debug view render pipeline
                    _currentViewData = _debugViewDatas.FirstOrDefault(data => !data.RenderObjectsNormallyBefore);
                }
                else
                {
                    _currentViewData = _debugViewDatas[savedDebugViewIndex];
                }
            }
        }
Ejemplo n.º 3
0
 private void EditorApplicationOnPlayModeStateChanged(PlayModeStateChange stateChange)
 {
     if (stateChange == PlayModeStateChange.ExitingEditMode)
     {
         PopURPAssetIfPossible();
     }
     else if (stateChange == PlayModeStateChange.EnteredEditMode)
     {
         _currentViewData = null;
     }
 }