Example #1
0
        static void AddPlayerProfilers(List <ProfilerChoise> profilers)
        {
            int[] connectionGuids = ProfilerDriver.GetAvailableProfilers();
            for (int index = 0; index < connectionGuids.Length; index++)
            {
                int    guid         = connectionGuids[index];
                string name         = ProfilerDriver.GetConnectionIdentifier(guid);
                bool   isProhibited = ProfilerDriver.IsIdentifierOnLocalhost(guid) && name.Contains("MetroPlayerX");
                bool   enabled      = !isProhibited && ProfilerDriver.IsIdentifierConnectable(guid);

                if (!enabled)
                {
                    if (isProhibited)
                    {
                        name += " (Localhost prohibited)";
                    }
                    else
                    {
                        name += " (Version mismatch)";
                    }
                }

                profilers.Add(new ProfilerChoise()
                {
                    Name       = name,
                    Enabled    = enabled,
                    IsSelected = () => { return(ProfilerDriver.connectedProfiler == guid); },
                    ConnectTo  = () => { ProfilerDriver.connectedProfiler = guid; }
                });
            }
        }
 private static void AddPlayerProfilers(List <ProfilerChoise> profilers)
 {
     int[] availableProfilers = ProfilerDriver.GetAvailableProfilers();
     for (int i = 0; i < availableProfilers.Length; i++)
     {
         int    guid  = availableProfilers[i];
         string text  = ProfilerDriver.GetConnectionIdentifier(guid);
         bool   flag  = ProfilerDriver.IsIdentifierOnLocalhost(guid) && text.Contains("MetroPlayerX");
         bool   flag2 = !flag && ProfilerDriver.IsIdentifierConnectable(guid);
         if (!flag2)
         {
             if (flag)
             {
                 text += " (Localhost prohibited)";
             }
             else
             {
                 text += " (Version mismatch)";
             }
         }
         profilers.Add(new ProfilerChoise
         {
             Name       = text,
             Enabled    = flag2,
             IsSelected = () => ProfilerDriver.connectedProfiler == guid,
             ConnectTo  = delegate
             {
                 ProfilerDriver.connectedProfiler = guid;
             }
         });
     }
 }
Example #3
0
 private void DoActiveProfilerButton(Rect position)
 {
     if (EditorGUI.ButtonMouseDown(position, new GUIContent("Active Profler"), FocusType.Native, EditorStyles.toolbarDropDown))
     {
         int connectedProfiler = ProfilerDriver.connectedProfiler;
         this.connectionGuids = ProfilerDriver.GetAvailableProfilers();
         int      num    = this.connectionGuids.Length;
         int[]    array  = new int[1];
         bool[]   array2 = new bool[num];
         string[] array3 = new string[num];
         for (int i = 0; i < num; i++)
         {
             int  num2 = this.connectionGuids[i];
             bool flag = ProfilerDriver.IsIdentifierConnectable(num2);
             array2[i] = flag;
             string text = ProfilerDriver.GetConnectionIdentifier(num2);
             if (!flag)
             {
                 text += " (Version mismatch)";
             }
             array3[i] = text;
             if (num2 == connectedProfiler)
             {
                 array[0] = i;
             }
         }
         EditorUtility.DisplayCustomMenu(position, array3, array2, array, new EditorUtility.SelectMenuItemFunction(this.SelectProfilerClick), null);
     }
 }
