Пример #1
0
        static PlayModeView GetOrCreateWindow()
        {
            var view = PlayModeView.GetMainPlayModeView();

            if (view == null)
            {
                return(EditorWindow.CreateWindow <GameView>());
            }

            return(view);
        }
Пример #2
0
        internal void ClickEnableFrameDebugger()
        {
            bool isEnabled       = FrameDebugger.enabled;
            bool enablingLocally = !isEnabled && m_AttachToPlayerState.connectedToTarget == ConnectionTarget.Editor;

            if (enablingLocally && !FrameDebuggerUtility.locallySupported)
            {
                return;
            }

            // pause play mode if needed
            if (enablingLocally)
            {
                if (EditorApplication.isPlaying && !EditorApplication.isPaused)
                {
                    EditorApplication.isPaused = true;
                }
            }

            if (!isEnabled)
            {
                FrameDebuggerUtility.SetEnabled(true, ProfilerDriver.connectedProfiler);
            }
            else
            {
                FrameDebuggerUtility.SetEnabled(false, FrameDebuggerUtility.GetRemotePlayerGUID());
            }

            // Make sure game view is visible when enabling frame debugger locally
            if (FrameDebugger.IsLocalEnabled())
            {
                PlayModeView playModeView = PlayModeView.GetMainPlayModeView();
                if (playModeView)
                {
                    playModeView.ShowTab();
                }
            }
        }
Пример #3
0
        private void BuiltinCustomSplashScreenGUI()
        {
            EditorGUILayout.LabelField(k_Texts.splashTitle, EditorStyles.boldLabel);

            using (new EditorGUI.DisabledScope(!licenseAllowsDisabling))
            {
                EditorGUILayout.PropertyField(m_ShowUnitySplashScreen, k_Texts.showSplash);
                if (!m_ShowUnitySplashScreen.boolValue)
                {
                    return;
                }
            }

            GUIContent buttonLabel       = SplashScreen.isFinished ? k_Texts.previewSplash : k_Texts.cancelPreviewSplash;
            Rect       previewButtonRect = GUILayoutUtility.GetRect(buttonLabel, "button");

            previewButtonRect = EditorGUI.PrefixLabel(previewButtonRect, new GUIContent(" "));
            if (GUI.Button(previewButtonRect, buttonLabel))
            {
                if (SplashScreen.isFinished)
                {
                    SplashScreen.Begin();
                    PlayModeView.RepaintAll();
                    var playModeView = PlayModeView.GetMainPlayModeView();
                    if (playModeView)
                    {
                        playModeView.Focus();
                    }
                    EditorApplication.update += PollSplashState;
                }
                else
                {
                    SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate);
                    EditorApplication.update -= PollSplashState;
                }

                GameView.RepaintAll();
            }

            EditorGUILayout.PropertyField(m_SplashScreenLogoStyle, k_Texts.splashStyle);

            // Animation
            EditorGUILayout.PropertyField(m_SplashScreenAnimation, k_Texts.animate);
            m_ShowAnimationControlsAnimator.target = m_SplashScreenAnimation.intValue == (int)PlayerSettings.SplashScreen.AnimationMode.Custom;

            if (EditorGUILayout.BeginFadeGroup(m_ShowAnimationControlsAnimator.faded))
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.Slider(m_SplashScreenLogoAnimationZoom, 0.0f, 1.0f, k_Texts.logoZoom);
                EditorGUILayout.Slider(m_SplashScreenBackgroundAnimationZoom, 0.0f, 1.0f, k_Texts.backgroundZoom);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFadeGroup();

            EditorGUILayout.Space();

            // Logos
            EditorGUILayout.LabelField(k_Texts.logosTitle, EditorStyles.boldLabel);
            using (new EditorGUI.DisabledScope(!Application.HasProLicense()))
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(m_ShowUnitySplashLogo, k_Texts.showLogo);
                if (EditorGUI.EndChangeCheck())
                {
                    if (!m_ShowUnitySplashLogo.boolValue)
                    {
                        RemoveUnityLogoFromLogosList();
                    }
                    else if (m_SplashScreenDrawMode.intValue == (int)PlayerSettings.SplashScreen.DrawMode.AllSequential)
                    {
                        AddUnityLogoToLogosList();
                    }
                }

                m_ShowLogoControlsAnimator.target = m_ShowUnitySplashLogo.boolValue;
            }

            if (EditorGUILayout.BeginFadeGroup(m_ShowLogoControlsAnimator.faded))
            {
                EditorGUI.BeginChangeCheck();
                var oldDrawmode = m_SplashScreenDrawMode.intValue;
                EditorGUILayout.PropertyField(m_SplashScreenDrawMode, k_Texts.drawMode);
                if (oldDrawmode != m_SplashScreenDrawMode.intValue)
                {
                    if (m_SplashScreenDrawMode.intValue == (int)PlayerSettings.SplashScreen.DrawMode.UnityLogoBelow)
                    {
                        RemoveUnityLogoFromLogosList();
                    }
                    else
                    {
                        AddUnityLogoToLogosList();
                    }
                }
            }
            EditorGUILayout.EndFadeGroup();

            using (var vertical = new EditorGUILayout.VerticalScope())
                using (new EditorGUI.PropertyScope(vertical.rect, GUIContent.none, m_SplashScreenLogos))
                {
                    m_LogoList.DoLayoutList();
                }


            EditorGUILayout.Space();

            // Background
            EditorGUILayout.LabelField(k_Texts.backgroundTitle, EditorStyles.boldLabel);
            EditorGUILayout.Slider(m_SplashScreenOverlayOpacity, Application.HasProLicense() ? k_MinProEditionOverlayOpacity : k_MinPersonalEditionOverlayOpacity, 1.0f, k_Texts.overlayOpacity);
            m_ShowBackgroundColorAnimator.target = m_SplashScreenBackgroundLandscape.objectReferenceValue == null;
            if (EditorGUILayout.BeginFadeGroup(m_ShowBackgroundColorAnimator.faded))
            {
                EditorGUILayout.PropertyField(m_SplashScreenBackgroundColor, k_Texts.backgroundColor);
            }
            EditorGUILayout.EndFadeGroup();

            EditorGUILayout.PropertyField(m_SplashScreenBlurBackground, k_Texts.blurBackground);
            EditorGUI.BeginChangeCheck();
            ObjectReferencePropertyField <Sprite>(m_SplashScreenBackgroundLandscape, k_Texts.backgroundImage);
            if (EditorGUI.EndChangeCheck() && m_SplashScreenBackgroundLandscape.objectReferenceValue == null)
            {
                m_SplashScreenBackgroundPortrait.objectReferenceValue = null;
            }

            using (new EditorGUI.DisabledScope(m_SplashScreenBackgroundLandscape.objectReferenceValue == null))
            {
                ObjectReferencePropertyField <Sprite>(m_SplashScreenBackgroundPortrait, k_Texts.backgroundPortraitImage);
            }
        }
