void TopToolBar(Rect rect)
        {
            GUILayout.BeginArea(rect);
            using (new EditorGUILayout.HorizontalScope())
            {
                var style = "miniButton";
                if (GUILayout.Button("Take Snapshot", style))
                {
                    m_Status = "Taking snapshot.....";
                    UnityEditor.MemoryProfiler.MemorySnapshot.RequestNewSnapshot();
                }

                if (GUILayout.Button("Load Snapshot", style))
                {
                    m_Status = "Loading snapshot.....";
                    PackedMemorySnapshot packedSnapshot = PackedMemorySnapshotUtility.LoadFromFile();
                    if (packedSnapshot != null)
                    {
                        IncomingSnapshot(packedSnapshot);
                    }
                }

                if (GUILayout.Button("Save Snapshot", style))
                {
                    m_Status = "Saving snapshot.....";
                    PackedMemorySnapshotUtility.SaveToFile(_snapshot);
                }
            }

            GUILayout.EndArea();
        }
Exemplo n.º 2
0
        // Playerからのメッセージ処理用イベント関数
        private void OnMessageEvent(MessageEventArgs args)
        {
            var text = Encoding.ASCII.GetString(args.data);

            Debug.Log("Message from player: " + text);
            if (text.Contains(TakeSnapShotText))
            {
                UnityEditor.EditorUtility.DisplayProgressBar("Take Snapshot", "Downloading Snapshot...", 0.0f);
                try
                {
                    UnityEditor.MemoryProfiler.MemorySnapshot.RequestNewSnapshot();
                }
                finally
                {
                    var fname = text.Substring(TakeSnapShotText.Length + 1);
                    var fpath = string.Format("{0}/{1}{2}", m_savePath, fname, ".memsnap3");

                    // 注意:この関数はprivateになっているのでpunlicに変更して下さい。
                    PackedMemorySnapshotUtility.SaveToFile(fpath, m_snapshot);


                    EditorConnection.instance.Send(UnityMemoryProfilerSupportKunClient.kMsgSendEditorToPlayer, Encoding.ASCII.GetBytes("Success"));
                    EditorUtility.ClearProgressBar();
                }
            }
        }
        void TopToolBar(Rect rect)
        {
            GUILayout.BeginArea(rect);
            using (new EditorGUILayout.HorizontalScope())
            {
                var style = "miniButton";
                if (GUILayout.Button("Take Snapshot", style))
                {
                    bCheckHeapOnly = false;
                    m_Status       = "Taking snapshot.....";
                    UnityEditor.MemoryProfiler.MemorySnapshot.RequestNewSnapshot();
                }

                if (GUILayout.Button("Load Snapshot", style))
                {
                    bCheckHeapOnly = false;
                    m_Status       = "Loading snapshot.....";
                    PackedMemorySnapshot packedSnapshot = PackedMemorySnapshotUtility.LoadFromFile();
                    //Debug.Log("Unlock!!!!!!!!!!!! " + packedSnapshot);
                    if (packedSnapshot != null)
                    {
                        IncomingSnapshot(packedSnapshot);
                    }
                }

                if (_snapshot != null)
                {
                    if (GUILayout.Button("Save Snapshot", style))
                    {
                        m_Status = "Saving snapshot.....";
                        PackedMemorySnapshotUtility.SaveToFile(_snapshot);
                    }
                }

                if (_unpackedCrawl != null)
                {
#if UNITY_5_6_OR_NEWER
                    //if (bCheckHeapOnly)
                    //{

                    if (GUILayout.Button("Show Tree/Node View", style))
                    {
                        bCheckHeapOnly          = false;
                        m_nodeView.bShowMemHeap = false;
                        m_nodeView.ClearNodeView();
                        m_TreeView.Reload();
                    }

                    //}
                    //else
                    {
#endif
                    if (GUILayout.Button("Show Heap Usage", style))
                    {
                        bCheckHeapOnly = true;
                        bshowPlainData = false;
                        m_nodeView.ClearNodeView();
                        m_nodeView.CreateTreelessView(_unpackedCrawl);
                    }

                    if (GUILayout.Button("Show Plain Data", style))
                    {
                        bCheckHeapOnly = true;
                        bshowPlainData = true;
                    }
#if UNITY_5_6_OR_NEWER
                }
#endif
                }
            }

            GUILayout.EndArea();
        }
        void TopToolBar(Rect rect)
        {
            GUILayout.BeginArea(rect);
            using (new EditorGUILayout.HorizontalScope()) {
                var style = "miniButton";
                if (GUILayout.Button("Take Snapshot", style))
                {
                    m_Status = "Taking snapshot.....";
                    UnityEditor.MemoryProfiler.MemorySnapshot.RequestNewSnapshot();
                }

                if (GUILayout.Button("Load Snapshot", style))
                {
                    m_Status = "Loading snapshot.....";
                    PackedMemorySnapshot packedSnapshot = PackedMemorySnapshotUtility.LoadFromFile();
                    if (packedSnapshot != null)
                    {
                        IncomingSnapshot(packedSnapshot);
                    }
                }

                if (_snapshot != null)
                {
                    if (GUILayout.Button("Save Snapshot", style))
                    {
                        m_Status = "Saving snapshot.....";
                        PackedMemorySnapshotUtility.SaveToFile(_snapshot);
                    }
                }

                if (GUILayout.Button("Load CrawlerData", style))
                {
                    m_Status       = "Loading CrawlerData.....";
                    _packedCrawled = PackedMemorySnapshotUtility.LoadCrawlerDataFromFile();
                    if (null != _packedCrawled)
                    {
                        m_nodeView.ClearNodeView();
                        _snapshot                = _packedCrawled.packedMemorySnapshot;
                        _unpackedCrawl           = null;
                        _packedCrawlGenerating   = true;
                        _unpackedCrawlGenerating = false;
                    }
                }

                if (_packedCrawled != null)
                {
                    if (GUILayout.Button("Save CrawlerData", style))
                    {
                        m_Status = "Saving CrawlerData.....";
                        PackedMemorySnapshotUtility.SaveCrawlerDataToFile(_packedCrawled);
                    }
                }

                if (_unpackedCrawl != null)
                {
                    if (GUILayout.Button("Show Heap Usage", style))
                    {
                        bshowPlainData = false;
                        m_nodeView.ClearNodeView();
                        m_nodeView.CreateTreelessView(_unpackedCrawl);
                    }

                    if (GUILayout.Button("Show Plain Data", style))
                    {
                        bshowPlainData = true;
                    }
                }
            }
            GUILayout.EndArea();
        }