Example #4
0
        private void DoActiveProfilerButton(Rect position)
        {
            if (!EditorGUI.ButtonMouseDown(position, new GUIContent("Active Profler"), FocusType.Native, EditorStyles.toolbarDropDown))
            {
                return;
            }
            int connectedProfiler = ProfilerDriver.connectedProfiler;

            this.connectionGuids = ProfilerDriver.GetAvailableProfilers();
            int length = this.connectionGuids.Length;

            int[]    selected = new int[1];
            bool[]   enabled  = new bool[length];
            string[] options  = new string[length];
            for (int index = 0; index < length; ++index)
            {
                int  connectionGuid = this.connectionGuids[index];
                bool flag           = ProfilerDriver.IsIdentifierConnectable(connectionGuid);
                enabled[index] = flag;
                string connectionIdentifier = ProfilerDriver.GetConnectionIdentifier(connectionGuid);
                if (!flag)
                {
                    connectionIdentifier += " (Version mismatch)";
                }
                options[index] = connectionIdentifier;
                if (connectionGuid == connectedProfiler)
                {
                    selected[0] = index;
                }
            }
            EditorUtility.DisplayCustomMenu(position, options, enabled, selected, new EditorUtility.SelectMenuItemFunction(this.SelectProfilerClick), (object)null);
        }
 private static void AddPlayerProfilers(List <ProfilerChoise> profilers)
 {
     foreach (int availableProfiler in ProfilerDriver.GetAvailableProfilers())
     {
         // ISSUE: object of a compiler-generated type is created
         // ISSUE: variable of a compiler-generated type
         AttachProfilerUI.\u003CAddPlayerProfilers\u003Ec__AnonStoreyA8 profilersCAnonStoreyA8 = new AttachProfilerUI.\u003CAddPlayerProfilers\u003Ec__AnonStoreyA8();
         // ISSUE: reference to a compiler-generated field
         profilersCAnonStoreyA8.guid = availableProfiler;
         // ISSUE: reference to a compiler-generated field
         string str = ProfilerDriver.GetConnectionIdentifier(profilersCAnonStoreyA8.guid);
         // ISSUE: reference to a compiler-generated field
         bool flag1 = ProfilerDriver.IsIdentifierOnLocalhost(profilersCAnonStoreyA8.guid) && str.Contains("MetroPlayerX");
         // ISSUE: reference to a compiler-generated field
         bool flag2 = !flag1 && ProfilerDriver.IsIdentifierConnectable(profilersCAnonStoreyA8.guid);
         if (!flag2)
         {
             str = !flag1 ? str + " (Version mismatch)" : str + " (Localhost prohibited)";
         }
         // ISSUE: reference to a compiler-generated method
         // ISSUE: reference to a compiler-generated method
         profilers.Add(new ProfilerChoise()
         {
             Name       = str,
             Enabled    = flag2,
             IsSelected = new Func <bool>(profilersCAnonStoreyA8.\u003C\u003Em__1EB),
             ConnectTo  = new System.Action(profilersCAnonStoreyA8.\u003C\u003Em__1EC)
         });
     }
 }
Example #6
0
 static void SetupProfiledConnection(int connId)
 {
     ProfilerDriver.connectedProfiler = ProfilerDriver.GetAvailableProfilers().FirstOrDefault(id => id == connId);
     Menu.SetChecked("Edit/Record", s_SlaveProfilerWindow.IsRecording());
     Menu.SetChecked("Edit/Deep Profiling", ProfilerDriver.deepProfiling);
     EditorApplication.UpdateMainWindowTitle();
     s_SlaveProfilerWindow.Repaint();
 }
Example #7
0
 static void SetupProfiledConnection(int connId, bool recording, bool isPlaying)
 {
     ProfilerDriver.connectedProfiler = ProfilerDriver.GetAvailableProfilers().FirstOrDefault(id => id == connId);
     ProfilerDriver.profileEditor     = !isPlaying;
     s_SlaveProfilerWindow.SetRecordingEnabled(recording);
     s_SlaveProfilerWindow.Repaint();
     EditorApplication.UpdateMainWindowTitle();
 }
