Пример #1
0
        public void AddItem(ConnectionDropDownItem connectionDropDownItem)
        {
            // *begin-nonstandard-formatting*
            connectionItems ??= new List <ConnectionDropDownItem>();
            // *end-nonstandard-formatting*
            // this is a hack to show switch connected over ethernet in devices
            if (connectionDropDownItem.IP == "127.0.0.1" && ProfilerDriver.GetConnectionIdentifier(connectionDropDownItem.m_ConnectionId).StartsWith("Switch"))
            {
                connectionDropDownItem.m_TopLevelGroup = ConnectionDropDownItem.ConnectionMajorGroup.Local;
                connectionDropDownItem.m_SubGroup      = "Devices";
                connectionDropDownItem.IsDevice        = true;
                connectionDropDownItem.IconContent     = ConnectionUIHelper.GetIcon("Switch");
                var fullName = ProfilerDriver.GetConnectionIdentifier(connectionDropDownItem.m_ConnectionId);
                var start    = fullName.IndexOf('-') + 1;
                var end      = fullName.IndexOf('(');
                connectionDropDownItem.DisplayName = $"{fullName.Substring(start, end - start)} - {ProfilerDriver.GetProjectName(connectionDropDownItem.m_ConnectionId)}";
            }

            var dupes = connectionItems.FirstOrDefault(x => x.DisplayName == connectionDropDownItem.DisplayName && x.IP == connectionDropDownItem.IP && x.Port == connectionDropDownItem.Port);

            if (dupes != null)
            {
                connectionItems.Remove(dupes);
            }

            connectionItems.Add(connectionDropDownItem);
        }
Пример #2
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);
        }
Пример #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);
     }
 }
Пример #4
0
 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)
         });
     }
 }
Пример #5
0
        private void SelectProfilerClick(object userData, string[] options, int selected)
        {
            int num = this.connectionGuids[selected];

            this.lastOpenedProfiler          = ProfilerDriver.GetConnectionIdentifier(num);
            ProfilerDriver.connectedProfiler = num;
        }
Пример #6
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; }
                });
            }
        }
Пример #7
0
        internal static string GetConnectionName(int guid)
        {
            // Connection identifier is constructed in the PlayerConnection::ConstructWhoamiString()
            // in a form "{platform name}(host name or ip)[:port]
            var name = ProfilerDriver.GetConnectionIdentifier(guid);

            // Ignore Editor connections which named explicitly after project name.
            var portSpacerIndex = name.LastIndexOf(')');

            if (portSpacerIndex == -1)
            {
                return(name);
            }

            // Port already specified
            if (name.Length > (portSpacerIndex + 1) && name[portSpacerIndex + 1] == ':')
            {
                return(name);
            }

            // If port hasn't been specified in the connection identifier, we place it with "host name or ip" segment.
            var port = ProfilerDriver.GetConnectionPort(guid);

            return(string.Format("{0}:{1})", name.Substring(0, portSpacerIndex), port));
        }
 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;
             }
         });
     }
 }
    private void OnGUI()
    {
        EditorGUILayout.BeginVertical();

        EditorGUILayout.LabelField("Current Target: " + ProfilerDriver.GetConnectionIdentifier(ProfilerDriver.connectedProfiler));

        if (GUILayout.Button("Take Sample"))
        {
            TakeSample();
        }

        _memorySize  = EditorGUILayout.FloatField("Memory Size(MB) >= ", _memorySize);
        _memoryDepth = EditorGUILayout.IntField("Memory Depth(>=1)", _memoryDepth);

        if (GUILayout.Button("Extract Memory"))
        {
            if (_memoryDepth <= 0)
            {
                _memoryDepth = 1;
            }
            ExtractMemory(_memorySize, _memoryDepth - 1);
        }

        EditorGUILayout.BeginVertical();
    }
Пример #10
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();
            }
        }
Пример #11
0
        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);
                }
            }
        }
Пример #12
0
        public static void StartCapture()
        {
            Capturing = true;
            Capture   = new ProfilerAnalyticsCapture();

            Capture.callStacksEnabled  = Profiler.enableAllocationCallstacks;
            Capture.deepProfileEnabled = ProfilerDriver.deepProfiling;
            Capture.connectionName     = ProfilerDriver.GetConnectionIdentifier(ProfilerDriver.connectedProfiler);
            Capture.platformName       = ProfilerDriver.profileEditor ? "Editor" : "";
        }
