コード例 #1
0
        public void OnGUI()
        {
            if (!AndroidBridge.AndroidExtensionsInstalled)
            {
                AndroidLogcatUtilities.ShowAndroidIsNotInstalledMessage();
                return;
            }

            GUILayout.BeginHorizontal();
            int count;

            lock (ms_LogEntries)
            {
                count = ms_LogEntries.Length;
            }

            GUILayout.Label("Entries: " + count);
            if (GUILayout.Button("Clear"))
            {
                lock (ms_LogEntries)
                {
                    ms_LogEntries = new StringBuilder();
                }
            }

            GUILayout.EndHorizontal();
            var e = Event.current;

            if (e.type == EventType.MouseDown && e.button == 1)
            {
                var menuItems = new[] { new GUIContent("Copy All") };
                EditorUtility.DisplayCustomMenu(new Rect(e.mousePosition.x, e.mousePosition.y, 0, 0),
                                                menuItems.ToArray(), -1, MenuSelection, null);
            }

            m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition, true, true);
            GUILayout.TextArea(ms_LogEntries.ToString(), AndroidLogcatStyles.internalLogStyle,
                               GUILayout.ExpandHeight(true));
            GUILayout.EndScrollView();
        }
コード例 #2
0
        void OnGUI()
        {
            if (!AndroidBridge.AndroidExtensionsInstalled)
            {
                AndroidLogcatUtilities.ShowAndroidIsNotInstalledMessage();
                return;
            }

            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            EditorGUI.BeginChangeCheck();
            m_WindowMode = (WindowMode)GUILayout.Toolbar((int)m_WindowMode, new[] { new GUIContent("Original"), new GUIContent("Resolved"), }, "LargeButton", GUI.ToolbarButtonSize.Fixed, GUILayout.ExpandWidth(true));
            if (EditorGUI.EndChangeCheck())
            {
                SelectWindowMode(m_WindowMode);
            }

            m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
            GUI.SetNextControlName(WindowMode.ResolvedLog.ToString());
            switch (m_WindowMode)
            {
            case WindowMode.ResolvedLog:
                // Note: Not using EditorGUILayout.SelectableLabel, because scrollbars are not working correctly
                EditorGUILayout.TextArea(m_ResolvedStacktraces, AndroidLogcatStyles.resolvedStacktraceStyle, GUILayout.ExpandHeight(true));
                break;

            case WindowMode.OriginalLog:
                m_Text = EditorGUILayout.TextArea(m_Text, AndroidLogcatStyles.stacktraceStyle, GUILayout.ExpandHeight(true));
                break;
            }

            EditorGUILayout.EndScrollView();
            GUILayout.EndVertical();
            DoInfoGUI();
            GUILayout.EndHorizontal();
        }
        void OnGUI()
        {
            if (!AndroidBridge.AndroidExtensionsInstalled)
            {
                AndroidLogcatUtilities.ShowAndroidIsNotInstalledMessage();
                return;
            }

            EditorGUILayout.BeginVertical();
            GUILayout.Space(5);

            EditorGUILayout.BeginHorizontal(AndroidLogcatStyles.toolbar);

            GUIContent statusIcon = GUIContent.none;

            if (m_CaptureCount > 0)
            {
                int frame = (int)Mathf.Repeat(Time.realtimeSinceStartup * 10, 11.99f);
                statusIcon = AndroidLogcatStyles.Status.GetContent(frame);
                Repaint();
            }
            GUILayout.Label(statusIcon, AndroidLogcatStyles.StatusIcon, GUILayout.Width(30));

            EditorGUI.BeginChangeCheck();
            m_SelectedDevice = EditorGUILayout.Popup(m_SelectedDevice, m_Devices, AndroidLogcatStyles.toolbarPopup);
            if (EditorGUI.EndChangeCheck())
            {
                QueueScreenCapture();
            }

            EditorGUI.BeginDisabledGroup(m_CaptureCount > 0);
            if (GUILayout.Button("Capture", AndroidLogcatStyles.toolbarButton))
            {
                QueueScreenCapture();
            }
            EditorGUI.EndDisabledGroup();

            if (GUILayout.Button("Save...", AndroidLogcatStyles.toolbarButton))
            {
                var path = EditorUtility.SaveFilePanel("Save Screen Capture", "", Path.GetFileName(m_ImagePath), "png");
                if (!string.IsNullOrEmpty(path))
                {
                    try
                    {
                        File.Copy(m_ImagePath, path, true);
                    }
                    catch (Exception ex)
                    {
                        Debug.LogErrorFormat("Failed to save to '{0}' as '{1}'.", path, ex.Message);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(10);
            var id = GetDeviceId();

            if (string.IsNullOrEmpty(id))
            {
                EditorGUILayout.HelpBox("No valid device detected, please reopen this window after selecting proper device.", MessageType.Info);
            }
            else
            {
                if (!string.IsNullOrEmpty(m_Error))
                {
                    EditorGUILayout.HelpBox(m_Error, MessageType.Error);
                }
                else
                {
                    if (m_ImageTexture != null)
                    {
                        Rect rect = new Rect(0, kButtonAreaHeight, position.width, position.height - kButtonAreaHeight - kBottomAreaHeight);
                        GUI.DrawTexture(rect, m_ImageTexture, ScaleMode.ScaleToFit);
                    }
                }
            }
            EditorGUILayout.EndVertical();
        }
        internal void OnGUI()
        {
            if (!AndroidBridge.AndroidExtensionsInstalled)
            {
                AndroidLogcatUtilities.ShowAndroidIsNotInstalledMessage();
                return;
            }

            if (m_ApplySettings)
            {
                ApplySettings(m_Runtime.Settings);
                m_ApplySettings = false;
            }

            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal(AndroidLogcatStyles.toolbar);
            {
                ShowDuringBuildRun = GUILayout.Toggle(ShowDuringBuildRun, kAutoRunText, AndroidLogcatStyles.toolbarButton);

                HandleSelectedDeviceField();

                EditorGUI.BeginDisabledGroup(!m_StatusBar.Connected);
                HandleSelectedPackage();

                HandleSearchField();

                SetRegex(GUILayout.Toggle(m_Runtime.UserSettings.FilterIsRegularExpression, kRegexText, AndroidLogcatStyles.toolbarButton));

                EditorGUI.EndDisabledGroup();

                GUILayout.Space(kSpace);

                if (GUILayout.Button(kReconnect, AndroidLogcatStyles.toolbarButton))
                {
                    RestartLogCat();
                }
                if (GUILayout.Button(kDisconnect, AndroidLogcatStyles.toolbarButton))
                {
                    StopLogCat();
                }

                GUILayout.Space(kSpace);
                if (GUILayout.Button(kClearButtonText, AndroidLogcatStyles.toolbarButton))
                {
                    ClearLogCat();
                    Repaint();
                }

                DoToolsGUI();
            }
            EditorGUILayout.EndHorizontal();

            if (Unsupported.IsDeveloperMode())
            {
                DoDebuggingGUI();
            }

            if (DoMessageView())
            {
                Repaint();
            }

            m_MemoryViewer.DoGUI();

            if (m_StatusBar != null)
            {
                m_StatusBar.DoGUI();
            }

            EditorGUILayout.EndVertical();
        }
        void OnGUI()
        {
            if (!AndroidBridge.AndroidExtensionsInstalled)
            {
                AndroidLogcatUtilities.ShowAndroidIsNotInstalledMessage();
                return;
            }

            EditorGUILayout.BeginVertical();
            {
                EditorGUILayout.LabelField("Available devices:", EditorStyles.boldLabel);
                GUI.Box(m_DeviceScrollRect, GUIContent.none, EditorStyles.helpBox);
                m_DevicesScrollPosition = EditorGUILayout.BeginScrollView(m_DevicesScrollPosition);
                bool refreshDevices = false;
                foreach (var deviceValue in m_Runtime.DeviceQuery.Devices)
                {
                    var device = deviceValue.Value;
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(device.DisplayName, EditorStyles.label);

                    EditorGUI.BeginDisabledGroup(device.State != IAndroidLogcatDevice.DeviceState.Connected);
                    if (GUILayout.Button(" Copy IP ", GUILayout.ExpandWidth(false)))
                    {
                        m_IpString = CopyIP(device.Id);
                        EditorGUIUtility.systemCopyBuffer = m_IpString;
                        GUIUtility.keyboardControl        = 0;
                        GUIUtility.hotControl             = 0;
                        Repaint();
                    }

                    float connectButtoSize = 100.0f;
                    if (device.ConnectionType == IAndroidLogcatDevice.DeviceConnectionType.Network)
                    {
                        if (GUILayout.Button(kDisconnect, GUILayout.Width(connectButtoSize)))
                        {
                            DisconnectDevice(device);
                            refreshDevices = true;
                        }
                    }
                    else
                    {
                        if (GUILayout.Button(kConnect, GUILayout.Width(connectButtoSize)))
                        {
                            SetTCPIPAndConnectDevice(device.Id, CopyIP(device.Id), "5555");
                            refreshDevices = true;
                        }
                    }
                    EditorGUI.EndDisabledGroup();

                    var rc       = GUILayoutUtility.GetLastRect();
                    var orgColor = GUI.color;
                    GUI.color = Color.black;
                    if (Event.current.type == EventType.Repaint)
                    {
                        GUI.DrawTexture(new Rect(0, rc.y + rc.height, m_DeviceScrollRect.width, 1), EditorGUIUtility.whiteTexture);
                    }
                    GUI.color = orgColor;
                    EditorGUILayout.EndHorizontal();

                    if (refreshDevices)
                    {
                        m_Runtime.DeviceQuery.UpdateConnectedDevicesList(true);
                        GUIUtility.keyboardControl = 0;
                        GUIUtility.hotControl      = 0;
                        break;
                    }
                }
                EditorGUILayout.EndScrollView();
                if (Event.current.type == EventType.Repaint)
                {
                    m_DeviceScrollRect = GUILayoutUtility.GetLastRect();
                }
                GUILayout.Space(5);
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("IP", EditorStyles.boldLabel);
                EditorGUILayout.LabelField("Port", EditorStyles.boldLabel, GUILayout.Width(100));
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                m_IpString   = EditorGUILayout.TextField(m_IpString);
                m_PortString = EditorGUILayout.TextField(m_PortString, GUILayout.Width(100));
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();

                EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(m_IpString));
                if (GUILayout.Button("Connect"))
                {
                    Close();
                    EditorPrefs.SetString(kAndroidLogcatLastIp, m_IpString);
                    EditorPrefs.SetString(kAndroidLogcatLastPort, m_PortString);
                    ConnectDevice(m_IpString, m_PortString);
                    GUIUtility.ExitGUI();
                }
                EditorGUI.EndDisabledGroup();
                if (GUILayout.Button("Refresh Devices"))
                {
                    m_Runtime.DeviceQuery.UpdateConnectedDevicesList(false);
                }

                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();
        }