Example #8
0
        private static void DrawConnectionGUI()
        {
            if (GUILayout.Button("Remote Devices…", EditorStyles.toolbarDropDown))
            {
                var menu        = new GenericMenu();
                var haveRemotes = InputSystem.devices.Any(x => x.remote);
                if (EditorConnection.instance.ConnectedPlayers.Count > 0)
                {
                    menu.AddItem(new GUIContent("Show remote devices"), haveRemotes, () =>
                    {
                        EnableRemoteDevices(!haveRemotes);
                    });
                }
                else
                {
                    menu.AddDisabledItem(new GUIContent("Show remote input devices"));
                }

                menu.AddSeparator("");

                var availableProfilers = ProfilerDriver.GetAvailableProfilers();
                foreach (var profiler in availableProfilers)
                {
                    var enabled      = ProfilerDriver.IsIdentifierConnectable(profiler);
                    var profilerName = ProfilerDriver.GetConnectionIdentifier(profiler);
                    var isConnected  = ProfilerDriver.connectedProfiler == profiler;
                    if (enabled)
                    {
                        menu.AddItem(new GUIContent(profilerName), isConnected, () => {
                            ProfilerDriver.connectedProfiler = profiler;
                            EnableRemoteDevices();
                        });
                    }
                    else
                    {
                        menu.AddDisabledItem(new GUIContent(profilerName));
                    }
                }

                foreach (var device in UnityEditor.Hardware.DevDeviceList.GetDevices())
                {
                    var supportsPlayerConnection = (device.features & UnityEditor.Hardware.DevDeviceFeatures.PlayerConnection) != 0;
                    if (!device.isConnected || !supportsPlayerConnection)
                    {
                        continue;
                    }

                    var url         = "device://" + device.id;
                    var isConnected = ProfilerDriver.connectedProfiler == 0xFEEE && ProfilerDriver.directConnectionUrl == url;
                    menu.AddItem(new GUIContent(device.name), isConnected, () => {
                        ProfilerDriver.DirectURLConnect(url);
                        EnableRemoteDevices();
                    });
                }

                menu.ShowAsContext();
            }
        }
        void AddAvailablePlayerConnections(GenericMenu menuOptions, ref bool hasOpenConnection)
        {
            int[] connectionGuids = ProfilerDriver.GetAvailableProfilers();
            for (int index = 0; index < connectionGuids.Length; index++)
            {
                int    guid         = connectionGuids[index];
                string name         = ProfilerDriver.GetConnectionIdentifier(guid);
                bool   isProhibited = ProfilerDriver.IsIdentifierOnLocalhost(guid) && (name.Contains("MetroPlayerX") || name.Contains("UWPPlayerX"));
                bool   enabled      = !isProhibited && ProfilerDriver.IsIdentifierConnectable(guid);

                bool isConnected = ProfilerDriver.connectedProfiler == guid;
                hasOpenConnection |= isConnected;
                if (!enabled)
                {
                    if (isProhibited)
                    {
                        name += Content.LocalHostProhibited;
                    }
                    else
                    {
                        name += Content.VersionMismatch;
                    }
                }
                if (enabled)
                {
                    if (m_EditorModeTargetState.HasValue && name.Contains(k_EditorConnectionName))
                    {
                        menuOptions.AddItem(Content.Playmode, isConnected && !m_EditorModeTargetConnectionStatus(EditorConnectionTarget.MainEditorProcessPlaymode), () =>
                        {
                            ProfilerDriver.connectedProfiler = guid;
                            SuccessfullyConnectedToPlayer(connectionName, EditorConnectionTarget.MainEditorProcessPlaymode);
                        });
                        menuOptions.AddItem(Content.Editmode, isConnected && m_EditorModeTargetConnectionStatus(EditorConnectionTarget.MainEditorProcessEditmode), () =>
                        {
                            ProfilerDriver.connectedProfiler = guid;
                            SuccessfullyConnectedToPlayer(connectionName, EditorConnectionTarget.MainEditorProcessEditmode);
                        });
                    }
                    else
                    {
                        menuOptions.AddItem(new GUIContent(name), isConnected, () =>
                        {
                            ProfilerDriver.connectedProfiler = guid;
                            if (ProfilerDriver.connectedProfiler == guid)
                            {
                                SuccessfullyConnectedToPlayer(connectionName);
                            }
                        });
                    }
                }
                else
                {
                    menuOptions.AddDisabledItem(new GUIContent(name), isConnected);
                }
            }
        }