Пример #13
0
    private void OnGUIRecordMode()
    {
        if (GUILayout.Button("Clear Profiler", GUILayout.Width(120)))
        {
            ProfilerDriver.ClearAllFrames();
            ClearRecordData();
            this.CallProfilerWindow();
        }

        EditorGUILayout.LabelField("Current Target:" + ProfilerDriver.GetConnectionIdentifier(ProfilerDriver.connectedProfiler));


        if (!string.IsNullOrEmpty(lastSaveFile))
        {
            EditorGUILayout.LabelField("Last save:" + lastSaveFile);
        }
    }
Пример #14
0
        public static void SendConnectionEvent(ProfilerAnalyticsConnectionData data)
        {
            if (!EditorAnalytics.enabled)
            {
                return;
            }

            if (data.success)
            {
                data.connectionDetail = ProfilerDriver.GetConnectionIdentifier(ProfilerDriver.connectedProfiler);
            }

            if (!profilerConnectionRegistered)
            {
                profilerConnectionRegistered = RegisterEvent(k_ProfilerConnection);
            }

            EditorAnalytics.SendEventWithLimit(k_ProfilerConnection, data);
        }
Пример #15
0
        private void LogMessage(MessageEventArgs messageEventArgs)
        {
            byte[]  bytes   = messageEventArgs.data.Skip(4).ToArray <byte>();
            string  text    = Encoding.UTF8.GetString(bytes);
            LogType logType = (LogType)messageEventArgs.data[0];

            if (!Enum.IsDefined(typeof(LogType), logType))
            {
                logType = LogType.Log;
            }
            StackTraceLogType stackTraceLogType = Application.GetStackTraceLogType(logType);

            Application.SetStackTraceLogType(logType, StackTraceLogType.None);
            string connectionIdentifier = ProfilerDriver.GetConnectionIdentifier(messageEventArgs.playerId);

            text = "<i>" + connectionIdentifier + "</i> " + text;
            Debug.unityLogger.Log(logType, text);
            Application.SetStackTraceLogType(logType, stackTraceLogType);
        }
Пример #16
0
    private void UpdateInterlPolling()
    {
        if (string.IsNullOrEmpty(saveDir))
        {
            return;
        }
        string target        = ProfilerDriver.GetConnectionIdentifier(ProfilerDriver.connectedProfiler).Replace('.', '_').Replace('@', '_').Replace(':', '_');
        int    firstFrameIdx = ProfilerDriver.firstFrameIndex;
        int    lastFrameIdx  = ProfilerDriver.lastFrameIndex;

        // update
        if (target == EditorIdentifier)
        {
            if (IsEditorStopPlaying())
            {
                ++stopPlayingCount;
            }
            else
            {
                stopPlayingCount = 0;
            }
        }

        // cleared Profiler History
        if (lastFrameIdx < savedCondition.lastIndex)
        {
            savedCondition.Clear();
        }

        if (ShouldSaveResult(target, firstFrameIdx, lastFrameIdx))
        {
            SaveProfileResult(lastTarget, firstFrameIdx, lastFrameIdx);
            this.savedCondition.SetData(target, firstFrameIdx, lastFrameIdx);
            this.Repaint();
        }
        if (this.lastTarget != target)
        {
            this.Repaint();
        }
        this.lastTarget = target;
    }
        void LogMessage(MessageEventArgs messageEventArgs)
        {
            var    body = messageEventArgs.data.Skip(4).ToArray();
            string text = System.Text.Encoding.UTF8.GetString(body);

            var logType = (LogType)messageEventArgs.data[0];

            if (!Enum.IsDefined(typeof(LogType), logType))
            {
                logType = LogType.Log;
            }
            var oldStackTraceType = Application.GetStackTraceLogType(logType);

            // We don't want stack traces from editor code in player log messages.
            Application.SetStackTraceLogType(logType, StackTraceLogType.None);

            string name = ProfilerDriver.GetConnectionIdentifier(messageEventArgs.playerId);

            text = "<i>" + name + "</i> " + text;
            Debug.unityLogger.Log(logType, text);
            Application.SetStackTraceLogType(logType, oldStackTraceType);
        }
    private void ExtractMemory(float memSize, int memDepth)
    {
        var filterSize = memSize * 1024 * 1024;
        var parent     = Directory.GetParent(Application.dataPath);
        var outputPath = string.Format("{0}/MemoryDetailed{1:yyyy_MM_dd_HH_mm_ss}.txt", parent.FullName, DateTime.Now);

        File.Create(outputPath).Dispose();
        _memoryElementRoot = ProfilerWindow.GetMemoryDetailRoot(memDepth, filterSize);

        if (null != _memoryElementRoot)
        {
            var writer = new StreamWriter(outputPath);
            writer.WriteLine("Memory Size: >= {0}MB", _memorySize);
            writer.WriteLine("Memory Depth: {0}", _memoryDepth);
            writer.WriteLine("Current Target: {0}", ProfilerDriver.GetConnectionIdentifier(ProfilerDriver.connectedProfiler));
            writer.WriteLine("**********************");
            ProfilerWindow.WriteMemoryDetail(writer, _memoryElementRoot);
            writer.Flush();
            writer.Close();
        }

        Process.Start(outputPath);
    }