Пример #4
0
        private void OnGUI()
        {
            FrameDebuggerEvent[] descs = FrameDebuggerUtility.GetFrameEvents();
            Initialize(descs);

            int oldLimit = FrameDebuggerUtility.limit;

            Profiler.BeginSample("DrawToolbar");
            bool repaint = m_Toolbar.DrawToolbar(this, m_AttachToPlayerState);

            Profiler.EndSample();

            if (IsDisabledInEditor)
            {
                GUI.enabled = true;
                if (!FrameDebuggerUtility.locallySupported)
                {
                    string warningMessage = (FrameDebuggerHelper.IsOnLinuxOpenGL) ? FrameDebuggerStyles.EventDetails.warningLinuxOpenGLMsg : FrameDebuggerStyles.EventDetails.warningMultiThreadedMsg;
                    EditorGUILayout.HelpBox(warningMessage, MessageType.Warning, true);
                }

                EditorGUILayout.HelpBox(FrameDebuggerStyles.EventDetails.descriptionString, MessageType.Info, true);
            }
            else
            {
                if (FrameDebugger.IsLocalEnabled())
                {
                    PlayModeView playModeView = PlayModeView.GetMainPlayModeView();
                    if (playModeView)
                    {
                        playModeView.ShowTab();
                    }
                }

                // captured frame event contents have changed, rebuild the tree data
                if (HasEventHashChanged)
                {
                    m_TreeView.m_DataSource.SetEvents(descs);
                    m_FrameEventsHash = FrameDebuggerUtility.eventsHash;
                }

                float toolbarHeight = EditorStyles.toolbar.fixedHeight;

                Rect dragRect = new Rect(m_TreeWidth, toolbarHeight, FrameDebuggerStyles.Window.k_ResizerWidth, position.height - toolbarHeight);
                dragRect    = EditorGUIUtility.HandleHorizontalSplitter(dragRect, position.width, FrameDebuggerStyles.Window.k_MinTreeWidth, FrameDebuggerStyles.Window.k_MinDetailsWidth);
                m_TreeWidth = dragRect.x;

                // Search area
                m_SearchRect       = EditorGUILayout.GetControlRect();
                m_SearchRect.width = m_TreeWidth - 5;
                DrawSearchField(m_SearchString);

                Rect listRect = new Rect(
                    0,
                    toolbarHeight + m_SearchRect.y,
                    m_TreeWidth,
                    position.height - toolbarHeight - m_SearchRect.height - 5
                    );

                Rect currentEventRect = new Rect(
                    m_TreeWidth,
                    toolbarHeight,
                    position.width - m_TreeWidth,
                    position.height - toolbarHeight
                    );

                Profiler.BeginSample("DrawTree");
                m_TreeView.m_TreeView.searchString = m_SearchString;
                m_TreeView.DrawTree(listRect);
                Profiler.EndSample();

                EditorGUIUtility.DrawHorizontalSplitter(dragRect);

                Profiler.BeginSample("DrawEvent");
                m_EventDetailsView.DrawEvent(currentEventRect, descs, m_AttachToPlayerState.connectedToTarget == ConnectionTarget.Editor);
                Profiler.EndSample();
            }

            if (repaint || oldLimit != FrameDebuggerUtility.limit)
            {
                RepaintOnLimitChange();
            }

            if (m_RepaintFrames > 0)
            {
                m_TreeView.SelectFrameEventIndex(FrameDebuggerUtility.limit);
                RepaintAllNeededThings();
                --m_RepaintFrames;
            }
        }