Пример #1
0
        public override void OnGUI(Rect rect)
        {
            Event current = Event.current;

            if (current.type == EventType.KeyDown && current.keyCode == KeyCode.Escape)
            {
                this.editorWindow.Close();
                GUIUtility.ExitGUI();
            }

            using (GUIHelpers.Area(rect))
            {
                using (GUIHelpers.Vertical())
                {
                    using (GUIHelpers.ScrollView(ref scroll))
                    {
                        DrawList();
                    }

                    if (m_footer != null)
                    {
                        m_footer();
                    }
                }
            }
        }
        void OnGUI()
        {
            if (!EnsureSkin())
            {
                return;
            }

            try
            {
                using (GUIHelpers.Horizontal(m_skin.inspectorBigStyle, GUILayout.Height(45.0f)))
                {
                    {
                        var r = GUILayoutUtility.GetRect(32, 32, GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false));
                        GUI.DrawTexture(r, m_skin.iconHeader);
                    }

                    using (GUIHelpers.Vertical())
                    {
                        using (GUIHelpers.Horizontal())
                        {
                            if (string.IsNullOrEmpty(m_openFilePath))
                            {
                                EditorGUILayout.LabelField(string.Format(m_skin.titleContent, BetterBuildInfo.Version), m_skin.pathStyle, GUILayout.MinWidth(1.0f));
                            }
                            else
                            {
                                EditorGUILayout.LabelField(m_openFilePath, m_skin.pathStyle, GUILayout.MinWidth(1.0f));
                            }
                        }

                        using (GUIHelpers.Horizontal())
                        {
                            var recentReports        = BuildInfoSettings.RecentReports;
                            var recentReportsOptions = recentReports
                                                       .Select(x => x.Replace("/", Skin.MenuSafeSlash)).ToArray();

                            if (GUIHelpers.ButtonWithDropdownList(m_skin.openReportContent, recentReportsOptions,
                                                                  x => OpenFile(recentReports[(int)x]), GUILayout.Width(130)))
                            {
                                OpenFile();
                            }

                            using (GUIHelpers.Enabled(m_buildInfo != null))
                            {
                                if (GUIHelpers.ButtonWithDropdownList(m_skin.openReportRefenceContent, recentReportsOptions,
                                                                      x => OpenReferenceFile(recentReports[(int)x]), GUILayout.Width(130)))
                                {
                                    OpenReferenceFile();
                                }
                            }

                            {
                                var rect = GUILayoutUtility.GetRect(m_skin.optionsContent, GUI.skin.button, GUILayout.Width(130));
                                if (GUI.Button(rect, m_skin.optionsContent, GUI.skin.button))
                                {
                                    GUIContent[] options = new[]
                                    {
                                        m_skin.openSettingsContent,
                                        m_skin.reloadSettingsContent,
                                    };

                                    EditorUtility.DisplayCustomMenu(rect, options, -1,
                                                                    (userData, opts, selected) =>
                                    {
                                        if (selected == 0)
                                        {
                                            EditorWindow.GetWindow(typeof(Editor).Assembly.GetType("UnityEditor.InspectorWindow")).Show(true);
                                            BuildInfoSettings.EnsureAsset();
                                            EditorGUIUtility.PingObject(Settings);
                                            Selection.activeObject = Settings;
                                        }
                                        else if (selected == 1)
                                        {
                                            m_error        = null;
                                            m_needsRefresh = true;
                                        }
                                    },
                                                                    null);
                                }
                            }

                            if (!EditorPrefs.GetBool("BBI_LeaveReviewDismissed", false))
                            {
                                if (GUIHelpers.ButtonWithDropdownList(m_skin.reviewContent, new[] { m_skin.openStorePageContent, m_skin.dismissContent }, x =>
                                {
                                    if ((int)x == 0)
                                    {
                                        Help.BrowseURL(m_skin.storeUrl);
                                    }
                                    else
                                    {
                                        EditorPrefs.SetBool("BBI_LeaveReviewDismissed", true);
                                    }
                                }, GUILayout.Width(130)
                                                                      ))
                                {
                                    Help.BrowseURL(m_skin.storeUrl);
                                }
                            }

                            GUILayout.FlexibleSpace();

                            {
                                if (GUILayout.Button("*****@*****.**", EditorStyles.miniLabel))
                                {
                                    Help.BrowseURL("mailto:[email protected]?subject=BetterBuildInfo");
                                }
                            }
                        }


                        //if (!EditorPrefs.HasKey("BBI_LeaveReviewDismissed"))
                        //{
                        //    EditorGUILayout.Space();
                        //    using (GUIHelpers.Horizontal())
                        //    {
                        //        GUILayout.Label("<b>If you enjoy the tool, please leave a review:</b>", m_skin.changelogStyle);
                        //        if (GUILayout.Button("Yes", EditorStyles.miniButton))
                        //        {
                        //            Help.BrowseURL("https://assetstore.unity.com/packages/tools/utilities/better-build-info-pro-report-tool-72579");
                        //            EditorPrefs.SetBool("BBI_LeaveReviewDismissed", true);
                        //        }
                        //        if (GUILayout.Button("Don't show this again", EditorStyles.miniButton))
                        //        {
                        //            EditorPrefs.SetBool("BBI_LeaveReviewDismissed", true);
                        //        }
                        //        GUILayout.FlexibleSpace();
                        //    }
                        //}
                    }
                }

                if (string.IsNullOrEmpty(m_openFilePath))
                {
                    DoStartScreenGUI();
                }
                else
                {
                    DoBuildInfoGUI();
                }
            }
            catch (UnityEngine.ExitGUIException)
            {
                // don't log it, just rethrow
                throw;
            }
            catch (System.Exception ex)
            {
                Debug.LogException(ex);
                m_error = ex;
            }

            if (m_error != null)
            {
                try
                {
                    EditorGUILayout.HelpBox("There was an error: " + m_error.Message + "\nCheck console for details.", MessageType.Error);
                }
                catch (System.Exception) { }
            }
        }