Example #10
0
    private void SaveProfileResult(string target, int firstFrameIdx, int lastFrameIdx)
    {
        StringBuilder sb = new StringBuilder();

        ProfilerDriver.GetAvailableProfilers();

        sb.Append(target).Append("_").Append(firstFrameIdx).Append("-").Append(lastFrameIdx).Append(".data");
        lastSaveFile = sb.ToString();

        string path = System.IO.Path.Combine(saveDir, lastSaveFile);

        ProfilerDriver.SaveProfile(path);
    }
        void AddAvailablePlayerConnections(ConnectionTreeViewWindow menuOptions, ref bool hasOpenConnection,
                                           Func <bool> disabler = null)
        {
            int[] connectionGuids = ProfilerDriver.GetAvailableProfilers();
            for (int index = 0; index < connectionGuids.Length; index++)
            {
                int    guid         = connectionGuids[index];
                string name         = GetConnectionName(guid);
                bool   isProhibited = ProfilerDriver.IsIdentifierOnLocalhost(guid) && (name.Contains("MetroPlayerX") || name.Contains("UWPPlayerX"));
                bool   enabled      = !isProhibited && ProfilerDriver.IsIdentifierConnectable(guid);

                bool isConnected = ProfilerDriver.connectedProfiler == guid;
                hasOpenConnection |= isConnected;
                if (!enabled)
                {
                    if (isProhibited)
                    {
                        name += Content.LocalHostProhibited;
                    }
                    else
                    {
                        name += Content.VersionMismatch;
                    }
                }
                if (enabled)
                {
                    if (m_EditorModeTargetState.HasValue && name.Contains(k_EditorConnectionName))
                    {
                        if (!menuOptions.HasItem(Content.Playmode.text) && !name.StartsWith("Profiler-"))
                        {
                            menuOptions.AddItem(new ConnectionDropDownItem(Content.Playmode.text, guid, Content.Editor,
                                                                           ConnectionDropDownItem.ConnectionMajorGroup.Editor,
                                                                           () => ProfilerDriver.connectedProfiler == guid &&
                                                                           !m_EditorModeTargetConnectionStatus(EditorConnectionTarget
                                                                                                               .MainEditorProcessPlaymode),
                                                                           () =>
                            {
                                ProfilerDriver.connectedProfiler = guid;
                                SuccessfullyConnectedToPlayer(connectionName,
                                                              EditorConnectionTarget.MainEditorProcessPlaymode);
                            }));

                            menuOptions.AddItem(new ConnectionDropDownItem(Content.Editmode.text, guid, Content.Editor,
                                                                           ConnectionDropDownItem.ConnectionMajorGroup.Editor,
                                                                           () => ProfilerDriver.connectedProfiler == guid &&
                                                                           m_EditorModeTargetConnectionStatus(EditorConnectionTarget
                                                                                                              .MainEditorProcessEditmode),
                                                                           () =>
                            {
                                ProfilerDriver.connectedProfiler = guid;
                                SuccessfullyConnectedToPlayer(connectionName,
                                                              EditorConnectionTarget.MainEditorProcessEditmode);
                            }));
                        }
                    }
                    else
                    {
                        menuOptions.AddItem(new ConnectionDropDownItem(
                                                name, guid, null, ConnectionDropDownItem.ConnectionMajorGroup.Unknown,
                                                () => ProfilerDriver.connectedProfiler == guid,
                                                () =>
                        {
                            ProfilerDriver.connectedProfiler = guid;
                            if (ProfilerDriver.connectedProfiler == guid)
                            {
                                SuccessfullyConnectedToPlayer(connectionName);
                            }
                        }));
                    }
                }
                else
                {
                    menuOptions.AddDisabledItem(new ConnectionDropDownItem(name, guid, null, ConnectionDropDownItem.ConnectionMajorGroup.Unknown, () => ProfilerDriver.connectedProfiler == guid, null));
                }
            }
        }