Пример #19
0
        public void Request(CaptureFlag flag, System.Action callback)
        {
            if (this.IsRunning)
            {
                return;
            }
            this.captureFlag = flag;
            this.IsRunning   = true;

            this.savedRenderTexture.Clear();
            this.alreadyWriteTextureDict.Clear();
            this.renderTextureLastChanged.Clear();


            var date         = System.DateTime.Now;
            var dateString   = string.Format("{0:D4}{1:D2}{2:D2}_{3:D2}{4:D2}{5:D2}_", date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second);
            var profilerName = ProfilerDriver.GetConnectionIdentifier(ProfilerDriver.connectedProfiler);

            this.saveDirectory = RootSaveDir + "/" + dateString + profilerName;
            System.IO.Directory.CreateDirectory(saveDirectory);

            endCallback = callback;
            EditorApplication.update += Update;
        }
Пример #20
0
        void OnGUI()
        {
            //if put these code to OnEnable function,the EditorStyles.boldLabel is null , and everything is wrong.
            //Debug.Log("ONGUI");
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            if (GUILayout.Button("Take Sample: " + ProfilerDriver.GetConnectionIdentifier(ProfilerDriver.connectedProfiler), EditorStyles.toolbarButton))
            {
                ProfilerDriver.ClearAllFrames();
                ProfilerDriver.deepProfiling = true;
                MemorySnapshot.RequestNewSnapshot();
            }
            if (GUILayout.Button(new GUIContent("Clear Editor References", "Design for profile in editor.\nEditorUtility.UnloadUnusedAssetsImmediate() can be called."), EditorStyles.toolbarButton))
            {
                ClearEditorReferences();
            }
            if (GUILayout.Button("Save Snapshot", EditorStyles.toolbarButton))
            {
                if (data.mSnapshot != null)
                {
                    string fileName = EditorUtility.SaveFilePanel("Save Snapshot", null, "MemorySnapshot", "memsnap");
                    if (!string.IsNullOrEmpty(fileName))
                    {
                        System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                        using (Stream stream = File.Open(fileName, FileMode.Create))
                        {
                            bf.Serialize(stream, data.mSnapshot);
                        }
                    }
                }
                else
                {
                    UnityEngine.Debug.LogWarning("No snapshot to save.  Try taking a snapshot first.");
                }
            }
            if (GUILayout.Button("Load Snapshot", EditorStyles.toolbarButton))
            {
                string fileName = EditorUtility.OpenFilePanel("Load Snapshot", null, "memsnap");
                if (!string.IsNullOrEmpty(fileName))
                {
                    System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    using (Stream stream = File.Open(fileName, FileMode.Open))
                    {
                        IncomingSnapshot(bf.Deserialize(stream) as PackedMemorySnapshot);
                    }
                }
            }
            GUILayout.FlexibleSpace();
            //showObjectInspector = EditorGUILayout.Toggle("Show In Inspector", showObjectInspector); //TODO
            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();
            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 };
                }
            }
            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();
            }
        }
Пример #21
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();
            }
        }
Пример #22
0
 public string GetConnectedProfiler()
 {
     return(ProfilerDriver.GetConnectionIdentifier(ProfilerDriver.connectedProfiler));
 }