Ejemplo n.º 1
0
        public void Init(AbstractSmallWindow hostWindow)
        {
            if (hostWindow != null)
            {
                this.hostWindow = hostWindow;
            }
            OnInit();
            foreach (AbstractSmallWindow sub in subWindow)
            {
                sub.Init(this);
            }
            foreach (AbstractSmallWindow sub in subWindow)
            {
                sub.SnapshotChangeEvent += SnapshotChangeEvent;
                sub.NodeChangeEvent     += NodeChangeEvent;
                sub.GroupChangeEvent    += GroupChangeEvent;
            }
            SnapshotChangeEvent += OnSnapshotChange;
            NodeChangeEvent     += OnNodeChange;
            GroupChangeEvent    += OnGroupChange;

            if (hostWindow != null)
            {
                hostWindow.SnapshotChangeEvent += SnapshotChangeEvent;
                hostWindow.NodeChangeEvent     += NodeChangeEvent;
                hostWindow.GroupChangeEvent    += GroupChangeEvent;
            }
        }
Ejemplo n.º 2
0
        protected override void OnInit()
        {
            mainWindow = hierarchyView;
            hierarchyView.Init(this);
            treeMapView.Init(this);

            hierarchyView.SnapshotChangeEvent += SnapshotChangeEvent;
            hierarchyView.NodeChangeEvent     += NodeChangeEvent;
            hierarchyView.GroupChangeEvent    += GroupChangeEvent;
            treeMapView.SnapshotChangeEvent   += SnapshotChangeEvent;
            treeMapView.NodeChangeEvent       += NodeChangeEvent;
            treeMapView.GroupChangeEvent      += GroupChangeEvent;
        }
Ejemplo n.º 3
0
        public override void Draw(Rect position)
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("检测内存上升"))
            {
                //Debugger.LogError("before: " + AppFacade.luaManager.LuaGC(LuaGCOptions.LUA_GCCOUNT) * 1024);
                //AppFacade.luaManager.LuaGC(LuaGCOptions.LUA_GCCOLLECT);
                //Debugger.LogError("after: " + AppFacade.luaManager.LuaGC(LuaGCOptions.LUA_GCCOUNT) * 1024);
                if (!temp)
                {
                    LuaState lua = AppFacade.luaManager.GetLuaStateOnlyForLuaMonitor();
                    lua.DoFile(Const.CHECK_MEMORY_PATH);
                    LuaFunction main = lua.GetFunction("SC_StartRecordAlloc");
                    main.Call(false);
                    temp = true;
                }
                else
                {
                    LuaState    lua  = AppFacade.luaManager.GetLuaStateOnlyForLuaMonitor();
                    LuaFunction main = lua.GetFunction("SC_StopRecordAllocAndDumpStat");
                    main.Call();
                    EditorUtility.DisplayDialog("", "输出文件memAlloc.csv至工作目录下,默认为Client目录下", "OK");
                    temp = false;
                }
            }
            if (GUILayout.Button("内存快照"))
            {
                if (!EditorApplication.isPlaying)
                {
                    return;
                }
                if (AppFacade.luaManager.GetLuaStateOnlyForLuaMonitor() == null)
                {
                    Debugger.LogError("lua state 为空");
                    return;
                }
                //Debugger.LogError("before: " + AppFacade.luaManager.LuaGC(LuaGCOptions.LUA_GCCOUNT) * 1024);
                //AppFacade.luaManager.LuaGC(LuaGCOptions.LUA_GCCOLLECT);
                //Debugger.LogError("after: " + AppFacade.luaManager.LuaGC(LuaGCOptions.LUA_GCCOUNT) * 1024);

                Snapshot snapshot = Snapshot.GetSnapshot(AppFacade.luaManager.GetLuaStateOnlyForLuaMonitor());
                if (snapshot == null)
                {
                    Debugger.LogError("snapshot 为空");
                    return;
                }
                snapshotList.Add(snapshot);
                snapshot.name = "S" + snapshotList.Count;
                if (SnapshotChangeEvent != null)
                {
                    SnapshotChangeEvent(snapshot);
                }
                Snapshot.snapshot_clear();
            }
            if (GUILayout.Button("交集"))
            {
                Snapshot snapshot1 = hierarchyView.snapshot;
                Snapshot snapshot2 = hierarchyView.snapshot2;
                if (snapshot1 == null || snapshot2 == null)
                {
                    return;
                }
                Snapshot snapshot = Snapshot.GetIntersection(snapshot1, snapshot2);
                snapshotList.Add(snapshot);
                snapshot.name = "(" + snapshot1.name + "∩" + snapshot2.name + ")";
                if (SnapshotChangeEvent != null)
                {
                    SnapshotChangeEvent(snapshot);
                }
            }
            if (GUILayout.Button("差集"))
            {
                Snapshot snapshot1 = hierarchyView.snapshot;
                Snapshot snapshot2 = hierarchyView.snapshot2;
                if (snapshot1 == null || snapshot2 == null)
                {
                    return;
                }
                Snapshot snapshot = Snapshot.GetDifferenceSet(snapshot1, snapshot2);
                snapshotList.Add(snapshot);
                snapshot.name = "(" + snapshot1.name + "-" + snapshot2.name + ")";
                if (SnapshotChangeEvent != null)
                {
                    SnapshotChangeEvent(snapshot);
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("层级视图"))
            {
                mainWindow = hierarchyView;
            }
            if (GUILayout.Button("树图"))
            {
                mainWindow = treeMapView;
            }
            GUILayout.EndHorizontal();
            if (snapshotList.Count != 0)
            {
                mainWindow.Draw(new Rect(0f, EditorGUIUtility.singleLineHeight * 3 + 1, position.width, position.height - EditorGUIUtility.singleLineHeight * 3 - 1));
            }
        }