Example #12
0
        void OnGUI()
        {
            Init();
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            //string[] array3 = new string[] { "Editor", "F****r", "Sucker" };

            if (GUILayout.Button(new GUIContent("Active Profler"), EditorStyles.toolbarDropDown))
            {
                Rect titleRect2 = EditorGUILayout.GetControlRect();
                titleRect2.y   += EditorStyles.toolbarDropDown.fixedHeight;
                connectionGuids = ProfilerDriver.GetAvailableProfilers();
                GUIContent[] guiContents = new GUIContent[connectionGuids.Length];
                for (int i = 0; i < connectionGuids.Length; i++)
                {
                    if (connectionGuids[i] == ProfilerDriver.connectedProfiler)
                    {
                        selectedIndex = i;
                    }
                    bool   flag = ProfilerDriver.IsIdentifierConnectable(connectionGuids[i]);
                    string text = ProfilerDriver.GetConnectionIdentifier(connectionGuids[i]);
                    if (!flag)
                    {
                        text += " (Version mismatch)";//I don't know what this means...
                    }
                    guiContents[i] = new GUIContent(text);
                }
                EditorUtility.DisplayCustomMenu(titleRect2, guiContents, selectedIndex, OnSelectProfilerClick, null);
            }
            //EditorGUILayout.Popup(selectedIndex, array3, EditorStyles.toolbarPopup);

            if (GUILayout.Button("Take Sample: " + ProfilerDriver.GetConnectionIdentifier(ProfilerDriver.connectedProfiler), EditorStyles.toolbarButton))
            {
                //ProfilerDriver.ClearAllFrames();
                //ProfilerDriver.deepProfiling = true;
                ShowNotification(new GUIContent("Waiting for device..."));
                MemorySnapshot.RequestNewSnapshot();
            }
            if (GUILayout.Button(new GUIContent("Clear Editor References", "Design for profile in editor.\nEditorUtility.UnloadUnusedAssetsImmediate() can be called."), EditorStyles.toolbarButton))
            {
                ClearEditorReferences();
            }
            GUILayout.FlexibleSpace();
            //GUILayout.Space(5);
            EditorGUILayout.EndHorizontal();



            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Save Snapshot", EditorStyles.toolbarButton))
            {
                if (data.mSnapshot != null)
                {
                    string filePath = EditorUtility.SaveFilePanel("Save Snapshot", null, "MemorySnapshot" + System.DateTime.Now.ToString("_MMdd_HHmm"), "memsnap");
                    if (!string.IsNullOrEmpty(filePath))
                    {
                        System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                        using (Stream stream = File.Open(filePath, FileMode.Create))
                        {
                            bf.Serialize(stream, data.mSnapshot);
                        }
                    }
                }
                else
                {
                    Debug.LogWarning("No snapshot to save.  Try taking a snapshot first.");
                }
            }
            if (GUILayout.Button("Load Snapshot", EditorStyles.toolbarButton))
            {
                string filePath = EditorUtility.OpenFilePanel("Load Snapshot", null, "memsnap");
                if (!string.IsNullOrEmpty(filePath))
                {
                    System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    using (Stream stream = File.Open(filePath, FileMode.Open))
                    {
                        IncomingSnapshot(bf.Deserialize(stream) as PackedMemorySnapshot);
                    }
                }
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Save Snapshot as .txt", EditorStyles.toolbarButton))
            {
                if (memoryRootNode != null)
                {
                    string filePath = EditorUtility.SaveFilePanel("Save Snapshot as .txt", null, "Mindmap" + System.DateTime.Now.ToString("_MMdd_HHmm"), "txt");
                    if (!string.IsNullOrEmpty(filePath))
                    {
                        SaveToMindMap(filePath);
                    }
                }
                else
                {
                    Debug.LogWarning("No snapshot to save.  Try taking a snapshot first.");
                }
            }
            if (GUILayout.Button("Load Snapshot from .txt", EditorStyles.toolbarButton))
            {
                string filePath = EditorUtility.OpenFilePanel("Load Snapshot from .txt", null, "txt");
                if (!string.IsNullOrEmpty(filePath))
                {
                    LoadFromMindMap(filePath);
                }
            }
            canSaveDetails = GUILayout.Toggle(canSaveDetails, "saveDetails");
            savedMinSize   = EditorGUILayout.IntField("minSize", savedMinSize, EditorStyles.toolbarTextField);
            if (savedMinSize < 0)
            {
                savedMinSize = 0;
            }
            EditorGUILayout.EndHorizontal();
            //Top tool bar end...


            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            memoryFilters = EditorGUILayout.ObjectField(memoryFilters, typeof(MemoryFilterSettings), false) as MemoryFilterSettings;
            //if (GUILayout.Button(new GUIContent("Save as plist/xml", "TODO in the future..."), EditorStyles.toolbarButton))
            //{
            //}
            //if (GUILayout.Button(new GUIContent("Load plist/xml", "TODO in the future..."), EditorStyles.toolbarButton))
            //{
            //}
            GUILayout.FlexibleSpace();
            GUILayout.Label(new GUIContent("[LastRefreshTime]" + lastRefreshTime.ToShortTimeString(),
                                           " enter / exit play mode or change a script,Unity has to reload the mono assemblies , and the GoProfilerWindow has to Refresh immediately"));
            if (GUILayout.Button(EditorGUIUtility.IconContent("TreeEditor.Refresh"), EditorStyles.toolbarButton, GUILayout.Width(30)))
            {
                IncomingSnapshot(data.mSnapshot);
                Repaint();
            }
            EditorGUILayout.EndHorizontal();
            if (!memoryFilters)
            {
                EditorGUILayout.HelpBox("Please Select a MemoryFilters object or load it from the .plist/.xml file", MessageType.Warning);
            }

            //TODO: handle the selected object.
            //EditorGUILayout.HelpBox("Watching Texture Detail Data is only for Editor.", MessageType.Warning, true);
            if (selectedObject != null && selectedObject.childList.Count == 0)
            {
                if (selectedObject != null && _prevInstance != selectedObject.instanceID)
                {
                    objectField   = EditorUtility.InstanceIDToObject(selectedObject.instanceID);
                    _prevInstance = selectedObject.instanceID;
                    //Selection.instanceIDs = new int[] { selectedObject.instanceID }; //Hide in inspector.
                }
            }
            if (objectField != null)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Selected Object Info:");
                EditorGUILayout.ObjectField(objectField, objectField.GetType(), true);
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                EditorGUILayout.LabelField("Can't instance object,maybe it was already released.");
            }
            //MemoryFilters end...

            Rect titleRect = EditorGUILayout.GetControlRect();

            EditorGUI.DrawRect(titleRect, new Color(0.15f, 0.15f, 0.15f, 1));
            EditorGUI.DrawRect(new Rect(titleRect.x + titleRect.width - 200, titleRect.y, 1, Screen.height), new Color(0.15f, 0.15f, 0.15f, 1));
            EditorGUI.DrawRect(new Rect(titleRect.x + titleRect.width - 100, titleRect.y, 1, Screen.height), new Color(0.15f, 0.15f, 0.15f, 1));
            GUI.Label(new Rect(titleRect.x, titleRect.y, titleRect.width - 200, titleRect.height), "Name", toolBarStyle);
            GUI.Label(new Rect(titleRect.x + titleRect.width - 175, titleRect.y, 50, titleRect.height), "Size", toolBarStyle);
            GUI.Label(new Rect(titleRect.x + titleRect.width - 75, titleRect.y, 50, titleRect.height), "RefCount", toolBarStyle);
            //Title bar end...

            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
            if (memoryRootNode != null && memoryRootNode.childList != null)
            {
                memoryRootNode.DrawGUI(0);
            }
            else
            {
                Init();
            }
            GUILayout.EndScrollView();
            //Contents end...
            //handle the select event to Repaint
            if (Event.current.type == EventType.mouseDown)
            {
                Repaint();
            }
        }